diff --git a/common/desktop_environment/sway/default.nix b/common/desktop_environment/sway/default.nix index 7388ce6..44c664b 100644 --- a/common/desktop_environment/sway/default.nix +++ b/common/desktop_environment/sway/default.nix @@ -79,6 +79,7 @@ with lib; slurp wf-recorder btop + pavucontrol ]; services.blueman.enable = config.hardware.bluetooth.enable; diff --git a/common/desktop_environment/sway/home_manager/sway.nix b/common/desktop_environment/sway/home_manager/sway.nix index efa6ff4..236e820 100644 --- a/common/desktop_environment/sway/home_manager/sway.nix +++ b/common/desktop_environment/sway/home_manager/sway.nix @@ -60,11 +60,34 @@ in # Bitwarden chrome popup as floating example from Hyprland rules { criteria = { - class = "chrome-nngceckbapebfimnlniiiahkandclblb-Default"; - title = "_crx_nngceckbapebfimnlniiiahkandclblb"; - instance = ".*"; + app_id = "chrome-nngceckbapebfimnlniiiahkandclblb-Default"; }; - command = "floating enable, move position center, resize set 720 600"; + command = "floating enable"; + } + { + criteria = { + app_id = "pavucontrol"; + }; + command = "floating enable, move position center, resize set 620 1200"; + } + { + criteria = { + class = "Google-chrome"; + window_role = "pop-up"; + }; + command = "floating enable, move position center, resize set 720 480"; + } + { + criteria = { + window_role = "pop-up"; + }; + command = "floating enable, move position center, resize set 640 420"; + } + { + criteria = { + window_role = "About"; + }; + command = "floating enable, move position center, resize set 640 420"; } ]; }; diff --git a/common/desktop_environment/sway/home_manager/waybar.nix b/common/desktop_environment/sway/home_manager/waybar.nix index e277f0d..b381d18 100644 --- a/common/desktop_environment/sway/home_manager/waybar.nix +++ b/common/desktop_environment/sway/home_manager/waybar.nix @@ -1,11 +1,17 @@ { lib, osConfig, ... }: let ccfg = import ../../../config.nix; - cfg_path = [ ccfg.custom_config_key "desktopEnvironment" "sway" "waybar" ]; + cfg_path = [ + ccfg.custom_config_key + "desktopEnvironment" + "sway" + "waybar" + ]; cfg = lib.attrsets.getAttrFromPath cfg_path osConfig; in { config = lib.mkIf cfg.enable { + programs.waybar = { enable = true; systemd.enable = true; @@ -13,28 +19,125 @@ in mainBar = { layer = "top"; position = "top"; - height = 30; + height = 28; spacing = 6; margin-top = 0; margin-bottom = 0; margin-left = 10; margin-right = 10; - modules-left = [ "sway/workspaces" ]; - modules-center = [ "clock" "temperature" "cpu" "memory" "disk" ]; - modules-right = [ "pulseaudio" "network" "bluetooth" "custom/notifications" "sway/language" ]; + modules-left = [ + "sway/workspaces" + "sway/mode" + "sway/scratchpad" + ]; + modules-center = [ + "clock" + "temperature" + "cpu" + "memory" + "disk" + ]; + modules-right = [ + "battery" + "battery#bat2" + "pulseaudio" + "network" + "bluetooth" + "power-profiles-daemon" + "backlight" + "custom/notifications" + "sway/language" + "tray" + "custom/power" + ]; + # LEFT "sway/workspaces" = { format = "{icon}"; format-icons = { - "1" = "一"; "2" = "二"; "3" = "三"; "4" = "四"; "5" = "五"; - "6" = "六"; "7" = "七"; "8" = "八"; "9" = "九"; "10" = "十"; - "11" = "十一"; "12" = "十二"; "13" = "十三"; "14" = "十四"; "15" = "十五"; - "16" = "十六"; "17" = "十七"; "18" = "十八"; "19" = "十九"; "20" = "二十"; + "1" = "一"; + "2" = "二"; + "3" = "三"; + "4" = "四"; + "5" = "五"; + "6" = "六"; + "7" = "七"; + "8" = "八"; + "9" = "九"; + "10" = "十"; + "11" = "十一"; + "12" = "十二"; + "13" = "十三"; + "14" = "十四"; + "15" = "十五"; + "16" = "十六"; + "17" = "十七"; + "18" = "十八"; + "19" = "十九"; + "20" = "二十"; }; disable-scroll = false; }; + # CENTER + clock = { + format = "{:%b %d, %H:%M}"; + tooltip-format = "{:%Y %B}\n{calendar}"; + }; + + temperature = { + thermal-zone = 2; + hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input"; + critical-threshold = 80; + format-critical = "󰔏 {temperatureC}°C"; + format = "󰔏 {temperatureC}°C"; + }; + + cpu = { + format = "󰻠 {usage}%"; + tooltip = true; + on-click = "btop"; + }; + + memory = { + format = "󰍛 {}%"; + on-click = "btop"; + }; + + disk = { + interval = 30; + format = "󰋊 {percentage_used}%"; + path = "/"; + on-click = "btop"; + }; + + # RIGHT + "battery" = { + "states" = { + # "good"= 95; + "warning" = 30; + "critical" = 15; + }; + "format" = "{capacity}% {icon}"; + "format-full" = "{capacity}% {icon}"; + "format-charging" = "{capacity}% "; + "format-plugged" = "{capacity}% "; + "format-alt" = "{time} {icon}"; + # "format-good"= ""; // An empty format will hide the module + # "format-full"= ""; + "format-icons" = [ + "" + "" + "" + "" + "" + ]; + }; + "battery#bat2" = { + "bat" = "BAT2"; + }; + pulseaudio = { format = "{icon} {volume}%"; format-bluetooth = "󰂰 {volume}%"; @@ -49,44 +152,17 @@ in phone = "󰏲"; portable = "󰦧"; car = "󰄋"; - default = [ "󰕿" "󰖀" "󰕾" ]; + default = [ + "󰕿" + "󰖀" + "󰕾" + ]; }; scroll-step = 5; - on-click = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; - on-click-right = "swaync-client -t -sw"; + on-click = "pavucontrol"; + on-click-right = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; }; - "custom/notifications" = { - format = "{icon} {}"; - format-icons = { - notification = ""; none = ""; - dnd-notification = "󰂛"; dnd-none = "󰂛"; - inhibited-notification = ""; inhibited-none = ""; - dnd-inhibited-notification = "󰂛"; dnd-inhibited-none = "󰂛"; - }; - return-type = "json"; - exec-if = "which swaync-client"; - exec = "swaync-client -swb"; - on-click = "swaync-client -t -sw"; - on-click-right = "swaync-client -d -sw"; - escape = true; - tooltip = false; - }; - - clock = { format = "{:%b %d, %H:%M}"; }; - - temperature = { - thermal-zone = 2; - hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input"; - critical-threshold = 80; - format-critical = "󰔏 {temperatureC}°C"; - format = "󰔏 {temperatureC}°C"; - }; - - cpu = { format = "󰻠 {usage}%"; tooltip = false; on-click = "btop"; }; - memory = { format = "󰍛 {}%"; on-click = "btop"; }; - disk = { interval = 30; format = "󰋊 {percentage_used}%"; path = "/"; on-click = "btop"; }; - network = { format-wifi = "󰤨 {essid} ({signalStrength}%)"; format-ethernet = "󰈀 {ipaddr}/{cidr}"; @@ -109,24 +185,77 @@ in # on-click-right = "bluetoothctl power toggle"; }; - "sway/language" = { format = "{}"; }; # simplified + "power-profiles-daemon" = { + format = "{icon}"; + "tooltip-format" = "Power profile: {profile}\nDriver: {driver}"; + tooltip = true; + "format-icons" = { + default = ""; + performance = ""; + balanced = ""; + "power-saver" = ""; + }; + }; + + backlight = { + format = "{percent}% {icon}"; + "format-icons" = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + ]; + }; + + "custom/notifications" = { + format = "{icon} {}"; + format-icons = { + notification = ""; + none = ""; + dnd-notification = "󰂛"; + dnd-none = "󰂛"; + inhibited-notification = ""; + inhibited-none = ""; + dnd-inhibited-notification = "󰂛"; + dnd-inhibited-none = "󰂛"; + }; + return-type = "json"; + exec-if = "which swaync-client"; + exec = "swaync-client -swb"; + on-click = "swaync-client -t -sw"; + on-click-right = "swaync-client -d -sw"; + escape = true; + tooltip = false; + }; + + "sway/language" = { + format = "{}"; + }; + + "tray" = { + "spacing" = 10; + }; + + "custom/power" = { + format = "⏻ "; + tooltip = false; + menu = "on-click"; + "menu-file" = ./waybar/power_menu.xml; + "menu-actions" = { + shutdown = "shutdown 0"; + reboot = "reboot"; + }; + }; + }; }; - style = '' - * { font-family: "JetBrainsMonoNL Nerd Font"; font-size: 12px; border: none; border-radius: 0; min-height: 0; } - window#waybar { background: transparent; border-radius: 10px; margin: 0px; } - .modules-left,.modules-center,.modules-right { background: rgba(26,27,38,.8); border-radius: 10px; margin: 4px; padding: 0 10px; } - #workspaces { padding: 0 5px; } - #workspaces button { padding: 0 8px; background: transparent; color: #c0caf5; border-radius: 5px; margin: 2px; } - #workspaces button:hover { background: rgba(125,196,228,.2); color: #7dcae4; } - #workspaces button.active { background: #7dcae4; color: #1a1b26; } - #pulseaudio,#custom-notifications,#clock,#temperature,#cpu,#memory,#disk,#network,#bluetooth,#language { padding: 0 8px; color: #c0caf5; margin: 2px; } - #temperature.critical { color: #f7768e; } - #network.disconnected { color: #f7768e; } - #bluetooth.disabled { color: #565f89; } - #pulseaudio.muted { color: #565f89; } - ''; + style = builtins.readFile ./waybar/waybar.css; }; }; } diff --git a/common/desktop_environment/sway/home_manager/waybar/power_menu.xml b/common/desktop_environment/sway/home_manager/waybar/power_menu.xml new file mode 100644 index 0000000..ae0de45 --- /dev/null +++ b/common/desktop_environment/sway/home_manager/waybar/power_menu.xml @@ -0,0 +1,18 @@ + + + + + + Reboot + + + + + + + + Shutdown + + + + diff --git a/common/desktop_environment/sway/home_manager/waybar/waybar.css b/common/desktop_environment/sway/home_manager/waybar/waybar.css new file mode 100644 index 0000000..11c5bcc --- /dev/null +++ b/common/desktop_environment/sway/home_manager/waybar/waybar.css @@ -0,0 +1,334 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: "JetBrainsMonoNL Nerd Font", FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 12px; + border: none; + border-radius: 0; + min-height: 0; +} + +window#waybar { + /* 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; */ + background: transparent; + border-radius: 10px; + margin: 0px; +} + +window#waybar.hidden { + opacity: 0.2; +} + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +button { + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each button name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +button:hover { + background: inherit; + box-shadow: inset 0 -3px #ffffff; +} + +/* you can set a style on hover for any module like this */ +#pulseaudio:hover { + background-color: #a37800; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; +} + +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#wireplumber, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#scratchpad, +#power-profiles-daemon, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left>widget:first-child>#workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right>widget:last-child>#workspaces { + margin-right: 0; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +} + +#battery.charging, +#battery.plugged { + color: #ffffff; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +/* Using steps() instead of linear as a timing function to limit cpu usage */ +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: steps(12); + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#power-profiles-daemon { + padding-right: 15px; +} + +#power-profiles-daemon.performance { + background-color: #f53c3c; + color: #ffffff; +} + +#power-profiles-daemon.balanced { + background-color: #2980b9; + color: #ffffff; +} + +#power-profiles-daemon.power-saver { + background-color: #2ecc71; + color: #000000; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#wireplumber { + background-color: #fff0f5; + color: #000000; +} + +#wireplumber.muted { + background-color: #f53c3c; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray>.passive { + -gtk-icon-effect: dim; +} + +#tray>.needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #00b093; + color: #740864; + padding: 0 5px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state>label { + padding: 0 5px; +} + +#keyboard-state>label.locked { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad.empty { + background-color: transparent; +} + +#privacy { + padding: 0; +} + +#privacy-item { + padding: 0 5px; + color: white; +} + +#privacy-item.screenshare { + background-color: #cf5700; +} + +#privacy-item.audio-in { + background-color: #1ca000; +} + +#privacy-item.audio-out { + background-color: #0069d4; +}