diff --git a/home/tiling/niri/config/config.kdl b/home/tiling/niri/config/config.kdl index 82d0769..bf874e8 100644 --- a/home/tiling/niri/config/config.kdl +++ b/home/tiling/niri/config/config.kdl @@ -179,7 +179,7 @@ layout { // off width 1 - active-color "#6c7086" + active-color "#fab387" // active-gradient from="#fab387" to="#89b4fa" angle=90 inactive-color "#313244" // inactive-gradient from="#313244" to="#6c7086" angle=90 @@ -252,6 +252,10 @@ layout { // This line starts waybar, a commonly used bar for Wayland compositors. spawn-at-startup "waybar" +// run tailscale system tray +spawn-at-startup "sudo tailscale set --operator=$USER" +spawn-at-startup "tailscale systray" + // Instead let's start quickshell, which is similar but made with Qt/QML // spawn-at-startup "quickshell" @@ -374,8 +378,8 @@ binds { // Example brightness key mappings for brightnessctl. // You can use regular spawn with multiple arguments too (to avoid going through "sh"), // but you need to manually put each argument in separate "" quotes. - XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } - XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } + XF86MonBrightnessUp allow-when-locked=true { spawn "/home/sckova/.config/niri/scripts/brightness.sh" "5"; } + XF86MonBrightnessDown allow-when-locked=true { spawn "/home/sckova/.config/niri/scripts/brightness.sh" "-5"; } // Open/close the Overview: a zoomed-out view of workspaces and windows. // You can also move the mouse into the top-left hot corner, diff --git a/home/tiling/niri/config/scripts/brightness.sh b/home/tiling/niri/config/scripts/brightness.sh new file mode 100755 index 0000000..73ed4a9 --- /dev/null +++ b/home/tiling/niri/config/scripts/brightness.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +WAYBAR_SIGNAL=8 # SIGRTMIN+8 + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +value="$1" + +# Validate integer range +if ! [[ "$value" =~ ^-?[0-9]+$ ]] || [ "$value" -lt -100 ] || [ "$value" -gt 100 ]; then + echo "Error: argument must be an integer between -100 and 100" >&2 + exit 1 +fi + +# Apply brightness change with correct syntax +if [ "$value" -gt 0 ]; then + brightnessctl s "+${value}%" >/dev/null +elif [ "$value" -lt 0 ]; then + brightnessctl s "${value#-}%-" >/dev/null +else + : # no-op for 0 +fi + +# Notify Waybar to refresh +pkill -RTMIN+"$WAYBAR_SIGNAL" waybar + diff --git a/home/tiling/waybar/config/config.jsonc b/home/tiling/waybar/config/config.jsonc index 1272ad6..de2e1e0 100644 --- a/home/tiling/waybar/config/config.jsonc +++ b/home/tiling/waybar/config/config.jsonc @@ -8,24 +8,24 @@ "margin-bottom": 0, "margin-left": 0, - "modules-left": ["sway/workspaces"], + "modules-left": ["custom/niri-window"], "modules-center": [], "modules-right": [ "tray", - "cpu_text", "cpu", "memory", "battery", "network", + "custom/brightness", "pulseaudio", "custom/clock", ], - "sway/workspaces": { - "disable-scroll": true, - "all-outputs": true, + "custom/niri-window": { + "exec": "/home/sckova/.config/waybar/scripts/niri-window.sh", + "restart-interval": 1, "tooltip": false, }, @@ -75,6 +75,13 @@ "tooltip": false, }, + "custom/brightness": { + "exec": "/home/sckova/.config/waybar/scripts/brightness.sh", + "restart-interval": 10, + "signal": 8, + "tooltip": false, + }, + "pulseaudio": { "scroll-step": 5, "max-volume": 150, diff --git a/home/tiling/waybar/config/scripts/brightness.sh b/home/tiling/waybar/config/scripts/brightness.sh new file mode 100755 index 0000000..d6a0ca9 --- /dev/null +++ b/home/tiling/waybar/config/scripts/brightness.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +MAX=500 + +current=$(brightnessctl g) + +# Guard against empty or non-numeric output +if ! [[ "$current" =~ ^[0-9]+$ ]]; then + echo "brightnessctl returned invalid value" >&2 + exit 1 +fi + +percentage=$(( current * 100 / MAX )) + +echo "bright ${percentage}%" + diff --git a/home/tiling/waybar/config/scripts/clock.sh b/home/tiling/waybar/config/scripts/clock.sh index 8185d57..9876ef6 100755 --- a/home/tiling/waybar/config/scripts/clock.sh +++ b/home/tiling/waybar/config/scripts/clock.sh @@ -1 +1,13 @@ -date +"%a, %b %d @ %I:%M%P" +#!/usr/bin/env bash + +day=$(date +%-d) + +case "$day" in + 11|12|13) suffix="th" ;; + *1) suffix="st" ;; + *2) suffix="nd" ;; + *3) suffix="rd" ;; + *) suffix="th" ;; +esac + +date +"%a, %b $day$suffix %Y @ %I:%M%P" diff --git a/home/tiling/waybar/config/scripts/niri-window.sh b/home/tiling/waybar/config/scripts/niri-window.sh new file mode 100755 index 0000000..a27d14c --- /dev/null +++ b/home/tiling/waybar/config/scripts/niri-window.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +last="" + +while :; do + current=$( + niri msg focused-window | awk -F'"' ' + /App ID:/ { app = $2 } + /Title:/ { title = $2 } + END { + if (app && title) { + print app " - " title + } + } + ' + ) + + if [[ -n "$current" && "$current" != "$last" ]]; then + printf '%s\n' "$current" + last="$current" + fi + + sleep 0.01 +done + diff --git a/home/tiling/waybar/config/style.css b/home/tiling/waybar/config/style.css index 6a31bac..7d9a78d 100644 --- a/home/tiling/waybar/config/style.css +++ b/home/tiling/waybar/config/style.css @@ -4,14 +4,16 @@ border-radius: 0; min-height: 0; font-family: "Noto Sans"; - /*font-weight: bold;*/ font-size: 12px; padding: 0; } window#waybar { - background: transparent; - border-bottom-color: @mantle; + background: black; + border: 2px solid @base; + border-top-width: 0px; + border-left-width: 0px; + border-right-width: 0px; } tooltip { @@ -19,12 +21,14 @@ tooltip { border-color: @peach; } +#custom-niri-window, #custom-clock, #tray, #cpu, #memory, #battery, #network, +#custom-brightness, #pulseaudio { background-color: @base; color: @text; @@ -56,6 +60,11 @@ tooltip { color: #1d2021; } +#custom-niri-window { + margin-left: 6px; + border-color: @yellow; +} + #cpu { border-color: @maroon; } @@ -72,6 +81,10 @@ tooltip { border-color: @teal; } +#custom-brightness { + border-color: @sky; +} + #pulseaudio { border-color: @blue; } diff --git a/system/all.nix b/system/all.nix index fabe5d8..17dfe77 100755 --- a/system/all.nix +++ b/system/all.nix @@ -105,7 +105,10 @@ enable = true; }; - programs.niri.enable = true; + programs.niri = { + enable = true; + useNautilus = false; + }; services.gnome.gnome-keyring.enable = true; security.pam.services.niri.enableGnomeKeyring = true;