waybar: add module

PR #1329
This commit is contained in:
Nicolas Berbiche 2020-07-29 16:29:51 -04:00 committed by Robert Helgesson
parent 2a54c353a9
commit f4f9f1a618
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
14 changed files with 688 additions and 0 deletions

View file

@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }:
with lib;
let
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
expected = pkgs.writeText "expected-json" ''
[
{
"height": 26,
"layer": "top",
"modules-center": [
"sway/window"
],
"modules-left": [
"sway/workspaces",
"sway/mode"
],
"modules-right": [
"idle_inhibitor",
"pulseaudio",
"network",
"cpu",
"memory",
"backlight",
"tray",
"clock"
],
"output": [
"DP-1",
"eDP-1",
"HEADLESS-1"
],
"position": "top",
"sway/workspaces": {
"all-outputs": true
}
}
]
'';
in {
config = {
programs.waybar = {
inherit package;
enable = true;
systemd.enable = true;
settings = [{
layer = "top";
position = "top";
height = 26;
output = [ "DP-1" "eDP-1" "HEADLESS-1" ];
modules-left = [ "sway/workspaces" "sway/mode" ];
modules-center = [ "sway/window" ];
modules-right = [
"idle_inhibitor"
"pulseaudio"
"network"
"cpu"
"memory"
"backlight"
"tray"
"clock"
];
modules = { "sway/workspaces".all-outputs = true; };
}];
};
nmt.description = ''
Test for the broken configuration
https://github.com/rycee/home-manager/pull/1329#issuecomment-653253069
'';
nmt.script = ''
assertPathNotExists home-files/.config/waybar/style.css
assertFileContent \
home-files/.config/waybar/config \
${expected}
'';
};
}

View file

@ -0,0 +1,8 @@
{
waybar-systemd-with-graphical-session-target =
./systemd-with-graphical-session-target.nix;
waybar-styling = ./styling.nix;
waybar-settings-complex = ./settings-complex.nix;
# Broken configuration from https://github.com/rycee/home-manager/pull/1329#issuecomment-653253069
waybar-broken-settings = ./broken-settings.nix;
}

View file

@ -0,0 +1,46 @@
[
{
"custom/my-module": {
"exec": "@dummy@/bin/dummy",
"format": "hello from {}"
},
"height": 30,
"idle_inhibitor": {
"format": "{icon}"
},
"layer": "top",
"modules-center": [
"sway/window"
],
"modules-left": [
"sway/workspaces",
"sway/mode",
"custom/my-module"
],
"modules-right": [
"idle_inhibitor",
"pulseaudio",
"network",
"cpu",
"memory",
"backlight",
"tray",
"battery",
"clock"
],
"output": [
"DP-1"
],
"position": "top",
"sway/mode": {
"tooltip": false
},
"sway/window": {
"max-length": 120
},
"sway/workspaces": {
"all-outputs": true,
"disable-scroll": true
}
}
]

View file

@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:
with lib;
let
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = {
programs.waybar = {
inherit package;
enable = true;
settings = [{
layer = "top";
position = "top";
height = 30;
output = [ "DP-1" ];
modules-left = [ "sway/workspaces" "sway/mode" "custom/my-module" ];
modules-center = [ "sway/window" ];
modules-right = [
"idle_inhibitor"
"pulseaudio"
"network"
"cpu"
"memory"
"backlight"
"tray"
"battery"
"clock"
];
modules = {
"sway/workspaces" = {
disable-scroll = true;
all-outputs = true;
};
"sway/mode" = { tooltip = false; };
"sway/window" = { max-length = 120; };
"idle_inhibitor" = { format = "{icon}"; };
"custom/my-module" = {
format = "hello from {}";
exec = let
dummyScript =
pkgs.writeShellScriptBin "dummy" "echo within waybar" // {
outPath = "@dummy@";
};
in "${dummyScript}/bin/dummy";
};
};
}];
};
nmt.script = ''
assertPathNotExists home-files/.config/waybar/style.css
assertFileContent \
home-files/.config/waybar/config \
${./settings-complex-expected.json}
'';
};
}

View file

@ -0,0 +1,23 @@
* {
border: none;
border-radius: 0;
font-family: Source Code Pro;
font-weight: bold;
color: #abb2bf;
font-size: 18px;
min-height: 0px;
}
window#waybar {
background: #16191C;
color: #aab2bf;
}
#window {
padding: 0 0px;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background: #16191C;
border: #16191C;
padding: 0 3px;
}

View file

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
with lib;
let
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = {
programs.waybar = {
inherit package;
enable = true;
style = ''
* {
border: none;
border-radius: 0;
font-family: Source Code Pro;
font-weight: bold;
color: #abb2bf;
font-size: 18px;
min-height: 0px;
}
window#waybar {
background: #16191C;
color: #aab2bf;
}
#window {
padding: 0 0px;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background: #16191C;
border: #16191C;
padding: 0 3px;
}
'';
};
nmt.script = ''
assertPathNotExists home-files/.config/waybar/config
assertFileContent \
home-files/.config/waybar/style.css \
${./styling-expected.css}
'';
};
}

View file

@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
with lib;
let
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = {
programs.waybar = {
inherit package;
enable = true;
systemd.enable = true;
};
nmt.script = ''
assertPathNotExists home-files/.config/waybar/config
assertPathNotExists home-files/.config/waybar/style.css
assertFileContent \
home-files/.config/systemd/user/waybar.service \
${./systemd-with-graphical-session-target.service}
'';
};
}

View file

@ -0,0 +1,16 @@
[Install]
WantedBy=graphical-session.target
[Service]
BusName=fr.arouillard.waybar
ExecStart=@waybar@/bin/waybar
Restart=always
RestartSec=1sec
Type=dbus
[Unit]
After=dbus.service
Description=Highly customizable Wayland bar for Sway and Wlroots based compositors.
Documentation=https://github.com/Alexays/Waybar/wiki
PartOf=graphical-session.target
Requisite=dbus.service