Compare commits

...

2 Commits

2 changed files with 301 additions and 309 deletions

View File

@ -1,9 +1,76 @@
{ pkgs, lib, config, ... }: { config, lib, pkgs, sane-lib, ... }:
# docs: https://nixos.wiki/wiki/Sway # docs: https://nixos.wiki/wiki/Sway
with lib; with lib;
let let
cfg = config.sane.gui.sway; cfg = config.sane.gui.sway;
# docs: https://github.com/Alexays/Waybar/wiki/Configuration
# format specifiers: https://fmt.dev/latest/syntax.html#syntax
waybar-config = [
{ # TOP BAR
layer = "top";
height = 40;
modules-left = ["sway/workspaces" "sway/mode"];
modules-center = ["sway/window"];
modules-right = ["custom/mediaplayer" "clock" "battery" "cpu" "network"];
"sway/window" = {
max-length = 50;
};
# include song artist/title. source: https://www.reddit.com/r/swaywm/comments/ni0vso/waybar_spotify_tracktitle/
"custom/mediaplayer" = {
exec = pkgs.writeShellScript "waybar-mediaplayer" ''
player_status=$(${pkgs.playerctl}/bin/playerctl status 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
echo "$(${pkgs.playerctl}/bin/playerctl metadata artist) - $(${pkgs.playerctl}/bin/playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo " $(${pkgs.playerctl}/bin/playerctl metadata artist) - $(${pkgs.playerctl}/bin/playerctl metadata title)"
fi
'';
interval = 2;
format = "{} ";
# return-type = "json";
on-click = "${pkgs.playerctl}/bin/playerctl play-pause";
on-scroll-up = "${pkgs.playerctl}/bin/playerctl next";
on-scroll-down = "${pkgs.playerctl}/bin/playerctl previous";
};
network = {
# docs: https://github.com/Alexays/Waybar/blob/master/man/waybar-network.5.scd
interval = 2;
max-length = 40;
# custom :> format specifier explained here: https://github.com/Alexays/Waybar/pull/472
format-ethernet = " {bandwidthUpBits:>} {bandwidthDownBits:>}";
tooltip-format-ethernet = "{ifname} {bandwidthUpBits:>} {bandwidthDownBits:>}";
format-wifi = "{ifname} ({signalStrength}%) {bandwidthUpBits:>} {bandwidthDownBits:>}";
tooltip-format-wifi = "{essid} ({signalStrength}%) {bandwidthUpBits:>} {bandwidthDownBits:>}";
format-disconnected = "";
};
cpu = {
format = " {usage:2}%";
tooltip = false;
};
battery = {
states = {
good = 95;
warning = 30;
critical = 10;
};
format = "{icon} {capacity}%";
format-icons = [
""
""
""
""
""
];
};
clock = {
format-alt = "{:%a, %d. %b %H:%M}";
};
}
];
waybar-config-text = lib.generators.toJSON {} waybar-config;
in in
{ {
options = { options = {
@ -288,351 +355,285 @@ in
}; };
}; };
sane.home-manager.programs.waybar = { sane.fs."/home/colin/.config/waybar/config" = sane-lib.fs.wantedText waybar-config-text;
enable = true;
# docs: https://github.com/Alexays/Waybar/wiki/Configuration
# format specifiers: https://fmt.dev/latest/syntax.html#syntax
settings = {
mainBar = {
layer = "top";
height = 40;
modules-left = ["sway/workspaces" "sway/mode"];
modules-center = ["sway/window"];
modules-right = ["custom/mediaplayer" "clock" "battery" "cpu" "network"];
"sway/window" = {
max-length = 50;
};
# include song artist/title. source: https://www.reddit.com/r/swaywm/comments/ni0vso/waybar_spotify_tracktitle/
"custom/mediaplayer" = {
exec = pkgs.writeShellScript "waybar-mediaplayer" ''
player_status=$(${pkgs.playerctl}/bin/playerctl status 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
echo "$(${pkgs.playerctl}/bin/playerctl metadata artist) - $(${pkgs.playerctl}/bin/playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo " $(${pkgs.playerctl}/bin/playerctl metadata artist) - $(${pkgs.playerctl}/bin/playerctl metadata title)"
fi
'';
interval = 2;
format = "{} ";
# return-type = "json";
on-click = "${pkgs.playerctl}/bin/playerctl play-pause";
on-scroll-up = "${pkgs.playerctl}/bin/playerctl next";
on-scroll-down = "${pkgs.playerctl}/bin/playerctl previous";
};
network = {
# docs: https://github.com/Alexays/Waybar/blob/master/man/waybar-network.5.scd
interval = 2;
max-length = 40;
# custom :> format specifier explained here: https://github.com/Alexays/Waybar/pull/472
format-ethernet = " {bandwidthUpBits:>} {bandwidthDownBits:>}";
tooltip-format-ethernet = "{ifname} {bandwidthUpBits:>} {bandwidthDownBits:>}";
format-wifi = "{ifname} ({signalStrength}%) {bandwidthUpBits:>} {bandwidthDownBits:>}"; # style docs: https://github.com/Alexays/Waybar/wiki/Styling
tooltip-format-wifi = "{essid} ({signalStrength}%) {bandwidthUpBits:>} {bandwidthDownBits:>}"; sane.fs."/home/colin/.config/waybar/style.css" = sane-lib.fs.wantedText ''
* {
font-family: monospace;
}
format-disconnected = ""; /* defaults below: https://github.com/Alexays/Waybar/blob/master/resources/style.css */
}; window#waybar {
cpu = { background-color: rgba(43, 48, 59, 0.5);
format = " {usage:2}%"; border-bottom: 3px solid rgba(100, 114, 125, 0.5);
tooltip = false; color: #ffffff;
}; transition-property: background-color;
battery = { transition-duration: .5s;
states = { }
good = 95;
warning = 30;
critical = 10;
};
format = "{icon} {capacity}%";
format-icons = [
""
""
""
""
""
];
};
clock = {
format-alt = "{:%a, %d. %b %H:%M}";
};
};
};
# style docs: https://github.com/Alexays/Waybar/wiki/Styling
style = ''
* {
font-family: monospace;
}
/* defaults below: https://github.com/Alexays/Waybar/blob/master/resources/style.css */ window#waybar.hidden {
window#waybar { opacity: 0.2;
background-color: rgba(43, 48, 59, 0.5); }
border-bottom: 3px solid rgba(100, 114, 125, 0.5);
color: #ffffff;
transition-property: background-color;
transition-duration: .5s;
}
window#waybar.hidden { /*
opacity: 0.2; window#waybar.empty {
} background-color: transparent;
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
/* window#waybar.termite {
window#waybar.empty { background-color: #3F3F3F;
background-color: transparent; }
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
window#waybar.termite { window#waybar.chromium {
background-color: #3F3F3F; background-color: #000000;
} border: none;
}
window#waybar.chromium { #workspaces button {
background-color: #000000; padding: 0 5px;
border: none; background-color: transparent;
} color: #ffffff;
/* Use box-shadow instead of border so the text isn't offset */
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each workspace name */
border: none;
border-radius: 0;
}
#workspaces button { /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
padding: 0 5px; #workspaces button:hover {
background-color: transparent; background: rgba(0, 0, 0, 0.2);
color: #ffffff; box-shadow: inset 0 -3px #ffffff;
/* Use box-shadow instead of border so the text isn't offset */ }
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each workspace name */
border: none;
border-radius: 0;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ #workspaces button.focused {
#workspaces button:hover { background-color: #64727D;
background: rgba(0, 0, 0, 0.2); box-shadow: inset 0 -3px #ffffff;
box-shadow: inset 0 -3px #ffffff; }
}
#workspaces button.focused { #workspaces button.urgent {
background-color: #64727D; background-color: #eb4d4b;
box-shadow: inset 0 -3px #ffffff; }
}
#workspaces button.urgent { #mode {
background-color: #eb4d4b; background-color: #64727D;
} border-bottom: 3px solid #ffffff;
}
#mode { #clock,
background-color: #64727D; #battery,
border-bottom: 3px solid #ffffff; #cpu,
} #memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#mpd {
padding: 0 10px;
color: #ffffff;
}
#clock, #window,
#battery, #workspaces {
#cpu, margin: 0 4px;
#memory, }
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#mpd {
padding: 0 10px;
color: #ffffff;
}
#window, /* If workspaces is the leftmost module, omit left margin */
#workspaces { .modules-left > widget:first-child > #workspaces {
margin: 0 4px; margin-left: 0;
} }
/* If workspaces is the leftmost module, omit left margin */ /* If workspaces is the rightmost module, omit right margin */
.modules-left > widget:first-child > #workspaces { .modules-right > widget:last-child > #workspaces {
margin-left: 0; margin-right: 0;
} }
/* If workspaces is the rightmost module, omit right margin */ #clock {
.modules-right > widget:last-child > #workspaces { background-color: #64727D;
margin-right: 0; }
}
#clock { #battery {
background-color: #64727D; background-color: #ffffff;
} color: #000000;
}
#battery { #battery.charging, #battery.plugged {
color: #ffffff;
background-color: #26A65B;
}
@keyframes blink {
to {
background-color: #ffffff; background-color: #ffffff;
color: #000000; color: #000000;
} }
}
#battery.charging, #battery.plugged { #battery.critical:not(.charging) {
color: #ffffff; background-color: #f53c3c;
background-color: #26A65B; color: #ffffff;
} animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes blink { label:focus {
to { background-color: #000000;
background-color: #ffffff; }
color: #000000;
}
}
#battery.critical:not(.charging) { #cpu {
background-color: #f53c3c; background-color: #2ecc71;
color: #ffffff; color: #000000;
animation-name: blink; }
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
label:focus { #memory {
background-color: #000000; background-color: #9b59b6;
} }
#cpu { #disk {
background-color: #2ecc71; background-color: #964B00;
color: #000000; }
}
#memory { #backlight {
background-color: #9b59b6; background-color: #90b1b1;
} }
#disk { #network {
background-color: #964B00; background-color: #2980b9;
} }
#backlight { #network.disconnected {
background-color: #90b1b1; background-color: #f53c3c;
} }
#network { #pulseaudio {
background-color: #2980b9; background-color: #f1c40f;
} color: #000000;
}
#network.disconnected { #pulseaudio.muted {
background-color: #f53c3c; background-color: #90b1b1;
} color: #2a5c45;
}
#pulseaudio { #custom-media {
background-color: #f1c40f; background-color: #66cc99;
color: #000000; color: #2a5c45;
} min-width: 100px;
}
#pulseaudio.muted { #custom-media.custom-spotify {
background-color: #90b1b1; background-color: #66cc99;
color: #2a5c45; }
}
#custom-media { #custom-media.custom-vlc {
background-color: #66cc99; background-color: #ffa000;
color: #2a5c45; }
min-width: 100px;
}
#custom-media.custom-spotify { #temperature {
background-color: #66cc99; background-color: #f0932b;
} }
#custom-media.custom-vlc { #temperature.critical {
background-color: #ffa000; background-color: #eb4d4b;
} }
#temperature { #tray {
background-color: #f0932b; background-color: #2980b9;
} }
#temperature.critical { #tray > .passive {
background-color: #eb4d4b; -gtk-icon-effect: dim;
} }
#tray { #tray > .needs-attention {
background-color: #2980b9; -gtk-icon-effect: highlight;
} background-color: #eb4d4b;
}
#tray > .passive { #idle_inhibitor {
-gtk-icon-effect: dim; background-color: #2d3436;
} }
#tray > .needs-attention { #idle_inhibitor.activated {
-gtk-icon-effect: highlight; background-color: #ecf0f1;
background-color: #eb4d4b; color: #2d3436;
} }
#idle_inhibitor { #mpd {
background-color: #2d3436; background-color: #66cc99;
} color: #2a5c45;
}
#idle_inhibitor.activated { #mpd.disconnected {
background-color: #ecf0f1; background-color: #f53c3c;
color: #2d3436; }
}
#mpd { #mpd.stopped {
background-color: #66cc99; background-color: #90b1b1;
color: #2a5c45; }
}
#mpd.disconnected { #mpd.paused {
background-color: #f53c3c; background-color: #51a37a;
} }
#mpd.stopped { #language {
background-color: #90b1b1; background: #00b093;
} color: #740864;
padding: 0 5px;
margin: 0 5px;
min-width: 16px;
}
#mpd.paused { #keyboard-state {
background-color: #51a37a; background: #97e1ad;
} color: #000000;
padding: 0 0px;
margin: 0 5px;
min-width: 16px;
}
#language { #keyboard-state > label {
background: #00b093; padding: 0 5px;
color: #740864; }
padding: 0 5px;
margin: 0 5px;
min-width: 16px;
}
#keyboard-state { #keyboard-state > label.locked {
background: #97e1ad; background: rgba(0, 0, 0, 0.2);
color: #000000; }
padding: 0 0px; '';
margin: 0 5px; # style = ''
min-width: 16px; # * {
} # border: none;
# border-radius: 0;
# font-family: Source Code Pro;
# }
# window#waybar {
# background: #16191C;
# color: #AAB2BF;
# }
# #workspaces button {
# padding: 0 5px;
# }
# .custom-spotify {
# padding: 0 10px;
# margin: 0 4px;
# background-color: #1DB954;
# color: black;
# }
# '';
#keyboard-state > label {
padding: 0 5px;
}
#keyboard-state > label.locked {
background: rgba(0, 0, 0, 0.2);
}
'';
# style = ''
# * {
# border: none;
# border-radius: 0;
# font-family: Source Code Pro;
# }
# window#waybar {
# background: #16191C;
# color: #AAB2BF;
# }
# #workspaces button {
# padding: 0 5px;
# }
# .custom-spotify {
# padding: 0 10px;
# margin: 0 4px;
# background-color: #1DB954;
# color: black;
# }
# '';
};
sane.packages.extraUserPkgs = with pkgs; [ sane.packages.extraUserPkgs = with pkgs; [
swaylock swaylock
swayidle # (unused) swayidle # (unused)

View File

@ -23,12 +23,6 @@ in
default = {}; default = {};
type = types.attrs; type = types.attrs;
}; };
# extra attributes to include in home-manager's `programs` option
sane.home-manager.programs = mkOption {
default = {};
type = types.attrs;
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -49,13 +43,10 @@ in
home.username = "colin"; home.username = "colin";
home.homeDirectory = "/home/colin"; home.homeDirectory = "/home/colin";
programs = lib.mkMerge [ programs = {
{ # XXX: unsure what this does?
# XXX: unsure what this does? home-manager.enable = true;
home-manager.enable = true; };
}
cfg.programs
];
}; };
}; };
} }