diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-18 23:26:17 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-18 23:26:17 +0530 |
| commit | 6b0161b2639bb49e270754e90f4f8a47311c5198 (patch) | |
| tree | fc0f4a138b311061daad5ddeb6ed50314f1f5a1a /modules/desktop | |
| parent | 53eac37422f77750adbc801f71b85ab04cf2b7f9 (diff) | |
| download | home-manager-config-6b0161b2639bb49e270754e90f4f8a47311c5198.tar.gz home-manager-config-6b0161b2639bb49e270754e90f4f8a47311c5198.zip | |
chore: projectwide refactoring
- Using more consistent naming conventions across the project. Using java style super
descriptive variable names.
- Removed slop comments in favor of using more descriptive naming conventions.
Diffstat (limited to 'modules/desktop')
| -rw-r--r-- | modules/desktop/eww/bar/bar.nix | 20 | ||||
| -rw-r--r-- | modules/desktop/eww/bar/bar.yuck | 109 | ||||
| -rw-r--r-- | modules/desktop/eww/bar/system-stats.lua | 25 | ||||
| -rw-r--r-- | modules/desktop/eww/default.nix | 56 | ||||
| -rw-r--r-- | modules/desktop/niri/default.nix | 10 | ||||
| -rw-r--r-- | modules/desktop/rofi/default.nix | 13 | ||||
| -rw-r--r-- | modules/desktop/xdg/default.nix | 19 |
7 files changed, 161 insertions, 91 deletions
diff --git a/modules/desktop/eww/bar/bar.nix b/modules/desktop/eww/bar/bar.nix index 70bfbac..252811f 100644 --- a/modules/desktop/eww/bar/bar.nix +++ b/modules/desktop/eww/bar/bar.nix @@ -63,12 +63,10 @@ name = "eww-system-stats"; path = ./system-stats.lua; description = "Emit {cpu, ram, net} as JSON."; - luaPackages = ( - ps: [ - ps.lua-cjson - ps.luaposix - ] - ); + luaPackages = ps: [ + ps.lua-cjson + ps.luaposix + ]; deps = [ pkgs.iw pkgs.iproute2 @@ -82,12 +80,10 @@ name = "niri-status"; path = ./niri-status.lua; description = "Emit workspace and active window information list."; - luaPackages = ( - ps: [ - ps.lgi - ps.lua-cjson - ] - ); + luaPackages = ps: [ + ps.lgi + ps.lua-cjson + ]; deps = [ config.desktop.niri.package ]; gobjectIntrospection = true; }; diff --git a/modules/desktop/eww/bar/bar.yuck b/modules/desktop/eww/bar/bar.yuck index f8f48d0..dc2d575 100644 --- a/modules/desktop/eww/bar/bar.yuck +++ b/modules/desktop/eww/bar/bar.yuck @@ -29,61 +29,122 @@ (system-widget))) (defwidget workspaces-widget [workspaces] - (box :orientation "v" :space-evenly false :spacing 4 :halign "fill" :class "workspaces" + (box :orientation "v" + :space-evenly false + :spacing 4 + :halign "fill" + :class "workspaces" (for ws in workspaces (eventbox :onclick "niri msg action focus-workspace ${ws.idx}" - :cursor "pointer" :halign "fill" + :cursor "pointer" + :halign "fill" :tooltip "${ws.tooltip}" - (box :class "workspace-button ${ws.is_active ? 'active' : ''}" :halign "fill" + (box :class "workspace-button ${ws.is_active ? 'active' : ''}" + :halign "fill" (overlay :halign "fill" (image :class "workspace-icon" :path "${ws.icon}" - :image-width 20 :image-height 20) - (label :class "workspace-idx" :text "${ws.idx}" :halign "end" :valign "end"))))))) + :image-width 20 + :image-height 20) + (label :class "workspace-idx" + :text "${ws.idx}" + :halign "end" + :valign "end"))))))) (defwidget windows-widget [windows] - (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "windows" :vexpand true + (box :orientation "v" + :space-evenly false + :spacing 4 + :halign "center" + :class "windows" + :vexpand true (for w in windows (eventbox :onclick "niri msg action focus-window --id ${w.id}" :cursor "pointer" :halign "fill" :tooltip "${w.app_id}: ${w.title != '' ? ' ' : ''}${w.title}" - (box :halign "fill" :class "window-button ${w.is_focused ? 'focused' : ''}" - (image :class "window-icon" :path "${w.icon}" :image-width 20 :image-height 20)))))) + (box :halign "fill" + :class "window-button ${w.is_focused ? 'focused' : ''}" + (image :class "window-icon" + :path "${w.icon}" + :image-width 20 + :image-height 20)))))) (defwidget system-widget [] - (box :orientation "v" :space-evenly false :spacing 6 :halign "fill" :class "system" - (box :orientation "v" :class "system-item" :halign "fill" :space-evenly false :spacing 4 + (box :orientation "v" + :space-evenly false + :spacing 6 + :halign "fill" + :class "system" + (box :orientation "v" + :class "system-item" + :halign "fill" + :space-evenly false + :spacing 4 :tooltip "${system_stats.net.tooltip}" (image :class "system-icon" :path "${system_stats.net.status == 'down' ? '@@icon-offline@@' : system_stats.net.routes[0].type == 'wifi' ? '@@icon-wifi@@' : system_stats.net.routes[0].type == 'ethernet' ? '@@icon-ethernet@@' : system_stats.net.routes[0].type == 'tun' ? '@@icon-proxy@@' : '@@icon-offline@@'}" - :image-width 24 :image-height 24) + :image-width 24 + :image-height 24) (label :class "system-label small" :text "${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].tx}") (label :class "system-label small" :text "${system_stats.net.status == 'down' ? '-' : system_stats.net.routes[0].rx}")) - (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (box :orientation "v" + :class "system-item" + :space-evenly false + :spacing 4 :tooltip "${system_stats.cpu.tooltip}" - (image :class "system-icon" :path "@@icon-cpu@@" :image-width 24 :image-height 24) + (image :class "system-icon" + :path "@@icon-cpu@@" + :image-width 24 + :image-height 24) (label :class "system-label" :text "${system_stats.cpu.percent}%")) - (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (box :orientation "v" + :class "system-item" + :space-evenly false + :spacing 4 :tooltip "${system_stats.ram.tooltip}" - (image :class "system-icon" :path "@@icon-ram@@" :image-width 24 :image-height 24) + (image :class "system-icon" + :path "@@icon-ram@@" + :image-width 24 + :image-height 24) (label :class "system-label" :text "${system_stats.ram.percent}%")) - (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (box :orientation "v" + :class "system-item" + :space-evenly false + :spacing 4 :tooltip "${system_stats.battery.tooltip}" - (image :class "system-icon" :path "@@icon-battery@@" :image-width 24 :image-height 24) - (label :class "system-label" :text "${system_stats.battery.present ? (system_stats.battery.percent + '%') : '-'}")) + (image :class "system-icon" + :path "@@icon-battery@@" + :image-width 24 + :image-height 24) + (label :class "system-label" + :text "${system_stats.battery.present ? (system_stats.battery.percent + '%') : '-'}")) (eventbox :onclick "pamixer --toggle-mute" :onscroll "bash -c '[ \"{}\" = \"up\" ] && pamixer --increase 5 --unmute || pamixer --decrease 5'" - :cursor "pointer" :halign "fill" - (box :orientation "v" :space-evenly false :spacing 4 :class "system-item" + :cursor "pointer" + :halign "fill" + (box :orientation "v" + :space-evenly false + :spacing 4 + :class "system-item" :tooltip "${system_stats.sound.tooltip}" - (image :class "system-icon" :path "@@icon-audio@@" :image-width 24 :image-height 24) - (label :class "system-label" :text "${system_stats.sound.mute ? '-' : (system_stats.sound.percent + '%')}"))) - (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (image :class "system-icon" + :path "@@icon-audio@@" + :image-width 24 + :image-height 24) + (label :class "system-label" + :text "${system_stats.sound.mute ? '-' : (system_stats.sound.percent + '%')}"))) + (box :orientation "v" + :class "system-item" + :space-evenly false + :spacing 4 :tooltip "${full_date} ${time} (${date})" - (image :class "system-icon" :path "@@icon-calendar@@" :image-width 24 :image-height 24) + (image :class "system-icon" + :path "@@icon-calendar@@" + :image-width 24 + :image-height 24) (label :class "system-label small" :text time) (label :class "system-label small" :text ampm) (label :class "system-label small" :text date)))) diff --git a/modules/desktop/eww/bar/system-stats.lua b/modules/desktop/eww/bar/system-stats.lua index bc9cc90..9571d26 100644 --- a/modules/desktop/eww/bar/system-stats.lua +++ b/modules/desktop/eww/bar/system-stats.lua @@ -4,6 +4,7 @@ -- Single-threaded LuaJIT port of the original Python script. Instead of -- OS threads, a single supervisor loop schedules the periodic cpu/ram and -- sound refreshes and polls an inotifywait child for link-state changes. + local cjson = require("cjson") local posix = require("posix") local unistd = require("posix.unistd") @@ -23,13 +24,13 @@ end local net_last_time = nil local net_last_bytes = {} --- ------------------------------------------------ time +-- TIME local function mono_sec() local g = gettimeofday() return g.tv_sec + g.tv_usec / 1e6 end --- ------------------------------------------------ process helpers +-- PROCESS HELPERS local function sh(cmd) local h = io.popen(cmd) if not h then @@ -40,7 +41,7 @@ local function sh(cmd) return out end --- ------------------------------------------------ formatting +-- FORMATTING local function format_rate(bytes_per_sec) if bytes_per_sec == nil or bytes_per_sec < 0 then return "0B" @@ -77,7 +78,7 @@ local function format_bytes(kib) return string.format("%.1f%s", val, unit) end --- ------------------------------------------------ /proc readers +-- /proc READERS local function read_cpu_times() local times = {} local f = io.open("/proc/stat") @@ -192,7 +193,7 @@ local function get_ram_speed_mhz() return mx end --- ------------------------------------------------ network helpers +-- NETWORK HELPERS local function get_all_default_ifaces() local out = sh("ip -o route show default 2>/dev/null") if not out then @@ -305,7 +306,7 @@ local function get_iface_io_bytes(iface) return rx, tx end --- ------------------------------------------------ tooltips +-- TOOLTIPS local function build_cpu_tooltip(overall_pct, per_core_list, freq_mhz, load_avg) local lines = { string.format("CPU: %d%%", overall_pct) } if freq_mhz ~= nil then @@ -337,7 +338,7 @@ local function build_ram_tooltip(ram_pct, used, total, available, swap_pct, swap return table.concat(lines, "\n") end --- ------------------------------------------------ state collectors +-- STATE COLLECTORS -- get_all_default_ifaces (`ip route`), get_iface_ip (`ip addr`), and the -- wifi branch of get_speed_mbps (`iw dev link`) each spawn a subprocess. -- Those three rarely change second-to-second, so they're only re-probed @@ -530,7 +531,7 @@ local function get_sound_state() } end --- ------------------------------------------------ battery +-- BATTERY local function find_battery_path() local handle = io.popen("ls /sys/class/power_supply/ 2>/dev/null") if not handle then @@ -608,7 +609,7 @@ end local battery_path = find_battery_path() --- ------------------------------------------------ state + emit +-- state + emit local state = { cpu = { percent = 0, @@ -657,7 +658,7 @@ local CPU_INTERVAL = 2.0 local SOUND_INTERVAL = 1.0 local INOTIFY_RETRY_INTERVAL = 30.0 -- backoff between (re)spawn attempts --- ------------------------------------------------ inotifywait child +-- inotifywait child -- Returns pid, read_fd on success, or nil, nil if the fork/exec setup -- itself failed outright (pipe/fork syscall failure, not inotifywait -- failing later). @@ -694,7 +695,7 @@ local function spawn_inotify() return pid, r end --- ------------------------------------------------ main loop +-- MAIN LOOP local function main() local ram_speed_mhz = get_ram_speed_mhz() @@ -878,7 +879,7 @@ local function main() -- Empty read on a "ready" fd means the write end closed, i.e. -- the inotifywait child exited (crashed, watched path missing, -- binary not found, etc). Reap it, drop the fd, and don't - -- touch it again until the next backed-off retry -- this is + -- touch it again until the next backed-off retry; this is -- the fix for the tight busy-loop: without this branch, poll() -- would report this dead fd as "ready" forever, on every -- single iteration, with an effectively-zero timeout. diff --git a/modules/desktop/eww/default.nix b/modules/desktop/eww/default.nix index dfc80cd..be6236f 100644 --- a/modules/desktop/eww/default.nix +++ b/modules/desktop/eww/default.nix @@ -1,8 +1,13 @@ +# ElKowar's Wacky Widgets — desktop widgets and bar { config, lib, + pkgs, ... }: +let + base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; +in { imports = [ ./bar/bar.nix @@ -22,38 +27,35 @@ enable = true; systemd = { enable = true; - # Nothing ever activates this, so home-manager's eww.service unit - # exists but is never auto-started by the session. Rely on eww-bar.service - # manually starts eww service. + # Nothing auto-starts home-manager's eww.service unit; the eww-bar + # service below starts the daemon on demand. target = "eww-daemon-manual.target"; }; scssConfig = let - baseSize = config.fonts.size; + themedStyleSheet = + builtins.replaceStrings + [ + "@@font-family@@" + "@@font-size@@" + "@@font-size-icon@@" + "@@font-size-label@@" + "@@font-size-small@@" + "@@font-size-idx@@" + ] + [ + config.fonts.normal + (toString config.fonts.size) + (toString config.fonts.iconSize) + (toString config.fonts.labelSize) + (toString config.fonts.smallSize) + (toString config.fonts.idxSize) + ] + (builtins.readFile ./eww.scss); in - builtins.readFile ( - config.scheme { - template = - builtins.replaceStrings - [ - "@@font-family@@" - "@@font-size@@" - "@@font-size-icon@@" - "@@font-size-label@@" - "@@font-size-small@@" - "@@font-size-idx@@" - ] - [ - config.fonts.normal - (toString baseSize) - (toString config.fonts.iconSize) - (toString config.fonts.labelSize) - (toString config.fonts.smallSize) - (toString config.fonts.idxSize) - ] - (builtins.readFile ./eww.scss); - } - ); + builtins.readFile (base16Colors { + templateFileOrContent = themedStyleSheet; + }); }; systemd.user.services.eww-bar = { diff --git a/modules/desktop/niri/default.nix b/modules/desktop/niri/default.nix index b13cdf4..9b0b160 100644 --- a/modules/desktop/niri/default.nix +++ b/modules/desktop/niri/default.nix @@ -1,9 +1,13 @@ +# Niri scrollable-tiling Wayland compositor and desktop essentials { config, lib, pkgs, ... }: +let + base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; +in { imports = [ ./keybindings.nix ]; @@ -64,7 +68,7 @@ x11.enable = true; }; - wayland.windowManager.niri.settings = { + wayland.windowManager.niri.settings = with base16Colors.colorsWithHashPrefix; { hotkey-overlay = { skip-at-startup = { }; }; @@ -94,8 +98,8 @@ background-color = "transparent"; focus-ring = { width = 1; - active-color = config.scheme.withHashtag.base07; - inactive-color = config.scheme.withHashtag.base03; + active-color = base07; + inactive-color = base03; }; border.off = { }; shadow.off = { }; diff --git a/modules/desktop/rofi/default.nix b/modules/desktop/rofi/default.nix index ced9167..bbf1aea 100644 --- a/modules/desktop/rofi/default.nix +++ b/modules/desktop/rofi/default.nix @@ -1,8 +1,13 @@ +# Application launcher and dmenu replacement { config, lib, + pkgs, ... }: +let + base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; +in { options.desktop.rofi = { package = lib.mkOption { @@ -18,7 +23,7 @@ enable = true; theme = let - template = + fontExpandedThemeTemplate = builtins.replaceStrings [ "@@rofi-font@@" @@ -30,9 +35,9 @@ ] (builtins.readFile ./theme.rasi); in - "${config.scheme { - inherit template; - extension = ".rasi"; + "${base16Colors { + templateFileOrContent = fontExpandedThemeTemplate; + fileExtension = ".rasi"; }}"; extraConfig = { modi = "drun"; diff --git a/modules/desktop/xdg/default.nix b/modules/desktop/xdg/default.nix index ef27182..7f46d37 100644 --- a/modules/desktop/xdg/default.nix +++ b/modules/desktop/xdg/default.nix @@ -5,6 +5,9 @@ pkgs, ... }: +let + base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; +in { config = lib.mkIf config.desktop.enable { dconf.enable = true; @@ -25,12 +28,10 @@ gtk = let - gtkCss = builtins.readFile ( - config.scheme { - template = builtins.readFile ./style.css; - extension = ".css"; - } - ); + gtkColorSchemeCss = builtins.readFile (base16Colors { + templateFileOrContent = builtins.readFile ./style.css; + fileExtension = ".css"; + }); in { enable = true; @@ -52,12 +53,12 @@ size = 20; }; colorScheme = "dark"; - gtk3.extraCss = gtkCss; + gtk3.extraCss = gtkColorSchemeCss; gtk4 = { # GTK 4/libadwaita does not support loading GTK 3 themes; use the - # OneDark Dark CSS above without Home Manager's compatibility workaround. + # themed CSS above without Home Manager's compatibility workaround. theme = null; - extraCss = gtkCss; + extraCss = gtkColorSchemeCss; }; }; }; |
