From 3389e89ec7b6f42ac4a1a6ddeb47fc5a1628c3bb Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Mon, 9 Mar 2026 20:26:17 +0530 Subject: Some minor code refactoring --- modules/desktop/bspwm/default.nix | 6 +++--- modules/desktop/polybar/bar/main.nix | 16 +++++++--------- modules/desktop/polybar/module/battery.nix | 10 +++++----- modules/desktop/polybar/module/bspwm.nix | 8 ++++---- modules/desktop/polybar/module/ethernet-separator.nix | 4 ++-- modules/desktop/polybar/module/ethernet.nix | 4 ++-- modules/desktop/polybar/module/wifi-separator.nix | 4 ++-- modules/desktop/polybar/module/wifi.nix | 6 +++--- modules/desktop/polybar/module/xwindow.nix | 1 - modules/desktop/sxhkd/default.nix | 8 ++++---- modules/desktop/sxhkd/keybindings/brightnessctl.nix | 2 +- modules/desktop/sxhkd/keybindings/bspwm.nix | 10 +++++----- modules/desktop/sxhkd/keybindings/maim.nix | 2 +- modules/desktop/sxhkd/keybindings/pamixer.nix | 4 ++-- modules/desktop/sxhkd/scripts/keybindings.sh | 7 +++---- 15 files changed, 44 insertions(+), 48 deletions(-) (limited to 'modules/desktop') diff --git a/modules/desktop/bspwm/default.nix b/modules/desktop/bspwm/default.nix index 2dc3f91..6b6acef 100644 --- a/modules/desktop/bspwm/default.nix +++ b/modules/desktop/bspwm/default.nix @@ -3,7 +3,7 @@ { config = lib.mkIf config.desktop.enable { xsession.windowManager.bspwm.enable = true; - + xsession.windowManager.bspwm.settings = with config.scheme.withHashtag; { window_gap = 10; split_ratio = 0.5; @@ -21,7 +21,7 @@ active_border_color = base02; focused_border_color = base03; }; - + xsession.windowManager.bspwm.rules = { "floating-termial" = { state = "floating"; @@ -31,7 +31,7 @@ follow = true; }; }; - + xsession.windowManager.bspwm.extraConfig = '' for monitor in $(xrandr -q | grep -w 'connected' | cut -d' ' -f1); do bspc monitor "$monitor" -d '1' '2' '3' '4' '5' '6' diff --git a/modules/desktop/polybar/bar/main.nix b/modules/desktop/polybar/bar/main.nix index 49c3b84..0f38ae4 100644 --- a/modules/desktop/polybar/bar/main.nix +++ b/modules/desktop/polybar/bar/main.nix @@ -10,31 +10,29 @@ in { override-redirect = false; wm-restack = "bspwm"; enable-ipc = true; - + border-top-size = 1; border-bottom-size = 1; border-left-size = 1; border-right-size = 1; border-color = base03; - + background = base00; foreground = base05; - + line-size = 3; line-color = base08; - + padding-left = 1; padding-right = 1; - - # separator = "%{F${base03}}%{T3}│%{T-}%{F-}"; - + offset-x = "10"; offset-y = "10"; - + font-0 = "${config.fonts.normal}:pixelsize=${toString config.fonts.size};3"; font-1 = "${config.fonts.normal}:weight=Bold:pixelsize=${largerFontSize};3"; font-2 = "${config.fonts.normal}:style=Light:pixelsize=${largerFontSize};2"; - + modules-left = "bspwm separator"; modules-center = "xwindow"; modules-right = "separator volume separator battery separator wifi wifi-separator ethernet ethernet-separator time separator memory separator cpu separator date"; diff --git a/modules/desktop/polybar/module/battery.nix b/modules/desktop/polybar/module/battery.nix index f2a10c8..cdf3b86 100644 --- a/modules/desktop/polybar/module/battery.nix +++ b/modules/desktop/polybar/module/battery.nix @@ -5,15 +5,15 @@ with config.scheme.withHashtag; type = "internal/battery"; battery = "BAT1"; adapter = "ADP1"; - + low-at = 0; format-charging = "%{T2}%{F${base03}}%{F-}%{T-} "; format-discharging = "%{T2}%{F${base03}}%{F-}%{T-} "; format-full-prefix = "󰁹 "; - + label-charging = "%percentage:3%%"; label-discharging = "%percentage:3%%"; - + ramp-capacity-0 = "󰁺"; ramp-capacity-1 = "󰁻"; ramp-capacity-2 = "󰁼"; @@ -24,7 +24,7 @@ with config.scheme.withHashtag; ramp-capacity-7 = "󰂁"; ramp-capacity-8 = "󰂂"; ramp-capacity-9 = "󰁹"; - + animation-charging-0 = "󰁺"; animation-charging-1 = "󰁻"; animation-charging-2 = "󰁼"; @@ -35,6 +35,6 @@ with config.scheme.withHashtag; animation-charging-7 = "󰂁"; animation-charging-8 = "󰂂"; animation-charging-9 = "󰁹"; - + animation-charging-framerate = 750; } diff --git a/modules/desktop/polybar/module/bspwm.nix b/modules/desktop/polybar/module/bspwm.nix index 383de8f..3c8f64a 100644 --- a/modules/desktop/polybar/module/bspwm.nix +++ b/modules/desktop/polybar/module/bspwm.nix @@ -3,18 +3,18 @@ with config.scheme.withHashtag; { type = "internal/bspwm"; - + label-focused = "%index%"; label-focused-underline = "${base0D}"; label-focused-padding = 1; - + label-occupied = "%index%"; label-occupied-padding = 1; - + label-urgent = "%index%"; label-urgent-underline = "${base08}"; label-urgent-padding = 1; - + label-empty = "%index%"; label-empty-foreground = "${base03}"; label-empty-padding = 1; diff --git a/modules/desktop/polybar/module/ethernet-separator.nix b/modules/desktop/polybar/module/ethernet-separator.nix index 87df6f3..c2fefaa 100644 --- a/modules/desktop/polybar/module/ethernet-separator.nix +++ b/modules/desktop/polybar/module/ethernet-separator.nix @@ -5,10 +5,10 @@ with config.scheme.withHashtag; type = "internal/network"; interface = "enp4s0"; interface-type = "wired"; - + format-connected = " %{F${base03}}%{T3}│%{T-}%{F-} "; format-disconnected = ""; - + label-connected = ""; label-disconnected = ""; } diff --git a/modules/desktop/polybar/module/ethernet.nix b/modules/desktop/polybar/module/ethernet.nix index 9073c79..3e2b48d 100644 --- a/modules/desktop/polybar/module/ethernet.nix +++ b/modules/desktop/polybar/module/ethernet.nix @@ -5,10 +5,10 @@ with config.scheme.withHashtag; type = "internal/network"; interface = "enp4s0"; interface-type = "wired"; - + format-connected = "%{T2}%{F${base03}}%{F-}%{T-} "; format-disconnected = ""; - + label-connected = "%netspeed:8%"; label-disconnected = ""; } diff --git a/modules/desktop/polybar/module/wifi-separator.nix b/modules/desktop/polybar/module/wifi-separator.nix index 4237d84..6b8da50 100644 --- a/modules/desktop/polybar/module/wifi-separator.nix +++ b/modules/desktop/polybar/module/wifi-separator.nix @@ -5,10 +5,10 @@ with config.scheme.withHashtag; type = "internal/network"; interface = "wlan0"; interface-type = "wireless"; - + format-connected = " %{F${base03}}%{T3}│%{T-}%{F-} "; format-disconnected = ""; - + label-connected = ""; label-disconnected = ""; } diff --git a/modules/desktop/polybar/module/wifi.nix b/modules/desktop/polybar/module/wifi.nix index f244054..9f25fa2 100644 --- a/modules/desktop/polybar/module/wifi.nix +++ b/modules/desktop/polybar/module/wifi.nix @@ -5,13 +5,13 @@ with config.scheme.withHashtag; type = "internal/network"; interface = "wlan0"; interface-type = "wireless"; - + format-connected = "%{T2}%{F${base03}}%{F-}%{T-} "; format-disconnected = ""; - + label-connected = "%netspeed:8%"; label-disconnected = ""; - + ramp-signal-0 = "󰢼"; ramp-signal-1 = "󰢼"; ramp-signal-2 = "󰢽"; diff --git a/modules/desktop/polybar/module/xwindow.nix b/modules/desktop/polybar/module/xwindow.nix index f0614d1..386efe2 100644 --- a/modules/desktop/polybar/module/xwindow.nix +++ b/modules/desktop/polybar/module/xwindow.nix @@ -1,6 +1,5 @@ { config }: -with config.scheme.withHashtag; { type = "internal/xwindow"; label = "%title:0:20:...%"; diff --git a/modules/desktop/sxhkd/default.nix b/modules/desktop/sxhkd/default.nix index 98338c2..3102efe 100644 --- a/modules/desktop/sxhkd/default.nix +++ b/modules/desktop/sxhkd/default.nix @@ -16,23 +16,23 @@ (import ./keybindings/maim.nix { inherit pkgs createKeybinding lib; }) (import ./keybindings/pamixer.nix { inherit pkgs createKeybindingBase lib; }) (import ./keybindings/playerctl.nix { inherit pkgs createKeybindingBase lib; }) - + (createKeybinding "s" "Show keybindings." "kitty --title 'Keybindings' --class floating-termial -e ${pkgs.writeShellScript "keybindings.sh" (builtins.readFile ./scripts/keybindings.sh)}" ) - + (createKeybinding "r" "Application launcher." "rofi -show drun") - + (createKeybinding "t" "Launch terminal." "kitty") - + (createKeybinding "f" "Launch File Manager." diff --git a/modules/desktop/sxhkd/keybindings/brightnessctl.nix b/modules/desktop/sxhkd/keybindings/brightnessctl.nix index acb4ea2..6cdf3e7 100644 --- a/modules/desktop/sxhkd/keybindings/brightnessctl.nix +++ b/modules/desktop/sxhkd/keybindings/brightnessctl.nix @@ -7,7 +7,7 @@ in lib.mkMerge [ "XF86MonBrightnessDown" "Decrease brightness." "${brightnessctl} set 5%-") - + (createKeybindingBase "XF86MonBrightnessUp" "Increase brightness." diff --git a/modules/desktop/sxhkd/keybindings/bspwm.nix b/modules/desktop/sxhkd/keybindings/bspwm.nix index ed62ed4..ffa7d6c 100644 --- a/modules/desktop/sxhkd/keybindings/bspwm.nix +++ b/modules/desktop/sxhkd/keybindings/bspwm.nix @@ -7,27 +7,27 @@ in lib.mkMerge [ "q" "Kill current window." "${bspc} node -c") - + (createKeybinding "{1-9,0}" "Switch workspace." "${bspc} desktop -f {1-9,10}") - + (createKeybinding "shift + {1-9,0}" "Move window to workspace." "${bspc} node -d {1-9,10} --follow") - + (createKeybinding "{n,d,m}" "Set current window mode (tiled, floating, fullscreen)." "${bspc} node focused -t {tiled,floating,fullscreen}") - + (createKeybinding "{_,shift + }{h,j,k,l}" "Navigate between windows." "${bspc} node --{focus,swap} {west,south,north,east}") - + # the indentation for each line is required to work with the help prompt (createKeybinding "ctrl + {h,j,k,l}" diff --git a/modules/desktop/sxhkd/keybindings/maim.nix b/modules/desktop/sxhkd/keybindings/maim.nix index 7b748da..b66ec98 100644 --- a/modules/desktop/sxhkd/keybindings/maim.nix +++ b/modules/desktop/sxhkd/keybindings/maim.nix @@ -7,7 +7,7 @@ in lib.mkMerge [ "p" "Take screenshot of selected area and save to clipboard" "${maim} -s | xclip -selection clipboard -t image/png") - + (createKeybinding "shift + p" "Take screenshot of selected area and save to ~/Pictures/Screenshots" diff --git a/modules/desktop/sxhkd/keybindings/pamixer.nix b/modules/desktop/sxhkd/keybindings/pamixer.nix index 3543d8f..a45bf83 100644 --- a/modules/desktop/sxhkd/keybindings/pamixer.nix +++ b/modules/desktop/sxhkd/keybindings/pamixer.nix @@ -7,12 +7,12 @@ in lib.mkMerge [ "XF86AudioLowerVolume" "Decrease volume." "${pamixer} --decrease 5") - + (createKeybindingBase "XF86AudioRaiseVolume" "Increase volume." "${pamixer} --increase 5") - + (createKeybindingBase "XF86AudioMute" "Mute audio." diff --git a/modules/desktop/sxhkd/scripts/keybindings.sh b/modules/desktop/sxhkd/scripts/keybindings.sh index 01bb05f..1548f1c 100755 --- a/modules/desktop/sxhkd/scripts/keybindings.sh +++ b/modules/desktop/sxhkd/scripts/keybindings.sh @@ -36,13 +36,12 @@ border_line="├$(printf '%.0s─' $(seq 1 $max_keybinding_length))┼$(printf ' # Print table header with borders echo "┌$(printf '%.0s─' $(seq 1 $max_keybinding_length))┬$(printf '%.0s─' $(seq 1 $description_width))┐" printf "│ %-*s │ %-*s │\n" "$max_keybinding_content_length" "KEYBINDING" "$description_content_width" "DESCRIPTION" - - # Initialize variables + description="" - + # Load the sxhkd file into an array mapfile -t lines < "$SXHKD_FILE" - + # Loop through lines for output for line in "${lines[@]}"; do # Check if the line is a comment -- cgit v1.2.3