Compare commits

...

12 Commits

Author SHA1 Message Date
syedm 4b8599132f Fix Import 2026-07-07 23:03:34 +01:00
syedm 1cae22ad2c Fix incorrect path 2026-07-07 22:25:19 +01:00
syedm a859bab33d Fix imports 2026-07-07 22:21:04 +01:00
syedm 220f8cd810 Fix typos 2026-07-07 22:13:03 +01:00
syedm a0bec00988 Update bindings api 2026-07-07 22:00:30 +01:00
syedm 7fb1ea8cb3 Make persistence path a proper global 2026-07-07 14:18:33 +01:00
syedm 0d2f52347d Fix persistence loading issue 2026-07-07 14:12:48 +01:00
syedm 3eb15736f3 Fix persistence and update deprecated dependencies 2026-07-07 13:58:25 +01:00
syedm 7460d38653 T 2026-07-07 13:25:42 +01:00
syedm 248e5a2c05 Update gitignore and minor fixes 2026-07-07 12:24:44 +01:00
syedm 10e0de5b05 Add package.nix and cleanup build process 2026-07-07 12:09:06 +01:00
syedm 2930d71889 Add flake.nix 2026-07-07 11:15:27 +01:00
15 changed files with 426 additions and 375 deletions
+1
View File
@@ -2,3 +2,4 @@
*.vim *.vim
*p.yml *p.yml
.num.json .num.json
result
+3 -8
View File
@@ -28,7 +28,8 @@ require_relative "../src/ruby/window"
require_relative "../src/ruby/workspace" require_relative "../src/ruby/workspace"
require_relative "../src/ruby/events" require_relative "../src/ruby/events"
require_relative "../src/ruby/commands" require_relative "../src/ruby/commands"
require_relative "../src/ruby/factory"
require_relative "../src/ruby/config"
# Cleanup on exit # Cleanup on exit
@@ -61,13 +62,7 @@ load_monitors!
# Run startup script # Run startup script
run File.join(__dir__, "../src/shell/startup.sh") load_config!
# Add keybinds
load File.join(__dir__, "../src/ruby/bindings.rb")
# Setup unix socket # Setup unix socket
Generated
+27
View File
@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1783148766,
"narHash": "sha256-uslt2pqShTIXDdAHRHv2QkYLsVdY8Oqwz0EA48/RSM8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a50de1b7d8a586adc18d2395c19de7d6058e6030",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-26.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+33
View File
@@ -0,0 +1,33 @@
{
description = "kutu wm environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
in {
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
(ruby.withPackages (ps: [
ps.ffi
]))
gcc
pkg-config
libxcb
xcbutilwm
xrandr
xprop
];
shellHook = ''
echo "kutu dev shell"
'';
};
packages.${system}.default = pkgs.callPackage ./package.nix {};
};
}
+63
View File
@@ -0,0 +1,63 @@
{ stdenv
, ruby
, makeWrapper
, pkg-config
, libxcb
, xcbutilwm
, xrandr
, xprop
, rubyPackages
, gcc
, lib
}:
stdenv.mkDerivation {
pname = "kutu";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [
pkg-config
makeWrapper
gcc
];
buildInputs = [
(ruby.withPackages (ps: [
ps.ffi
]))
libxcb
xcbutilwm
xrandr
xprop
];
buildPhase = ''
mkdir -p build
gcc -shared -fPIC \
-Wall -Wextra \
-o build/X-kutu.so \
src/c/X-kutu.c \
$(pkg-config --libs --cflags xcb xcb-icccm);
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/build
mkdir -p $out/src
cp bin/kutu.rb $out/bin/kutu.rb
cp bin/kutu-run.rb $out/bin/kutu-run.rb
cp build/X-kutu.so $out/build/
cp -r src/. $out/src/
wrapProgram $out/bin/kutu.rb \
--prefix PATH : ${lib.makeBinPath [
xrandr
xprop
]}
'';
}
-5
View File
@@ -28,9 +28,4 @@ for f in "$DIR/bin/"* "$DIR/src/shell/"*; do
} }
done done
if ! command -v kutu.rb >/dev/null 2>&1 || ! command -v kutu-run.rb >/dev/null 2>&1; then
echo "Tip: Add $DIR/bin to your PATH to run 'kutu.rb' and 'kutu-run.rb' from anywhere:"
echo "export PATH=\"\$PATH:$DIR/bin\""
fi
echo -e "\e[32mAll done! Build successful.\e[0m" echo -e "\e[32mAll done! Build successful.\e[0m"
-253
View File
@@ -1,253 +0,0 @@
presets = {
normal: [0, X.clk],
mod: [X.mod, X.mod | X.clk]
}
keybind 23, presets[:mod] do |_event|
run "firefox"
end
keybind 24, presets[:mod] do |event|
X.kill event[:window]
end
keybind 25, presets[:mod] do |_event|
run "kitty"
end
keybind 26, presets[:mod] do |_event|
run File.join(__dir__, "../shell/power.sh")
end
keybind 123, presets[:normal] do |_event|
run %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
keybind 122, presets[:normal] do |_event|
run %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
keybind 121, presets[:normal] do |_event|
run %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
keybind 38, presets[:mod] do |_event|
run %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
)
end
keybind 232, presets[:normal] do |_event|
run %q(
brightnessctl set 5%-;
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
dunstify "Brightness" "" -h int:value:$pct -r 998
)
end
keybind 233, presets[:normal] do |_event|
run %q(
brightnessctl set 5%+;
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
dunstify "Brightness" "" -h int:value:$pct -r 998
)
end
keybind 54, presets[:mod] do |_event|
run "kitty -e fish -c \"y\""
end
keybind 53, presets[:mod] do |_event|
run "kitty -e fish -c \"editor\""
end
keybind 41, presets[:mod] do |_event|
run "kitty -e fish -c \"btop\""
end
keybind 40, presets[:mod] do |_event|
run File.join(__dir__, "../shell/run.sh")
end
keybind 33, presets[:mod] do |_event|
run "~/.config/polybar/launch.sh"
end
keybind 45, presets[:mod] do |_event|
run File.join(__dir__, "../shell/caffiene.sh")
end
keybind 56, presets[:mod] do |_event|
monitor = current_monitor
create_workspace monitor
persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ?
JSON.parse(File.read(persistence_path), symbolize_names: true) :
{}
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
File.write(persistence_path, JSON.pretty_generate(persistence))
end
keybind 57, presets[:mod] do |_event|
monitor = current_monitor
delete_workspace monitor[:workspaces].length - 1, monitor
persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ?
JSON.parse(File.read(persistence_path), symbolize_names: true) :
{}
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
File.write(persistence_path, JSON.pretty_generate(persistence))
end
keybind 110, presets[:normal] do |_event|
run %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
)
end
keybind 173, presets[:mod] do |_event|
run %q(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous)
end
keybind 171, presets[:mod] do |_event|
run %q(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next)
end
keybind 110, presets[:mod] do |_event|
monitor = current_monitor
persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ?
JSON.parse(File.read(persistence_path), symbolize_names: true) :
{}
if monitor[:selected_workspace] == 0
select_workspace persistence[$monitors.key(monitor)]&.[](:saved) || 1, monitor
else
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:saved] = monitor[:selected_workspace]
File.write(persistence_path, JSON.pretty_generate(persistence))
select_workspace 0, monitor
end
end
keybind 89, presets[:mod] do |event|
monitor = current_monitor
persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ?
JSON.parse(File.read(persistence_path), symbolize_names: true) :
{}
ws = monitor[:workspaces][
monitor[:selected_workspace] == 0 ?
monitor[:workspaces][persistence[$monitors.key(monitor)]&.[](:saved) || 1] : 0
]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
keybind 118, presets[:normal] do |_event|
run "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
end
keybind 86, presets[:normal] do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
keybind 86, presets[:mod] do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
keybind 82, presets[:normal] do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
keybind 82, presets[:mod] do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
keybind 10, presets[:mod] do |_event|
run "setxkbmap us"
end
keybind 11, presets[:mod] do |_event|
run "setxkbmap ara"
end
keybind 27, presets[:mod] do |_event|
load File.join(__dir__, "./bindings.rb")
load File.join(__dir__, "./events.rb")
monitor = current_monitor
next unless monitor
monitor[:workspaces][monitor[:selected_workspace]].switch_direction
end
keybind 55, presets[:mod] do |_event|
run %q(
CM_LAUNCHER=rofi clipmenu
)
end
keybind 39, presets[:mod] do |event|
window = $windows[event[:window]]
window.toggle_floating if window
end
mousebind 1, presets[:mod] {|x|}
mousebind 3, presets[:mod] {|x|}
mousebind 9, presets[:normal] do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
mousebind 9, presets[:mod] do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
mousebind 8, presets[:normal] do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
mousebind 8, presets[:mod] do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
+24
View File
@@ -0,0 +1,24 @@
def config_path
File.join(
ENV["XDG_CONFIG_HOME"] || File.expand_path("~/.config"),
"kutu",
"config.rb"
)
end
def load_config!
path = config_path
unless File.exist?(path)
load "../src/ruby/defaults.rb"
return
end
puts "loading kutu config: #{path}"
load path
rescue Exception => e
warn "failed to load kutu config"
warn "#{e.class}: #{e.message}"
warn e.backtrace.join("\n")
end
+89
View File
@@ -0,0 +1,89 @@
bind_key 23, true, "firefox"
bind_key 24, true, :kill_window
bind_key 25, true, "kitty"
bind_key 26, true, "bash /home/me/dotfiles/scripts/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 /home/me/dotfiles/scripts/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 9, false, :workspace_next
bind_mouse 9, true, :move_window_next_workspace
bind_mouse 8, false, :workspace_previous
bind_mouse 8, true, :move_window_previous_workspace
+179
View File
@@ -0,0 +1,179 @@
PERSISTENCE_PATH = File.join(
ENV["XDG_STATE_HOME"] || File.expand_path("~/.local/state"),
"kutu",
"num.json"
)
ACTIONS = {}
def action(name, &block)
ACTIONS[name] = block
end
action :kill_window do |event|
X.kill event[:window]
end
action :toggle_floating do |event|
window = $windows[event[:window]]
window.toggle_floating if window
end
action :workspace_next do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws =
(monitor[:selected_workspace] %
(monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
action :workspace_previous do |_event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
next_ws =
((monitor[:selected_workspace] - 2) %
(monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor
end
action :move_window_next_workspace do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws =
monitor[:workspaces][
(monitor[:selected_workspace] %
(monitor[:workspaces].length - 1)) + 1
]
ws.drop ws.tiled_windows.length,
$windows[event[:window]] if $windows[event[:window]]
end
action :move_window_previous_workspace do |event|
monitor = current_monitor
next if monitor[:selected_workspace].zero?
ws =
monitor[:workspaces][
((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
]
ws.drop ws.tiled_windows.length,
$windows[event[:window]] if $windows[event[:window]]
end
action :toggle_scratchpad do |_event|
monitor = current_monitor
persistence = File.exist?(PERSISTENCE_PATH) ?
JSON.parse(File.read(PERSISTENCE_PATH), symbolize_names: true) :
{}
if monitor[:selected_workspace] == 0
select_workspace persistence[$monitors.key(monitor)]&.[](:saved) || 1, monitor
else
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:saved] = monitor[:selected_workspace]
File.write(PERSISTENCE_PATH, JSON.pretty_generate(persistence))
select_workspace 0, monitor
end
end
action :toggle_move_scratchpad do |event|
monitor = current_monitor
persistence = File.exist?(PERSISTENCE_PATH) ?
JSON.parse(File.read(PERSISTENCE_PATH), symbolize_names: true) :
{}
ws = monitor[:workspaces][
monitor[:selected_workspace] == 0 ?
monitor[:workspaces][persistence[$monitors.key(monitor)]&.[](:saved) || 1] : 0
]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end
action :add_workspace do |_event|
monitor = current_monitor
create_workspace monitor
persistence = File.exist?(PERSISTENCE_PATH) ?
JSON.parse(File.read(PERSISTENCE_PATH), symbolize_names: true) :
{}
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
File.write(PERSISTENCE_PATH, JSON.pretty_generate(persistence))
end
action :delete_workspace do |_event|
monitor = current_monitor
delete_workspace monitor[:workspaces].length - 1, monitor
persistence = File.exist?(PERSISTENCE_PATH) ?
JSON.parse(File.read(PERSISTENCE_PATH), symbolize_names: true) :
{}
persistence[$monitors.key(monitor)] ||= {}
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
File.write(PERSISTENCE_PATH, JSON.pretty_generate(persistence))
end
PRESETS = {
normal: [0, X.clk, X.num | X.clk, X.num],
mod: [
X.mod,
X.mod | X.clk,
X.num | X.clk | X.mod,
X.num | X.mod
]
}
def resolve_action(action, &block)
action ||= block
case action
when Symbol
ACTIONS.fetch(action) do
raise "Unknown kutu action: #{action}"
end
when String
proc do |_event|
run action
end
when Proc
action
else
raise ArgumentError,
"Expected action Symbol, String, or Block, got #{action.class}"
end
end
PRESETS[:mod].each do |modifier|
X.add_mousebind 1, modifier
end
PRESETS[:mod].each do |modifier|
X.add_mousebind 3, modifier
end
def bind_key(code, mod, action = nil, &block)
callback = resolve_action(action, &block)
PRESETS[mod ? :mod : :normal].each do |modifier|
X.add_keybind code, modifier
$keybind_actions[[code, modifier]] = callback
end
end
def bind_mouse(button, mod, action = nil, &block)
callback = resolve_action(action, &block)
PRESETS[mod ? :mod : :normal].each do |modifier|
X.add_mousebind button, modifier
$mousebind_actions[[button, modifier]] = callback
end
end
+7 -21
View File
@@ -1,21 +1,8 @@
def keybind(key, mod, &block) PERSISTENCE_PATH = File.join(
if mod.is_a? Array ENV["XDG_STATE_HOME"] || File.expand_path("~/.local/state"),
mod.each { |m| keybind(key, m, &block) } "kutu",
return "num.json"
end )
X.add_keybind key, mod
$keybind_actions[[key, mod]] = block if block
end
def mousebind(btn, mod, &block)
if mod.is_a? Array
mod.each { |m| mousebind(btn, m, &block) }
return
end
X.add_mousebind btn, mod
$mousebind_actions[[btn, mod]] = block if block
end
def run(cmd) def run(cmd)
pid = spawn "bash", "-c", cmd pid = spawn "bash", "-c", cmd
@@ -29,9 +16,8 @@ def load_monitors!
xrandr_output = `xrandr --query` xrandr_output = `xrandr --query`
connected = xrandr_output.each_line.select { |line| line.include?(" connected") } connected = xrandr_output.each_line.select { |line| line.include?(" connected") }
connected.sort_by! { |line| line.include?(" primary") ? 0 : 1 } connected.sort_by! { |line| line.include?(" primary") ? 0 : 1 }
persistence_path = File.join(__dir__, ".num.json") persistence = File.exist?(PERSISTENCE_PATH) ?
persistence = File.exist?(persistence_path) ? JSON.parse(File.read(PERSISTENCE_PATH), symbolize_names: true) :
JSON.parse(File.read(persistence_path), symbolize_names: true) :
{} {}
connected.first(2).each_with_index do |line, index| connected.first(2).each_with_index do |line, index|
next unless line =~ /(\d+)x(\d+)\+(\d+)\+(\d+)/ next unless line =~ /(\d+)x(\d+)\+(\d+)\+(\d+)/
-9
View File
@@ -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
-41
View File
@@ -1,41 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
opts=" Lock
󰒲 Suspend
 Shutdown
󰜉 Reboot
 Hibernate
 Stop KutuWM"
sel=$(printf "%s\n" "$opts" | dmenu -i -p "Select Power Option:" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'AgaveNerdFont-16')
[ -z "$sel" ] && exit 0
case "$sel" in
*Shutdown*)
confirm=$(printf "No\nYes" | dmenu -i -p "Are you sure you want to shutdown? :" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'AgaveNerdFont-16')
[ "$confirm" = "Yes" ] && exec shutdown -h now
;;
*Reboot*)
confirm=$(printf "No\nYes" | dmenu -i -p "Are you sure you want to reboot? :" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'HurmitNerdFont-16')
[ "$confirm" = "Yes" ] && exec reboot
;;
*Hibernate*)
confirm=$(printf "No\nYes" | dmenu -i -p "Are you sure you want to hibernate? :" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'AgaveNerdFont-16')
[ "$confirm" = "Yes" ] && exec systemctl hibernate
;;
*Stop\ KutuWM*)
exec kutu-run.rb stop
;;
*Suspend*)
exec systemctl suspend
;;
*Lock*)
~/dotfiles/scripts/lock.sh &
;;
esac
-17
View File
@@ -1,17 +0,0 @@
#!/usr/bin/env bash
choice=$(
(
printf "%s\n" godot mvox mox aseprite terraria zomboid silksong factorio oxygen
compgen -c
) |
grep -v -E '^(if|fi|case|esac|for|done|while|until|select|function|return|continue|break|time|exec|source|alias|builtin|read|export|unset|local|set|declare|typeset|:|\.|\[|coproc|l|ll|ls|then|else|elif|do|in|\{|\}|!|\[\[|\]\]|_.*|compgen)$' |
sort |
dmenu -i -p "Enter command  " \
-nf '#4abaaf' -nb '#1f2335' -sb '#7aa2f7' -sf '#102030' -fn 'AgaveNerdFont-16'
)
[ -z "$choice" ] && exit 0
fish -c "$choice" >/dev/null 2>&1 &
disown
-21
View File
@@ -1,21 +0,0 @@
#!/usr/bin/env bash
picom --config ~/dotfiles/picom/dot-config/picom/picom.conf &
clipmenud &
# xss-lock --transfer-sleep-lock -- ~/dotfiles/scripts/lock.sh &
dunst -config ~/.config/dunst/dunstrc &
#magick -size 1920x1080 xc:#000000 /tmp/f_bg.png
#feh --bg-fill /tmp/f_bg.png
xsetroot -cursor_name left_ptr
setxkbmap us
export XAUTHORITY="$HOME/.Xauthority"
systemctl --user import-environment DISPLAY XAUTHORITY
dbus-update-activation-environment DISPLAY XAUTHORITY
systemctl --user restart xdg-desktop-portal
systemctl --user restart xdg-desktop-portal-gtk