From 41491f62abd639784f38b5179f5fbd4901357f85 Mon Sep 17 00:00:00 2001 From: Syed Daanish Date: Fri, 18 Sep 2026 10:22:48 +0100 Subject: [PATCH] Switch to new version of kutuWM. --- home/kutu/config.rb | 277 ++++++++++++++-------------------- home/kutu/default.nix | 5 +- home/kutu/scripts/caffiene.sh | 9 -- home/kutu/scripts/power.sh | 3 +- home/kutu/scripts/run.sh | 1 - home/tardis.nix | 5 - 6 files changed, 116 insertions(+), 184 deletions(-) delete mode 100644 home/kutu/scripts/caffiene.sh diff --git a/home/kutu/config.rb b/home/kutu/config.rb index 1ce0bda..b61ccce 100644 --- a/home/kutu/config.rb +++ b/home/kutu/config.rb @@ -1,224 +1,167 @@ -# ==== State ==== +tmp_src = "@src@" +if tmp_src == "@src@" + SRC = "~/main/ocaml/epq/scripts" +else + SRC = tmp_src +end -MAX_PROJECTS = 9 -SUBS = 2 # workspaces per project - -$current_project = 1 # 1..MAX_PROJECTS -$current_sub = 0 # 0..SUBS-1 - -# For each special workspace, remembers which workspace you were on -# before you jumped into it -- so hitting the mode key again toggles back. -$special_origin = {} +MAX_PROJECTS = 3 SPECIAL = { - terminal: { cmd: "kitty" }, - browser: { cmd: "firefox" }, - music: { cmd: "spotify" }, - misc: { cmd: nil }, # doesn't start anything - todo: { cmd: nil }, # doesn't start anything + terminal: { cmd: 'kitty' }, + browser: { cmd: 'firefox' }, + misc: { cmd: nil } } -# ==== Helpers ==== +$current = 0 -def project_ws(n, sub) - :"p#{n}_#{sub}" +system "bash #{SRC}/startup.sh >/dev/null 2>&1 &" + +def project_ws(n) + :"p#{n}" end -def running?(process) - system("pgrep #{process} > /dev/null 2>&1") -end - -def go_project(n, sub) - $current_project = n - $current_sub = sub - jump_ws project_ws(n, sub) +def go_project(n) + $current = n + jump_ws project_ws($current) end def in_project?(ws) !SPECIAL.key?(ws) end -# Toggle between a special-mode workspace (terminal/browser/music/misc/todo) -# and whatever workspace you were last on. Starts the associated app if -# it isn't already running. `ws` is the current workspace, passed in by -# the bind block (bind gives us (window, current_ws)). def go_special(name, ws) cfg = SPECIAL.fetch(name) if ws == name - target = $special_origin[name] || project_ws($current_project, $current_sub) + target = project_ws($current) jump_ws target else - $special_origin[name] = ws jump_ws name - system("#{cfg[:cmd]} >/dev/null 2>&1 &") if cfg[:cmd] && !running?(cfg[:cmd]) + system("#{cfg[:cmd]} >/dev/null 2>&1 &") if cfg[:cmd] && ws_empty?(name) end end -# ==== Untouched bindings ==== - -bind ?q do |x| +bind 'q' do |x| kill x end -bind ?w do - system "kitty >/dev/null 2>&1 &" +bind 'w' do + system 'kitty >/dev/null 2>&1 &' end -bind ?e do - exit +bind 'e' do + system "bash #{SRC}/power.sh >/dev/null 2>&1 &" end -bind ?f do |x| +bind 'd' do + system "bash #{SRC}/run.sh >/dev/null 2>&1 &" +end + +bind 'v' do + system 'CM_LAUNCHER=rofi clipmenu >/dev/null 2>&1 &' +end + +bind 'a' do + system 'bash', '-c', " + maim -c 0.3,0.5,1.0,0.8 -s | tee /tmp/screenshot_temp.png | xclip -selection clipboard -t image/png; + if [ -s '/tmp/screenshot_temp.png' ]; then + mv /tmp/screenshot_temp.png ~/screenshots/$(date +%Y-%m-%d_%H:%M:%S).png; + fi + " +end + +bind 123, :none do + system 'bash', '-c', %q( + pactl set-sink-volume @DEFAULT_SINK@ +5%; + vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); + dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 + ) +end + +bind 122, :none do + system 'bash', '-c', %q( + pactl set-sink-volume @DEFAULT_SINK@ -5%; + vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); + dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 + ) +end + +bind 121, :none do + system 'bash', '-c', %q( + pactl set-sink-mute @DEFAULT_SINK@ toggle; + vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); + dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 + ) +end + +bind 232, :none do + system 'bash', '-c', %q( + brightnessctl set 5%-; + pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); + dunstify "Brightness" "" -h int:value:$pct -r 998 + ) +end + +bind 233, :none do + system 'bash', '-c', %q( + brightnessctl set 5%+; + pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); + dunstify "Brightness" "" -h int:value:$pct -r 998 + ) +end + +bind 'x' do + system 'kitty -e fish -c "editor" >/dev/null 2>&1 &' +end + +bind 'c' do + system 'kitty -e fish -c "y" >/dev/null 2>&1 &' +end + +bind 's' do |x| toggle_float x end -# ==== Mode switches ==== +bind 'f' do + system 'kitty -e fish -c "btop" >/dev/null 2>&1 &' +end -bind ?[ do |_, ws| +bind 80, :none do |_, ws| go_special :terminal, ws end -bind ?] do |_, ws| - go_special :misc, ws -end - -bind "tab" do |_, ws| +bind 79, :none do |_, ws| go_special :browser, ws end bind 89 do |_, ws| - go_special :music, ws + go_special :misc, ws end -bind 81 do |_, ws| - go_special :todo, ws +bind 118, :none do + system 'bash', '-c', + 'dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause >/dev/null 2>&1 &' end -# ==== Project navigation ==== - -(1..MAX_PROJECTS).each do |n| - bind n.to_s do - go_project(n, $current_sub) +(0..MAX_PROJECTS - 1).each do |n| + bind (n + 1).to_s do + go_project(n) end end bind 86, :none do |_, ws| next unless in_project?(ws) - n = (($current_project - 2) % MAX_PROJECTS) + 1 - go_project(n, $current_sub) + + n = (($current - 1 + MAX_PROJECTS) % MAX_PROJECTS) + go_project(n) end bind 82, :none do |_, ws| next unless in_project?(ws) - n = ($current_project % MAX_PROJECTS) + 1 - go_project(n, $current_sub) + + n = (($current + 1) % MAX_PROJECTS) + go_project(n) end -bind 79, :none do |_, ws| - next unless in_project?(ws) - go_project($current_project, ($current_sub + 1) % SUBS) -end - -bind 80, :none do |_, ws| - next unless in_project?(ws) - go_project($current_project, ($current_sub - 1 + SUBS) % SUBS) -end - -# ==== Startup ==== - -go_project(1, 0) - -=begin -run "bash @src@/startup.sh" - -bind_key 23, true, "firefox" -bind_key 24, true, :kill_window -bind_key 25, true, "kitty" -bind_key 26, true, "bash @src@/power.sh" - -bind_key 123, false, %q( - pactl set-sink-volume @DEFAULT_SINK@ +5%; - vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); - dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 -) - -bind_key 122, false, %q( - pactl set-sink-volume @DEFAULT_SINK@ -5%; - vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); - dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 -) - -bind_key 121, false, %q( - pactl set-sink-mute @DEFAULT_SINK@ toggle; - vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); - dunstify "Volume Adjusted" "" -h int:value:$vol -r 997 -) - -bind_key 38, true, %Q( - maim -c 0.3,0.5,1.0,0.8 -s | tee /tmp/screenshot_temp.png | xclip -selection clipboard -t image/png; - if [ -s '/tmp/screenshot_temp.png' ]; then - mv /tmp/screenshot_temp.png ~/screenshots/$(date +%Y-%m-%d_%H:%M:%S).png; - fi -) - -bind_key 232, false, %q( - brightnessctl set 5%-; - pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); - dunstify "Brightness" "" -h int:value:$pct -r 998 -) - -bind_key 233, false, %q( - brightnessctl set 5%+; - pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); - dunstify "Brightness" "" -h int:value:$pct -r 998 -) - -bind_key 54, true, 'kitty -e fish -c "y"' -bind_key 53, true, 'kitty -e fish -c "editor"' -bind_key 41, true, 'kitty -e fish -c "btop"' - -bind_key 40, true, "bash @src@/run.sh" - -bind_key 56, true, :add_workspace -bind_key 57, true, :delete_workspace - -bind_key 110, false, %q( - dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify \ - /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause; - dbus-send --print-reply --dest=$(busctl --user list | grep -oP 'org.mpris.MediaPlayer2.firefox.instance_1_\d+') \ - /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause -) - -bind_key 173, true, - "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" - -bind_key 171, true, - "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" - -bind_key 89, true, :toggle_scratchpad - -bind_key 81, true, :toggle_move_scratchpad - -bind_key 118, false, - "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" - -bind_key 86, false, :workspace_next -bind_key 86, true, :move_window_next_workspace - -bind_key 82, false, :workspace_previous -bind_key 82, true, :move_window_previous_workspace - -bind_key 10, true, "setxkbmap us" -bind_key 11, true, "setxkbmap ara" - -bind_key 55, true, "CM_LAUNCHER=rofi clipmenu" - -bind_key 39, true, :toggle_floating - -bind_mouse 8, false, :workspace_next -bind_mouse 8, true, :move_window_next_workspace - -bind_mouse 9, false, :workspace_previous -bind_mouse 9, true, :move_window_previous_workspace -=end +go_project(0) diff --git a/home/kutu/default.nix b/home/kutu/default.nix index cd96a41..103f294 100644 --- a/home/kutu/default.nix +++ b/home/kutu/default.nix @@ -11,5 +11,8 @@ let }; in { - home.file.".config/kutu/config.rb".source = script; + xsession = { + enable = true; + windowManager.command = "kutu ${script}"; + }; } diff --git a/home/kutu/scripts/caffiene.sh b/home/kutu/scripts/caffiene.sh deleted file mode 100644 index f28916f..0000000 --- a/home/kutu/scripts/caffiene.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ "$(xset q | awk '/timeout:/ {print $2}')" == "0" ]]; then - xset s on - xset +dpms -else - xset s off - xset -dpms -fi diff --git a/home/kutu/scripts/power.sh b/home/kutu/scripts/power.sh index 69e0dba..75917f8 100644 --- a/home/kutu/scripts/power.sh +++ b/home/kutu/scripts/power.sh @@ -31,7 +31,8 @@ case "$sel" in [ "$confirm" = "Yes" ] && exec systemctl --system hibernate ;; *Stop\ KutuWM*) - exec kutu-run.rb stop + #exec kutu-run.rb stop TODO. + pkill X ;; *Suspend*) exec systemctl --system suspend diff --git a/home/kutu/scripts/run.sh b/home/kutu/scripts/run.sh index 97026fb..2f2b12f 100644 --- a/home/kutu/scripts/run.sh +++ b/home/kutu/scripts/run.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash declare -A aliases=( - [prism]="nvidia-offload prismlauncher" [editor]="kitty -e fish -c editor" [yazi]="kitty -e fish -c yazi" [btop]="kitty -e fish -c btop" diff --git a/home/tardis.nix b/home/tardis.nix index 4698f62..b4564fc 100644 --- a/home/tardis.nix +++ b/home/tardis.nix @@ -10,11 +10,6 @@ ./rofi ]; - xsession = { - enable = true; - windowManager.command = "kutu ~/main/ocaml/epq/config.rb"; - }; - home.file.".xinitrc".text = '' if [ -f ~/.xsession ]; then exec ~/.xsession