diff --git a/hosts/MaxNixosLaptop/home.nix b/hosts/MaxNixosLaptop/home.nix index 38dc0df..52f187c 100644 --- a/hosts/MaxNixosLaptop/home.nix +++ b/hosts/MaxNixosLaptop/home.nix @@ -7,6 +7,15 @@ ../../modules/home ]; + kanshi.enable = true; + kanshi.laptop = true; + + waybar.enable = true; + waybar.squeekboard = true; + waybar.mpd = true; + waybar.battery = true; + waybar.backlight = true; + # Home Manager needs a bit of information about you and the paths it should # manage. home.username = "max"; diff --git a/modules/home/git/default.nix b/modules/home/git/default.nix index b0ca686..2862edf 100644 --- a/modules/home/git/default.nix +++ b/modules/home/git/default.nix @@ -1,4 +1,6 @@ {...}: { + imports = [./lazygit.nix]; + programs.git = { enable = true; extraConfig = { diff --git a/modules/home/sway/default.nix b/modules/home/sway/default.nix index 8cd884b..cab1be3 100644 --- a/modules/home/sway/default.nix +++ b/modules/home/sway/default.nix @@ -4,25 +4,6 @@ lib, ... }: let - schema = "org.gnome.desktop.a11y.applications"; - key = "screen-keyboard-enabled"; - - squeekboard_toggle = pkgs.writeShellScriptBin "squeekboard_toggle" '' - if [ "$(gsettings get ${schema} ${key})" == "true" ]; then - gsettings set ${schema} ${key} false - else - gsettings set ${schema} ${key} true - fi - ''; - - squeekboard_format = pkgs.writeShellScriptBin "squeekboard_format" '' - if [ "$(gsettings get ${schema} ${key})" == "true" ]; then - echo '{ "text": "󰌌", "tooltip": "enabled", "percentage": 100 }' - else - echo '{ "text": "󰌐", "tooltip": "disabled", "percentage": 0 }' - fi - ''; - rotate_lisgd = pkgs.writeShellScriptBin "rotate_lisgd" '' # PREV_ORIENTATION and ORIENTATION are given by rot8 @@ -66,11 +47,11 @@ gsettings set $gnome_schema gtk-theme 'Dracula' ''; in { + imports = [./kanshi.nix ./waybar.nix]; + home.packages = with pkgs; [ - waybar # status bar swaylock # screen locking swayidle # automatic screen locking after system idle time - kanshi # hotswap displays foot # terminal keepassxc # used for secrets instead of gnome-keyring ]; @@ -201,7 +182,6 @@ in { {command = "${rotate_lisgd}/bin/rotate_lisgd";} {command = "${pkgs.nwg-launchers}/bin/nwggrid-server -fp";} {command = "${pkgs.keepassxc}/bin/keepassxc";} - {command = "${pkgs.waybar}/bin/waybar";} {command = "${pkgs.foot}/bin/foot -a foot-startup";} {command = "${pkgs.networkmanagerapplet}/bin/nm-applet";} ]; @@ -286,234 +266,6 @@ in { ''; }; - programs.waybar = { - enable = true; - settings = { - mainBar = { - layer = "top"; - position = "top"; - height = 26; - modules-left = ["sway/workspaces" "sway/mode"]; - modules-center = ["sway/window"]; - modules-right = ["mpd" "tray" "custom/squeekboard" "sway/language" "clock" "backlight" "battery" "network"]; - - "sway/workspaces" = { - disable-scroll = true; - all-outputs = false; - format = "{icon} {name}"; - format-icons = { - "main" = "󰈹"; - "term" = ""; - "msg" = "󰷹"; - "music" = "󰫔"; - "urgent" = ""; - "focused" = ""; - "default" = ""; - }; - }; - - "mpd" = { - format = "{stateIcon}{consumeIcon}{randomIcon}{repeatIcon}{singleIcon} {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) {volume}"; - format-stopped = "{stateIcon}{randomIcon}{repeatIcon}{singleIcon} Stopped {volume}"; - format-disconnected = ""; - unkown-tag = "N/A"; - interval = 2; - consume-icons = { - on = "󰮯 "; - off = ""; - }; - random-icons = { - on = "󰒟 "; - off = "󰒞 "; - }; - repeat-icons = { - on = "󰑖 "; - off = "󰑗 "; - }; - single-icons = { - on = "󰑘 "; - off = ""; - }; - state-icons = { - paused = "󰏤 "; - playing = "󰐊 "; - }; - max-length = 50; - }; - - "tray" = { - spacing = 10; - }; - - "custom/squeekboard" = { - format = "{}"; - exec = "${squeekboard_format}/bin/squeekboard_format"; - return-type = "json"; - exec-on-event = true; - interval = 2; - on-click = "${squeekboard_toggle}/bin/squeekboard_toggle"; - }; - - "sway/language" = { - format = "{shortDescription}"; - tooltip = false; - }; - - "clock" = { - interval = 60; - format = "{:%a %d.%m %H:%M}"; - }; - - "backlight" = { - format = "{percent}% {icon}"; - format-icons = ["󰹐" "󱩎" "󱩏" "󱩐" "󱩑" "󱩒" "󱩓" "󱩔" "󱩕" "󱩖" "󰛨"]; - }; - - "battery" = { - format = "{capacity}% {icon}"; - format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; - }; - - "network" = { - format-wifi = "{essid} ({signalStrength}%) 󰖩"; - format-ethernet = "{ipaddr}/{cidr} 󰈀"; - tooltip-format = "{ifname} via {gwaddr} 󰌘"; - format-disconnected = "󰌙"; - }; - }; - }; - style = ./waybar.css; - }; - - services.kanshi = { - enable = true; - profiles = { - laptop.outputs = [ - { - criteria = "eDP-1"; - position = "0,0"; - } - ]; - dock_luhbots = { - outputs = [ - { - criteria = "eDP-1"; - position = "0,1080"; - } - { - criteria = "Dell Inc. DELL U2422HE GRCPH83"; - position = "0,0"; - } - { - criteria = "NEC Corporation E243WMi 7X313185NB"; - transform = "90"; - position = "1920,0"; - } - ]; - exec = [ - "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-4" - "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-5" - "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-4" - ]; - }; - dock_luhbots2 = { - outputs = [ - { - criteria = "eDP-1"; - position = "1080,1080"; - } - { - criteria = "Dell Inc. DELL U2422HE 8YCPH83"; - position = "1080,0"; - } - { - criteria = "NEC Corporation E243WMi 59118576NB"; - transform = "90"; - position = "0,0"; - } - ]; - exec = [ - "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-4" - "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-5" - "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-4" - ]; - }; - dock_luhbots3 = { - outputs = [ - { - criteria = "eDP-1"; - position = "0,1080"; - } - { - criteria = "Dell Inc. DELL U2422HE 53DCH83"; - position = "0,0"; - } - { - criteria = "Dell Inc. DELL U2412M 0FFXD46I4U5S"; - transform = "90"; - position = "1920,0"; - } - ]; - exec = [ - "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-6" - "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-7" - "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-6" - ]; - }; - dock_luhbots4 = { - outputs = [ - { - criteria = "eDP-1"; - position = "1080,1080"; - } - { - criteria = "Dell Inc. DELL P2422HE 4BXL9M3"; - position = "1080,0"; - } - { - criteria = "NEC Corporation E243WMi 75309334NB"; - transform = "90"; - position = "0,0"; - } - ]; - exec = [ - "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-3" - "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-4" - "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-3" - ]; - }; - laptop_hannspree = { - outputs = [ - { - criteria = "eDP-1"; - position = "320,1440"; - } - { - criteria = "HannStar Display Corp HC281UPB "; - position = "0,0"; - mode = "3840x2160@60"; - scale = 1.5; - } - ]; - exec = [ - "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to HDMI-A-1" - "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" - "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to HDMI-A-1" - ]; - }; - }; - }; - # Theming gtk = { enable = true; diff --git a/modules/home/sway/kanshi.nix b/modules/home/sway/kanshi.nix new file mode 100644 index 0000000..d1dedaa --- /dev/null +++ b/modules/home/sway/kanshi.nix @@ -0,0 +1,144 @@ +{ + lib, + config, + pkgs, + ... +}: let + cfg = config.kanshi; +in { + options = { + kanshi.enable = lib.mkEnableOption "kanshi, a dynamic display recognizer"; + kanshi.laptop = lib.mkEnableOption "laptop workspaces"; + }; + + config = lib.mkIf cfg.enable { + services.kanshi = { + enable = true; + profiles = lib.mkIf cfg.laptop { + laptop.outputs = [ + { + criteria = "eDP-1"; + position = "0,0"; + } + ]; + dock_luhbots = { + outputs = [ + { + criteria = "eDP-1"; + position = "0,1080"; + } + { + criteria = "Dell Inc. DELL U2422HE GRCPH83"; + position = "0,0"; + } + { + criteria = "NEC Corporation E243WMi 7X313185NB"; + transform = "90"; + position = "1920,0"; + } + ]; + exec = [ + "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-4" + "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-5" + "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-4" + ]; + }; + dock_luhbots2 = { + outputs = [ + { + criteria = "eDP-1"; + position = "1080,1080"; + } + { + criteria = "Dell Inc. DELL U2422HE 8YCPH83"; + position = "1080,0"; + } + { + criteria = "NEC Corporation E243WMi 59118576NB"; + transform = "90"; + position = "0,0"; + } + ]; + exec = [ + "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-4" + "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-5" + "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-4" + ]; + }; + dock_luhbots3 = { + outputs = [ + { + criteria = "eDP-1"; + position = "0,1080"; + } + { + criteria = "Dell Inc. DELL U2422HE 53DCH83"; + position = "0,0"; + } + { + criteria = "Dell Inc. DELL U2412M 0FFXD46I4U5S"; + transform = "90"; + position = "1920,0"; + } + ]; + exec = [ + "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-6" + "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-7" + "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-6" + ]; + }; + dock_luhbots4 = { + outputs = [ + { + criteria = "eDP-1"; + position = "1080,1080"; + } + { + criteria = "Dell Inc. DELL P2422HE 4BXL9M3"; + position = "1080,0"; + } + { + criteria = "NEC Corporation E243WMi 75309334NB"; + transform = "90"; + position = "0,0"; + } + ]; + exec = [ + "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to DP-3" + "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to DP-4" + "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to DP-3" + ]; + }; + laptop_hannspree = { + outputs = [ + { + criteria = "eDP-1"; + position = "320,1440"; + } + { + criteria = "HannStar Display Corp HC281UPB "; + position = "0,0"; + mode = "3840x2160@60"; + scale = 1.5; + } + ]; + exec = [ + "${pkgs.sway}/bin/swaymsg workspace 1, move workspace to HDMI-A-1" + "${pkgs.sway}/bin/swaymsg workspace 2, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 3, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 4, move workspace to eDP-1" + "${pkgs.sway}/bin/swaymsg workspace 5, move workspace to HDMI-A-1" + ]; + }; + }; + }; + }; +} diff --git a/modules/home/sway/waybar.css b/modules/home/sway/waybar.css index 25fc565..45f273a 100644 --- a/modules/home/sway/waybar.css +++ b/modules/home/sway/waybar.css @@ -32,46 +32,12 @@ window#waybar { padding-right: 3px; } -#tray { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 3px; - padding-right: 3px; -} - -#custom-squeekboard { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 10px; - padding-right: 10px; -} - -#language { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 3px; - padding-right: 3px; -} - -#clock { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 3px; - padding-right: 3px; -} - -#backlight { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 3px; - padding-right: 3px; -} - +#tray +#custom-squeekboard +#language +#network +#backlight +#clock #battery { border-width: 1px; border-style: none none none solid; @@ -80,10 +46,10 @@ window#waybar { padding-right: 3px; } -#network { - border-width: 1px; - border-style: none none none solid; - border-color: #444444; - padding-left: 3px; - padding-right: 3px; +#battery.warning { + background-color: #ffd760 +} + +#battery.critical { + background-color: #ff4040 } diff --git a/modules/home/sway/waybar.nix b/modules/home/sway/waybar.nix new file mode 100644 index 0000000..6f442ee --- /dev/null +++ b/modules/home/sway/waybar.nix @@ -0,0 +1,142 @@ +{ + lib, + config, + pkgs, + ... +}: let + cfg = config.waybar; + + schema = "org.gnome.desktop.a11y.applications"; + key = "screen-keyboard-enabled"; + + squeekboard_toggle = pkgs.writeShellScriptBin "squeekboard_toggle" '' + if [ "$(gsettings get ${schema} ${key})" == "true" ]; then + gsettings set ${schema} ${key} false + else + gsettings set ${schema} ${key} true + fi + ''; + + squeekboard_format = pkgs.writeShellScriptBin "squeekboard_format" '' + if [ "$(gsettings get ${schema} ${key})" == "true" ]; then + echo '{ "text": "󰌌", "tooltip": "enabled", "percentage": 100 }' + else + echo '{ "text": "󰌐", "tooltip": "disabled", "percentage": 0 }' + fi + ''; +in { + options = { + waybar.enable = lib.mkEnableOption "waybar, a status bar for wayland compositors"; + waybar.squeekboard = lib.mkEnableOption "squeekboard"; + waybar.mpd = lib.mkEnableOption "mpd"; + waybar.battery = lib.mkEnableOption "battery"; + waybar.backlight = lib.mkEnableOption "backlight"; + }; + + config = lib.mkIf cfg.enable { + wayland.windowManager.sway.config.startup = [{command = "${pkgs.waybar}/bin/waybar";}]; + programs.waybar = { + enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + height = 26; + modules-left = ["sway/workspaces" "sway/mode"]; + modules-center = ["sway/window"]; + modules-right = ["mpd" "tray" "custom/squeekboard" "sway/language" "clock" "backlight" "battery" "network"]; + + "sway/workspaces" = { + disable-scroll = true; + all-outputs = false; + format = "{icon} {name}"; + format-icons = { + "main" = "󰈹"; + "term" = ""; + "msg" = "󰷹"; + "music" = "󰫔"; + "urgent" = ""; + "focused" = ""; + "default" = ""; + }; + }; + + "mpd" = lib.mkIf cfg.mpd { + format = "{stateIcon}{consumeIcon}{randomIcon}{repeatIcon}{singleIcon} {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) {volume}"; + format-stopped = "{stateIcon}{randomIcon}{repeatIcon}{singleIcon} Stopped {volume}"; + format-disconnected = ""; + unkown-tag = "N/A"; + interval = 2; + consume-icons = { + on = "󰮯 "; + off = ""; + }; + random-icons = { + on = "󰒟 "; + off = "󰒞 "; + }; + repeat-icons = { + on = "󰑖 "; + off = "󰑗 "; + }; + single-icons = { + on = "󰑘 "; + off = ""; + }; + state-icons = { + paused = "󰏤 "; + playing = "󰐊 "; + }; + max-length = 50; + }; + + "tray" = { + spacing = 10; + }; + + "custom/squeekboard" = lib.mkIf cfg.squeekboard { + format = "{}"; + exec = "${squeekboard_format}/bin/squeekboard_format"; + return-type = "json"; + exec-on-event = true; + interval = 2; + on-click = "${squeekboard_toggle}/bin/squeekboard_toggle"; + }; + + "sway/language" = { + format = "{shortDescription}"; + tooltip = false; + }; + + "clock" = { + interval = 60; + format = "{:%a %d.%m %H:%M}"; + }; + + "backlight" = lib.mkIf cfg.backlight { + format = "{percent}% {icon}"; + format-icons = ["󰹐" "󱩎" "󱩏" "󱩐" "󱩑" "󱩒" "󱩓" "󱩔" "󱩕" "󱩖" "󰛨"]; + }; + + "battery" = lib.mkIf cfg.battery { + format = "{capacity}% {icon}"; + format-charging = "{capacity}% {icon}󱐋"; + format-icons = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; + states = { + warning = 30; + critical = 15; + }; + }; + + "network" = { + format-wifi = "{essid} ({signalStrength}%) 󰖩"; + format-ethernet = "{ipaddr}/{cidr} 󰈀"; + tooltip-format = "{ifname} via {gwaddr} 󰌘"; + format-disconnected = "󰌙"; + }; + }; + }; + style = ./waybar.css; + }; + }; +}