repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nugu: add hypr and console generators

78664f0bca2957b8da7bafbb9974fc48079a71c8

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (5)

justfile

Modified
4 4 set shell := ["nu", "--commands"]
6 6 default:
7 7 @just --list
9 9 # initialize crypto, install hooks, verify, link dorkfiles into HOME
10 -link:
10 +link: nugu-linux-console nugu-hypr
11 11 java bootstripper.java bootstrap
13 +# build generated files needed by linked shell config
14 +nugu-linux-console:
15 + just --justfile nugu/justfile --working-directory nugu linux-console
17 +nugu-hypr:
18 + just --justfile nugu/justfile --working-directory nugu hypr
13 20 # verify crypto filters, hooks, and staged secrets
14 21 check:
15 22 java bootstripper.java check
24 +clean:
25 + java bootstripper.java clean
17 27 # run the same checks as the Git pre-commit hook
18 28 pre-commit:
19 29 java bootstripper.java pre-commit

nugu/README.md

Modified
7 7 * [x] helix
8 8 * [x] wezterm
9 +* [x] linux console
9 10 * [ ] LS\_COLORS
11 +* [x] hypr
12 +* [x] mako
10 13 * [ ] firefox
11 14 * [ ] nushell

nugu/hypr.nu

Added
new file mode 100644
1 +use nugu.nu
3 +export def json [] {
4 + {
5 + dark: (nugu dark | get palette)
6 + light: (nugu light | get palette)
7 + } | to json --indent 2
8 +}
10 +def q [s: string] { $'"($s)"' }
12 +def lua-palette [p: record] {
13 +$' debug = (q $p.debug),
14 + error = (q $p.error),
15 + warning = (q $p.warning),
16 + info = (q $p.info),
17 + content = {
18 + normal = (q $p.content.normal),
19 + backdrop = (q $p.content.backdrop),
20 + accent = (q $p.content.accent),
21 + minor = (q $p.content.minor),
22 + focus = (q $p.content.focus),
23 + unfocus = (q $p.content.unfocus),
24 + important_local = (q $p.content.important_local),
25 + important_global = (q $p.content.important_global),
26 + },
27 + ui = {
28 + normal = (q $p.ui.normal),
29 + backdrop = (q $p.ui.backdrop),
30 + accent = (q $p.ui.accent),
31 + minor = (q $p.ui.minor),
32 + focus = (q $p.ui.focus),
33 + unfocus = (q $p.ui.unfocus),
34 + important_local = (q $p.ui.important_local),
35 + important_global = (q $p.ui.important_global),
36 + },'
39 +export def lua [] {
40 + let dark = (nugu dark | get palette)
41 + let light = (nugu light | get palette)
42 + [
43 + 'local palette = {'
44 + ' dark = {'
45 + (lua-palette $dark)
46 + ' },'
47 + ' light = {'
48 + (lua-palette $light)
49 + ' },'
50 + '}'
51 + ''
52 + 'local M = {}'
53 + ''
54 + 'function M.mode()'
55 + ' local path = os.getenv("HOME") .. "/.cache/nugu/mode"'
56 + ' local file = io.open(path, "r")'
57 + ' if not file then return "dark" end'
58 + ' local mode = file:read("*l") or "dark"'
59 + ' file:close()'
60 + ' if mode == "light" then return "light" end'
61 + ' return "dark"'
62 + 'end'
63 + ''
64 + 'function M.current()'
65 + ' return palette[M.mode()]'
66 + 'end'
67 + ''
68 + 'function M.get(mode)'
69 + ' return palette[mode]'
70 + 'end'
71 + ''
72 + 'function M.hex(color)'
73 + ' return color:gsub("#", "")'
74 + 'end'
75 + ''
76 + 'function M.rgba(color, alpha)'
77 + ' return "rgba(" .. M.hex(color) .. (alpha or "ff") .. ")"'
78 + 'end'
79 + ''
80 + 'function M.rgb(color)'
81 + ' return "rgb(" .. M.hex(color) .. ")"'
82 + 'end'
83 + ''
84 + 'return M'
85 + ''
86 + ] | str join "\n"

nugu/justfile

Modified
12 12 open helix.nu | nu-check --as-module --debug helix.nu
13 13 open wezterm.nu | nu-check --as-module --debug wezterm.nu
14 14 open ghostty.nu | nu-check --as-module --debug ghostty.nu
15 + open linux_console.nu | nu-check --as-module --debug linux_console.nu
16 + open hypr.nu | nu-check --as-module --debug hypr.nu
16 18 fmt: lint
17 19 taplo fmt
64 66 cp {{output}}/ghostty/nugu-dark ../ghostty/themes/nugu-dark
65 67 cp {{output}}/ghostty/nugu-light ../ghostty/themes/nugu-light
67 -install: helix wezterm ghostty
69 +hypr: build
70 + rm --force --recursive {{output}}/hypr
71 + mkdir {{output}}/hypr
72 + use hypr.nu; hypr json | save --raw {{output}}/hypr/nugu.json
73 + use hypr.nu; hypr lua | save --raw {{output}}/hypr/nugu.lua
74 + mkdir ../hypr/generated
75 + cp {{output}}/hypr/nugu.json ../hypr/generated/nugu.json
76 + cp {{output}}/hypr/nugu.lua ../hypr/generated/nugu.lua
78 +linux-console: build
79 + rm --force --recursive {{output}}/linux-console
80 + mkdir {{output}}/linux-console
81 + mkdir ../bash/linux-console
82 + use linux_console.nu; linux_console theme dark | save --raw --force {{output}}/linux-console/nugu-dark.sh
83 + use linux_console.nu; linux_console theme light | save --raw --force {{output}}/linux-console/nugu-light.sh
84 + cp {{output}}/linux-console/nugu-dark.sh ../bash/linux-console/nugu-dark.sh
85 + cp {{output}}/linux-console/nugu-light.sh ../bash/linux-console/nugu-light.sh
87 +install: helix wezterm ghostty linux-console hypr

nugu/linux_console.nu

Added
new file mode 100644
1 +use palette.nu
3 +# Generate a sudo-free Linux virtual console palette script.
4 +# Linux console supports 16 palette slots via OSC: ESC ] P nrrggbb.
5 +# It does not provide real truecolor; SGR 256/24-bit colors are mapped back.
7 +export def theme [mode: string] {
8 + let nugu = (palette nugu $mode)
9 + let p = $nugu.palette
11 + let colors = [
12 + $p.content.backdrop # 0: black/default background
13 + $p.error # 1: red
14 + $p.content.focus # 2: green
15 + $p.warning # 3: yellow/brown
16 + $p.content.important_local # 4: blue
17 + $p.content.accent # 5: magenta
18 + $p.content.unfocus # 6: cyan
19 + $p.content.normal # 7: white/default foreground
20 + $p.content.minor # 8: bright black
21 + $p.info # 9: bright red
22 + $p.ui.unfocus # 10: bright green
23 + $p.ui.backdrop # 11: bright yellow
24 + $p.content.important_global # 12: bright blue
25 + $p.ui.accent # 13: bright magenta
26 + $p.ui.important_local # 14: bright cyan
27 + $p.ui.important_global # 15: bright white
28 + ]
30 + let palette_lines = ($colors | enumerate | each {|e|
31 + $"printf '\\033]P(hex-index $e.index)(strip-hash $e.item)'"
32 + })
34 + let header = [
35 + "#!/bin/sh"
36 + "# Generated by nugu/linux_console.nu."
37 + "# Sudo-free Linux virtual console palette."
38 + "# No effect outside TERM=linux."
39 + ""
40 + "if [ \"${TERM:-}\" != linux ]; then"
41 + "\treturn 0 2>/dev/null || exit 0"
42 + "fi"
43 + ""
44 + $"export NUGU_CONSOLE_THEME=($mode)"
45 + ""
46 + ]
48 + let footer = [
49 + ""
50 + "# After palette rewrite, black=slot 0 and white=slot 7."
51 + "if command -v setterm >/dev/null 2>&1; then"
52 + "\tsetterm --foreground white --background black --store"
53 + "fi"
54 + ""
55 + ]
57 + ($header ++ $palette_lines ++ $footer) | str join "\n"
60 +def strip-hash [hex: string] {
61 + $hex | str trim | str replace --regex '^#' '' | str downcase
64 +def hex-index [index: int] {
65 + [
66 + "0"
67 + "1"
68 + "2"
69 + "3"
70 + "4"
71 + "5"
72 + "6"
73 + "7"
74 + "8"
75 + "9"
76 + "a"
77 + "b"
78 + "c"
79 + "d"
80 + "e"
81 + "f"
82 + ] | get $index