Compare commits
9 Commits
248e5a2c05
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
4b8599132f
|
|||
|
1cae22ad2c
|
|||
|
a859bab33d
|
|||
|
220f8cd810
|
|||
|
a0bec00988
|
|||
| 7fb1ea8cb3 | |||
| 0d2f52347d | |||
| 3eb15736f3 | |||
| 7460d38653 |
+3
-8
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
gcc
|
gcc
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|
||||||
xorg.libxcb
|
libxcb
|
||||||
xorg.xcbutilwm
|
xcbutilwm
|
||||||
xorg.xrandr
|
xrandr
|
||||||
xorg.xprop
|
xprop
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|||||||
+10
-7
@@ -2,7 +2,10 @@
|
|||||||
, ruby
|
, ruby
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, pkg-config
|
, pkg-config
|
||||||
, xorg
|
, libxcb
|
||||||
|
, xcbutilwm
|
||||||
|
, xrandr
|
||||||
|
, xprop
|
||||||
, rubyPackages
|
, rubyPackages
|
||||||
, gcc
|
, gcc
|
||||||
, lib
|
, lib
|
||||||
@@ -24,10 +27,10 @@ stdenv.mkDerivation {
|
|||||||
(ruby.withPackages (ps: [
|
(ruby.withPackages (ps: [
|
||||||
ps.ffi
|
ps.ffi
|
||||||
]))
|
]))
|
||||||
xorg.libxcb
|
libxcb
|
||||||
xorg.xcbutilwm
|
xcbutilwm
|
||||||
xorg.xrandr
|
xrandr
|
||||||
xorg.xprop
|
xprop
|
||||||
];
|
];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
@@ -53,8 +56,8 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
wrapProgram $out/bin/kutu.rb \
|
wrapProgram $out/bin/kutu.rb \
|
||||||
--prefix PATH : ${lib.makeBinPath [
|
--prefix PATH : ${lib.makeBinPath [
|
||||||
xorg.xrandr
|
xrandr
|
||||||
xorg.xprop
|
xprop
|
||||||
]}
|
]}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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) :
|
|
||||||
{}
|
|
||||||
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 81, 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
|
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
@@ -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+)/
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
choice=$(
|
|
||||||
(
|
|
||||||
printf "%s\n" prism
|
|
||||||
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
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user