repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

hypr: replace nushell scripts with lua, update references

cb814db409217faf758fd463b4d79d171c28136f

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

hypr/AGENTS.md

Modified
11 11 - Mako: `mako/nugu.conf` via `include=~/.config/mako/nugu.conf`
12 12 - Hypr Lua: `hypr/generated/nugu.lua`
13 13 - Runtime JSON: `hypr/generated/nugu.json`
14 -- Runtime switcher `hypr/scripts/theme.nu` writes active color fragments under `$XDG_CONFIG_HOME`.
14 +- Runtime switcher `hypr/scripts/theme.lua` writes active color fragments under `$XDG_CONFIG_HOME`.
16 16 Hyprtoolkit:
17 17 - Never rewrite `hyprtoolkit.conf` while Hyprtoolkit apps run.
37 37 - UI sans: `IBM Plex Sans`; mono/status: `IBM Plex Mono`.
39 39 Testing:
40 -- After theme edits: `NUGU_NO_NOTIFY=1 hypr/scripts/theme.nu dark|light`.
40 +- After theme edits: `NUGU_NO_NOTIFY=1 hypr/scripts/theme.lua dark|light`.
41 41 - Check `systemctl --user is-active mako.service ironbar.service hyprpaper.service`.
42 42 - Screenshot dark/light with `grim`; inspect actual rendered colors, not just CSS.

hypr/lib/apps.lua

Modified
11 11 wifi = function() tui.spawn("impala") end,
12 12 lock = "hyprlock",
13 13 logout = "hyprshutdown --dry-run",
14 - theme_toggle = "nu ~/.config/hypr/scripts/theme.nu toggle",
15 - theme_auto = "nu ~/.config/hypr/scripts/theme.nu auto",
14 + theme_toggle = "lua ~/.config/hypr/scripts/theme.lua toggle",
15 + theme_auto = "lua ~/.config/hypr/scripts/theme.lua auto",
16 16 clipboard = "bash -lc 'cliphist list | hyprlauncher --dmenu | cliphist decode | wl-copy'",
17 17 screenshot_region = "hyprshot -m region -z",
18 18 screenshot_window = "hyprshot -m window -z",
19 19 screenshot_output = "hyprshot -m output -z",
20 20 screenshot_annotate = "hyprshot -m region -z -- satty --filename",
21 - binds_help = "nu ~/.config/hypr/scripts/show_binds.nu",
22 - clients_help = "nu ~/.config/hypr/scripts/show_clients.nu",
21 + binds_help = "lua ~/.config/hypr/scripts/show_binds.lua",
22 + clients_help = "lua ~/.config/hypr/scripts/show_clients.lua",

hypr/scripts/show_binds.nu

Deleted
deleted file mode 100644
1 -# Function to parse modmask into readable modifier names
2 -def parse_modmask [modmask: int] {
3 - let modifiers = [
4 - { mask: 64, name: "SUPER" },
5 - { mask: 1, name: "SHIFT" },
6 - { mask: 4, name: "CTRL" },
7 - { mask: 8, name: "ALT" }
8 - ]
9 - let active_mods = $modifiers | where { |mod| ($modmask | bits and $mod.mask) != 0 } | get name
10 - if ($active_mods | is-empty) { "None" } else { $active_mods | str join "+" }
11 -}
13 -# Function to format key for display
14 -def format_key [key: string, mouse: bool] {
15 - if $mouse {
16 - $key | str replace "mouse:" "MOUSE_"
17 - } else {
18 - $key | str upcase
19 - }
20 -}
22 -# Main function to process binds and show fuzzel menu
23 -def main [] {
24 - # Get binds from hyprctl
25 - let binds = (hyprctl binds -j | from json)
27 - # Parse binds into a formatted list for fuzzel
28 - let formatted_binds = $binds | each { |bind|
29 - let mods = (parse_modmask $bind.modmask)
30 - let key = (format_key $bind.key $bind.mouse)
31 - let display = $"($mods) + ($key) -> ($bind.dispatcher): ($bind.arg)"
32 - { display: $display, arg: $bind.arg, dispatcher: $bind.dispatcher }
33 - }
35 - # Create a temporary file for fuzzel
36 - let temp_file = (mktemp -t hypr_binds.XXXXXX | str trim)
37 - $formatted_binds | each { |b| $b.display } | str join "\n" | save -f $temp_file
39 - # Show fuzzel menu and get selection
40 - let selection = (cat $temp_file | fuzzel --dmenu --prompt "Keybindings: " | str trim)
41 - rm $temp_file
43 - # Find the selected binding and execute its arg
44 - if ($selection | is-not-empty) {
45 - let selected_bind = ($formatted_binds | where display == $selection | first)
46 - if ($selected_bind | is-not-empty) {
47 - if $selected_bind.dispatcher == "exec" {
48 - run-external ($selected_bind.arg | split row ' ')
49 - } else {
50 - hyprctl dispatch $selected_bind.dispatcher $selected_bind.arg
51 - }
52 - }
53 - }
54 -}

hypr/scripts/show_clients.nu

Deleted
deleted file mode 100644
1 -# Fetch and parse hyprctl clients JSON
2 -let clients = (hyprctl clients -j | from json)
4 -# Format clients for fuzzel: "class: title (workspace)"
5 -let formatted = ($clients | each { |client|
6 - $"($client.class): ($client.title) \(($client.workspace.name)\)"
7 -} | str join "\n")
9 -# Pipe formatted list to fuzzel and get selected item
10 -let selected = ($formatted | fuzzel --dmenu --prompt "Select window: " | str trim)
12 -# Exit if no selection
13 -if ($selected | is-empty) {
14 - exit 0
15 -}
17 -# Find the index of the selected item
18 -let selected_index = ($formatted | split row "\n" | enumerate | where item == $selected | get 0.index)
20 -# Get the address of the selected client
21 -let address = ($clients | get $selected_index | get address)
23 -# Focus the selected window
24 -hyprctl -q dispatch focuswindow address:($address)
25 -hyprctl -q dispatch alterzorder top

hypr/scripts/theme.nu

Deleted
deleted file mode 100755
1 -#!/usr/bin/env nu
3 -# Nugu desktop theme switcher. Writes active runtime configs, then reloads clients.
5 -const modes = [dark light]
7 -def config-home [] { $env.XDG_CONFIG_HOME? | default ($env.HOME | path join ".config") }
8 -def cache-dir [] { $env.HOME | path join ".cache" "nugu" }
9 -def mode-file [] { cache-dir | path join "mode" }
10 -def auto-file [] { cache-dir | path join "auto" }
11 -def palette-file [] { config-home | path join "hypr" "generated" "nugu.json" }
13 -def active-mode [] {
14 - let path = (mode-file)
15 - if ($path | path exists) {
16 - let mode = (open --raw $path | str trim)
17 - if $mode in $modes { return $mode }
18 - }
19 - "dark"
22 -def auto-mode [] {
23 - let hour = (date now | format date "%H" | into int)
24 - if $hour >= 7 and $hour < 19 { "light" } else { "dark" }
27 -def hex-no-hash [color: string] { $color | str replace --all "#" "" }
28 -def argb [color: string] { $"0xFF(hex-no-hash $color)" }
30 -def palette [mode: string] {
31 - open (palette-file) | get $mode
34 -def auto-enabled [] {
35 - let path = (auto-file)
36 - if not ($path | path exists) { return true }
37 - (open --raw $path | str trim) != "0"
40 -def set-auto [enabled: bool] {
41 - (if $enabled { "1" } else { "0" }) | save --raw --force (auto-file)
44 -def write-desktop-color-scheme [mode: string] {
45 - let scheme = if $mode == "dark" { "prefer-dark" } else { "prefer-light" }
46 - try { gsettings set org.gnome.desktop.interface color-scheme $scheme | ignore }
49 -def write-hyprtoolkit [mode: string, p: record] {
50 - let out = (config-home | path join "hypr" "hyprtoolkit.conf")
51 - $"background = (argb $p.content.backdrop)
52 -base = (argb $p.ui.backdrop)
53 -alternate_base = (argb $p.ui.unfocus)
54 -text = (argb $p.content.normal)
55 -bright_text = (argb $p.ui.important_global)
56 -accent = (argb $p.ui.accent)
57 -accent_secondary = (argb $p.content.important_local)
58 -h1_size = 20
59 -h2_size = 16
60 -h3_size = 13
61 -font_size = 11
62 -small_font_size = 10
63 -font_family = IBM Plex Sans
64 -font_family_monospace = IBM Plex Mono
65 -icon_theme = Adwaita
66 -" | save --raw --force $out
69 -def write-mako [mode: string, p: record] {
70 - mkdir (config-home | path join "mako")
71 - let out = (config-home | path join "mako" "nugu.conf")
72 - $"# Generated by hypr/scripts/theme.nu from Nugu palette.
73 -background-color=($p.ui.backdrop)ee
74 -text-color=($p.ui.normal)ff
75 -border-color=($p.ui.accent)ff
76 -progress-color=over ($p.ui.focus)ff
78 -[urgency=low]
79 -background-color=($p.content.backdrop)e6
80 -text-color=($p.content.minor)ff
81 -border-color=($p.ui.unfocus)ff
82 -progress-color=over ($p.content.minor)ff
84 -[urgency=normal]
85 -border-color=($p.ui.accent)ff
86 -progress-color=over ($p.ui.focus)ff
88 -[urgency=critical]
89 -background-color=($p.ui.backdrop)ff
90 -text-color=($p.ui.important_global)ff
91 -border-color=($p.error)ff
92 -progress-color=over ($p.error)ff
94 -[summary~=\"[Ee]rror|[Ff]ailed|[Ff]ailure|[Cc]rash\"]
95 -border-color=($p.error)ff
96 -progress-color=over ($p.error)ff
98 -[summary~=\"[Ww]arn|[Ww]arning\"]
99 -border-color=($p.warning)ff
100 -progress-color=over ($p.warning)ff
102 -[summary~=\"[Ii]nfo|[Nn]otice\"]
103 -border-color=($p.info)ff
104 -progress-color=over ($p.info)ff
105 -" | save --raw --force $out
108 -def write-ironbar [mode: string, p: record] {
109 - mkdir (config-home | path join "ironbar")
110 - let out = (config-home | path join "ironbar" "nugu.css")
111 - let surface = $p.ui.minor
112 - let on_focus = $p.content.backdrop
113 - $"/* Generated by hypr/scripts/theme.nu from Nugu palette. */
114 -:root {
115 - --bg: ($p.ui.backdrop);
116 - --bg-transparent: ($p.ui.backdrop)ee;
117 - --surface: ($surface);
118 - --fg: ($p.ui.normal);
119 - --accent: ($p.ui.accent);
120 - --focus: ($p.ui.focus);
121 - --on-focus: ($on_focus);
122 - --muted: ($p.ui.minor);
123 - --unfocus: ($p.ui.unfocus);
124 - --error: ($p.error);
125 - --warning: ($p.warning);
126 - --info: ($p.info);
127 - --debug: ($p.debug);
128 - --border: ($p.ui.accent);
130 -" | save --raw --force $out
133 -def apply-mode [mode: string] {
134 - mkdir (cache-dir)
135 - let p = (palette $mode)
136 - $mode | save --raw --force (mode-file)
137 - write-desktop-color-scheme $mode
138 - # Disabled until Hyprtoolkit handles live config rewrites without busy-looping:
139 - # https://github.com/hyprwm/hyprtoolkit/issues/92
140 - # write-hyprtoolkit $mode $p
141 - write-mako $mode $p
142 - write-ironbar $mode $p
144 - try { hyprctl hyprpaper wallpaper $",~/.config/hypr/wallpapers/nugu-($mode).png" | ignore }
145 - try { hyprctl reload | ignore }
146 - if (($env.NUGU_NO_RESTART_MAKO? | default "") != "1") {
147 - try { systemctl --user restart mako.service | ignore }
148 - }
149 - try { systemctl --user restart ironbar.service | ignore }
150 - if (($env.NUGU_NO_NOTIFY? | default "") != "1") {
151 - try { notify-send --expire-time 1500 "nugu" $"($mode) mode" | ignore }
152 - }
155 -def next-mode [] { if (active-mode) == "dark" { "light" } else { "dark" } }
157 -def main [mode: string = "toggle"] {
158 - let manual = $mode in [dark light toggle]
159 - if $manual { set-auto false }
160 - if $mode == "auto" { set-auto true }
162 - let target = match $mode {
163 - "dark" => "dark",
164 - "light" => "light",
165 - "toggle" => (next-mode),
166 - "auto" => (auto-mode),
167 - "current" => (active-mode),
168 - "watch" => { watch; return },
169 - _ => { error make { msg: "mode must be dark|light|toggle|auto|current|watch" } },
170 - }
171 - apply-mode $target
174 -def watch [] {
175 - loop {
176 - if (auto-enabled) {
177 - let target = (auto-mode)
178 - if $target != (active-mode) { apply-mode $target }
179 - }
180 - sleep 5min
181 - }

hypr/systemd/mako.service

Modified
6 6 [Service]
7 7 Environment=NUGU_NO_RESTART_MAKO=1
8 8 Environment=NUGU_NO_NOTIFY=1
9 -ExecStartPre=/usr/bin/nu %h/.config/hypr/scripts/theme.nu current
9 +ExecStartPre=/usr/bin/lua %h/.config/hypr/scripts/theme.lua current
10 10 ExecStart=/usr/bin/mako --config %h/.config/mako/config
11 11 Restart=on-failure
12 12 RestartSec=2

hypr/systemd/nugu-theme.service

Modified
5 5 Wants=hyprpaper.service
7 7 [Service]
8 -ExecStart=/usr/bin/nu %h/.config/hypr/scripts/theme.nu watch
8 +ExecStart=/usr/bin/lua %h/.config/hypr/scripts/theme.lua watch
9 9 Restart=on-failure
10 10 RestartSec=10