Improvements

This commit is contained in:
2026-07-02 12:43:02 +01:00
parent d1e13093c5
commit 49ba7ddb41
14 changed files with 187 additions and 74 deletions
+1 -1
View File
@@ -23,4 +23,4 @@ Then add `kutu.rb` to your `~/.xinitrc` file.
## TODO ## TODO
Add `ruby` like configuration files support. Add better `ruby` configuration files support.
+1 -5
View File
@@ -9,13 +9,9 @@ if ! XCB=$(pkg-config --cflags --libs xcb xcb-icccm 2>/dev/null); then
exit 1 exit 1
fi fi
if ! xrandr --version >/dev/null 2>&1; then
echo "Error: xrandr not found. Please install xrandr." >&2
exit 1
fi
mkdir -p "$DIR/build" mkdir -p "$DIR/build"
# shellcheck disable=SC2086
gcc -shared -fPIC -Wall -Wextra -o "$DIR/build/X-kutu.so" "$DIR/src/c/X-kutu.c" $XCB gcc -shared -fPIC -Wall -Wextra -o "$DIR/build/X-kutu.so" "$DIR/src/c/X-kutu.c" $XCB
if [ ! -f "$DIR/build/X-kutu.so" ]; then if [ ! -f "$DIR/build/X-kutu.so" ]; then
+39 -8
View File
@@ -21,7 +21,7 @@ void cleanup(void) {
// Keybind function to setup a key grab if the keycode is clicked along with the // Keybind function to setup a key grab if the keycode is clicked along with the
// MOD key // MOD key
void add_keybind(int key, int mod) { void add_keybind(int key, int mod) {
xcb_grab_key(conn, 0, scr->root, mod ? MOD : 0, key, XCB_GRAB_MODE_ASYNC, xcb_grab_key(conn, 0, scr->root, mod, key, XCB_GRAB_MODE_ASYNC,
XCB_GRAB_MODE_ASYNC); XCB_GRAB_MODE_ASYNC);
} }
@@ -31,7 +31,7 @@ void add_mousebind(int button, int mod) {
xcb_grab_button(conn, 0, scr->root, xcb_grab_button(conn, 0, scr->root,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE, XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, scr->root, XCB_NONE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, scr->root, XCB_NONE,
button, mod ? MOD : 0); button, mod);
} }
// Deploy function to initialize the X connection, set up event masks, and // Deploy function to initialize the X connection, set up event masks, and
@@ -84,7 +84,38 @@ void subscribe(xcb_window_t win) {
} }
// Kill a window // Kill a window
void kill(xcb_window_t window) { xcb_kill_client(conn, window); } void kill(xcb_window_t window) {
xcb_intern_atom_cookie_t wm_protocols_cookie =
xcb_intern_atom(conn, 1, 12, "WM_PROTOCOLS");
xcb_intern_atom_cookie_t wm_delete_window_cookie =
xcb_intern_atom(conn, 0, 16, "WM_DELETE_WINDOW");
xcb_intern_atom_reply_t *wm_protocols =
xcb_intern_atom_reply(conn, wm_protocols_cookie, NULL);
xcb_intern_atom_reply_t *wm_delete_window =
xcb_intern_atom_reply(conn, wm_delete_window_cookie, NULL);
if (!wm_protocols || !wm_delete_window) {
// fallback to force kill
xcb_kill_client(conn, window);
xcb_flush(conn);
return;
}
xcb_client_message_event_t ev = {0};
ev.response_type = XCB_CLIENT_MESSAGE;
ev.window = window;
ev.type = wm_protocols->atom;
ev.format = 32;
ev.data.data32[0] = wm_delete_window->atom;
ev.data.data32[1] = XCB_CURRENT_TIME;
xcb_send_event(conn, 0, window, XCB_EVENT_MASK_NO_EVENT, (char *)&ev);
xcb_flush(conn);
free(wm_protocols);
free(wm_delete_window);
}
// Destroy a window // Destroy a window
void destroy(xcb_window_t win) { xcb_destroy_window(conn, win); } void destroy(xcb_window_t win) { xcb_destroy_window(conn, win); }
@@ -111,12 +142,12 @@ Geometry get_geometry(xcb_window_t win) {
} }
// Get the current pointer position // Get the current pointer position
Geometry get_pointer(void) { PointerInfo get_pointer(void) {
xcb_query_pointer_reply_t *geom; xcb_query_pointer_reply_t *geom;
geom = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, scr->root), 0); geom = xcb_query_pointer_reply(conn, xcb_query_pointer(conn, scr->root), 0);
Geometry g = {geom->root_x, geom->root_y, 0, 0}; PointerInfo p = {geom->root_x, geom->root_y, geom->child};
free(geom); free(geom);
return g; return p;
} }
// Get the screen geometry // Get the screen geometry
@@ -301,7 +332,7 @@ Event translate_event(xcb_generic_event_t *ev) {
ret.x = e->event_x; ret.x = e->event_x;
ret.y = e->event_y; ret.y = e->event_y;
ret.btn = e->detail; ret.btn = e->detail;
ret.state = (e->state & MOD) != 0; ret.state = e->state;
} break; } break;
case XCB_MOTION_NOTIFY: { case XCB_MOTION_NOTIFY: {
@@ -326,7 +357,7 @@ Event translate_event(xcb_generic_event_t *ev) {
ret.type = 9; ret.type = 9;
ret.window = e->child; ret.window = e->child;
ret.btn = e->detail; ret.btn = e->detail;
ret.state = (e->state & MOD) != 0; ret.state = e->state;
} break; } break;
case XCB_KEY_RELEASE: { case XCB_KEY_RELEASE: {
+12 -1
View File
@@ -3,6 +3,7 @@
// Standard headers // Standard headers
#include <err.h> #include <err.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@@ -36,6 +37,12 @@ typedef struct Geometry {
uint16_t height; uint16_t height;
} Geometry; } Geometry;
typedef struct PointerInfo {
int16_t x;
int16_t y;
uint32_t window;
} PointerInfo;
// Event structure to represent various X events // Event structure to represent various X events
typedef struct Event { typedef struct Event {
int32_t type; int32_t type;
@@ -70,7 +77,7 @@ void hide(xcb_window_t window);
void send_to_top(xcb_window_t win); void send_to_top(xcb_window_t win);
Geometry get_geometry(xcb_window_t win); Geometry get_geometry(xcb_window_t win);
Geometry get_pointer(void); PointerInfo get_pointer(void);
Geometry get_screen(void); Geometry get_screen(void);
void free_geometry(Geometry *g); void free_geometry(Geometry *g);
@@ -93,4 +100,8 @@ void ungrab_pointer(void);
xcb_generic_event_t *next_event(void); xcb_generic_event_t *next_event(void);
Event translate_event(xcb_generic_event_t *ev); Event translate_event(xcb_generic_event_t *ev);
extern inline int mod() { return MOD; }
extern inline int clk() { return XCB_MOD_MASK_LOCK; }
extern inline int num() { return XCB_MOD_MASK_2; }
#endif // X_KUTU_H #endif // X_KUTU_H
+10 -1
View File
@@ -14,6 +14,12 @@ module X
:height, :uint16 :height, :uint16
end end
class PointerInfo < FFI::Struct
layout :x, :int16,
:y, :int16,
:window, :xcb_window_t
end
class Event < FFI::Struct class Event < FFI::Struct
layout :type, :int32, layout :type, :int32,
:window, :xcb_window_t, :window, :xcb_window_t,
@@ -75,7 +81,7 @@ module X
attach_function :send_to_top, [:xcb_window_t], :void attach_function :send_to_top, [:xcb_window_t], :void
attach_function :free_geometry, [:pointer], :void attach_function :free_geometry, [:pointer], :void
attach_function :get_geometry, [:xcb_window_t], Geometry.by_value attach_function :get_geometry, [:xcb_window_t], Geometry.by_value
attach_function :get_pointer, [], Geometry.by_value attach_function :get_pointer, [], PointerInfo.by_value
attach_function :get_screen, [], Geometry.by_value attach_function :get_screen, [], Geometry.by_value
attach_function :warp_pointer, [:xcb_window_t, :int, :int], :void attach_function :warp_pointer, [:xcb_window_t, :int, :int], :void
attach_function :move_window, [:xcb_window_t, :int, :int], :void attach_function :move_window, [:xcb_window_t, :int, :int], :void
@@ -91,4 +97,7 @@ module X
attach_function :grab_pointer, [:xcb_window_t], :void attach_function :grab_pointer, [:xcb_window_t], :void
attach_function :ungrab_pointer, [], :void attach_function :ungrab_pointer, [], :void
attach_function :get_root, [], :xcb_window_t attach_function :get_root, [], :xcb_window_t
attach_function :mod, [], :int
attach_function :clk, [], :int
attach_function :num, [], :int
end end
+63 -35
View File
@@ -1,20 +1,25 @@
keybind 23 do |_event| presets = {
normal: [0, X.clk],
mod: [X.mod, X.mod | X.clk]
}
keybind 23, presets[:mod] do |_event|
run "firefox" run "firefox"
end end
keybind 24 do |event| keybind 24, presets[:mod] do |event|
X.kill event[:window] X.kill event[:window]
end end
keybind 25 do |_event| keybind 25, presets[:mod] do |_event|
run "kitty" run "kitty"
end end
keybind 26 do |_event| keybind 26, presets[:mod] do |_event|
run File.join(__dir__, "../shell/power.sh") run File.join(__dir__, "../shell/power.sh")
end end
keybind 123, 0 do |_event| keybind 123, presets[:normal] do |_event|
run %q( run %q(
pactl set-sink-volume @DEFAULT_SINK@ +5%; pactl set-sink-volume @DEFAULT_SINK@ +5%;
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1);
@@ -22,7 +27,7 @@ keybind 123, 0 do |_event|
) )
end end
keybind 122, 0 do |_event| keybind 122, presets[:normal] do |_event|
run %q( run %q(
pactl set-sink-volume @DEFAULT_SINK@ -5%; pactl set-sink-volume @DEFAULT_SINK@ -5%;
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1); vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1);
@@ -30,7 +35,7 @@ keybind 122, 0 do |_event|
) )
end end
keybind 121, 0 do |_event| keybind 121, presets[:normal] do |_event|
run %q( run %q(
pactl set-sink-mute @DEFAULT_SINK@ toggle; pactl set-sink-mute @DEFAULT_SINK@ toggle;
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\\+%' | head -n1); vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\\+%' | head -n1);
@@ -38,7 +43,7 @@ keybind 121, 0 do |_event|
) )
end end
keybind 38 do |_event| keybind 38, presets[:mod] do |_event|
run %Q( run %Q(
maim -c 0.3,0.5,1.0,0.8 -s | tee /tmp/screenshot_temp.png | xclip -selection clipboard -t image/png; 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 if [ -s '/tmp/screenshot_temp.png' ]; then
@@ -47,7 +52,7 @@ keybind 38 do |_event|
) )
end end
keybind 232, 0 do |_event| keybind 232, presets[:normal] do |_event|
run %q( run %q(
brightnessctl set 5%-; brightnessctl set 5%-;
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
@@ -55,7 +60,7 @@ keybind 232, 0 do |_event|
) )
end end
keybind 233, 0 do |_event| keybind 233, presets[:normal] do |_event|
run %q( run %q(
brightnessctl set 5%+; brightnessctl set 5%+;
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %'); pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
@@ -63,27 +68,31 @@ keybind 233, 0 do |_event|
) )
end end
keybind 54 do |_event| keybind 54, presets[:mod] do |_event|
run "kitty -e fish -c \"y\"" run "kitty -e fish -c \"y\""
end end
keybind 53 do |_event| keybind 53, presets[:mod] do |_event|
run "kitty -e fish -c \"editor\"" run "kitty -e fish -c \"editor\""
end end
keybind 40 do |_event| 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") run File.join(__dir__, "../shell/run.sh")
end end
keybind 33 do |_event| keybind 33, presets[:mod] do |_event|
run "~/.config/polybar/launch.sh" run "~/.config/polybar/launch.sh"
end end
keybind 45 do |_event| keybind 45, presets[:mod] do |_event|
run File.join(__dir__, "../shell/caffiene.sh") run File.join(__dir__, "../shell/caffiene.sh")
end end
keybind 56 do |_event| keybind 56, presets[:mod] do |_event|
monitor = current_monitor monitor = current_monitor
create_workspace monitor create_workspace monitor
persistence_path = File.join(__dir__, ".num.json") persistence_path = File.join(__dir__, ".num.json")
@@ -95,7 +104,7 @@ keybind 56 do |_event|
File.write(persistence_path, JSON.pretty_generate(persistence)) File.write(persistence_path, JSON.pretty_generate(persistence))
end end
keybind 57 do |_event| keybind 57, presets[:mod] do |_event|
monitor = current_monitor monitor = current_monitor
delete_workspace monitor[:workspaces].length - 1, monitor delete_workspace monitor[:workspaces].length - 1, monitor
persistence_path = File.join(__dir__, ".num.json") persistence_path = File.join(__dir__, ".num.json")
@@ -107,7 +116,7 @@ keybind 57 do |_event|
File.write(persistence_path, JSON.pretty_generate(persistence)) File.write(persistence_path, JSON.pretty_generate(persistence))
end end
keybind 110, 0 do |_event| keybind 110, presets[:normal] do |_event|
run %q( run %q(
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause; 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+') \ dbus-send --print-reply --dest=$(busctl --user list | grep -oP 'org.mpris.MediaPlayer2.firefox.instance_1_\\d+') \
@@ -115,7 +124,15 @@ keybind 110, 0 do |_event|
) )
end end
keybind 110 do |_event| 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 monitor = current_monitor
persistence_path = File.join(__dir__, ".num.json") persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ? persistence = File.exist?(persistence_path) ?
@@ -131,7 +148,7 @@ keybind 110 do |_event|
end end
end end
keybind 115 do |event| keybind 89, presets[:mod] do |event|
monitor = current_monitor monitor = current_monitor
persistence_path = File.join(__dir__, ".num.json") persistence_path = File.join(__dir__, ".num.json")
persistence = File.exist?(persistence_path) ? persistence = File.exist?(persistence_path) ?
@@ -144,80 +161,91 @@ keybind 115 do |event|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]] ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end end
keybind 118, 0 do |_event| keybind 118, presets[:normal] do |_event|
run "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" run "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
end end
keybind 117, 0 do |_event| keybind 86, presets[:normal] do |_event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1 next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor select_workspace next_ws, monitor
end end
keybind 117 do |event| keybind 86, presets[:mod] do |event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1] ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]] ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end end
keybind 112, 0 do |_event| keybind 82, presets[:normal] do |_event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1 next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor select_workspace next_ws, monitor
end end
keybind 112 do |event| keybind 82, presets[:mod] do |event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1] 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]] ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end end
keybind 27 do |_event| 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__, "./bindings.rb")
load File.join(__dir__, "./events.rb")
monitor = current_monitor monitor = current_monitor
next unless monitor next unless monitor
monitor[:workspaces][monitor[:selected_workspace]].switch_direction monitor[:workspaces][monitor[:selected_workspace]].switch_direction
end end
keybind 55 do |_event| keybind 55, presets[:mod] do |_event|
run "rofi -modi 'clipboard:greenclip print' -show clipboard -run-command '{cmd}'" run %q(
CM_LAUNCHER=rofi clipmenu
)
end end
keybind 39 do |event| keybind 39, presets[:mod] do |event|
window = $windows[event[:window]] window = $windows[event[:window]]
window.toggle_floating if window window.toggle_floating if window
end end
mousebind 1 mousebind 1, presets[:mod] {|x|}
mousebind 3 mousebind 3, presets[:mod] {|x|}
mousebind 9, 0 do |_event| mousebind 9, presets[:normal] do |_event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1 next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor select_workspace next_ws, monitor
end end
mousebind 9 do |_event| mousebind 9, presets[:mod] do |event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1] ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]] ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
end end
mousebind 8, 0 do |_event| mousebind 8, presets[:normal] do |_event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1 next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
select_workspace next_ws, monitor select_workspace next_ws, monitor
end end
mousebind 8 do |_event| mousebind 8, presets[:mod] do |event|
monitor = current_monitor monitor = current_monitor
next if monitor[:selected_workspace].zero? next if monitor[:selected_workspace].zero?
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1] ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1]
-2
View File
@@ -19,8 +19,6 @@ def handle_command(command)
reply[:workspace] = monitor[:selected_workspace] reply[:workspace] = monitor[:selected_workspace]
reply[:monitor] = $monitors.key(monitor) reply[:monitor] = $monitors.key(monitor)
reply[:count] = monitor[:workspaces].length reply[:count] = monitor[:workspaces].length
when "topped"
reply[:topped] = $topped_windows
when "stop" when "stop"
exit 1 exit 1
end end
+9 -1
View File
@@ -14,7 +14,6 @@ EVENT_TYPES = {
13 => :resize_request 13 => :resize_request
}.freeze }.freeze
def handle_event(event) def handle_event(event)
case EVENT_TYPES[event[:type]] case EVENT_TYPES[event[:type]]
@@ -29,6 +28,15 @@ def handle_event(event)
$all_windows.delete event[:window] $all_windows.delete event[:window]
$windows[event[:window]]&.delete $windows[event[:window]]&.delete
X.focus $root X.focus $root
X.flush
mouse_pos = X.get_pointer
X.focus mouse_pos[:window] if mouse_pos[:window] != 0
when :closed_temp
X.focus $root
X.flush
mouse_pos = X.get_pointer
X.focus mouse_pos[:window] if mouse_pos[:window] != 0
when :enter when :enter
+10 -2
View File
@@ -1,9 +1,17 @@
def keybind(key, mod = 1, &block) def keybind(key, mod, &block)
if mod.is_a? Array
mod.each { |m| keybind(key, m, &block) }
return
end
X.add_keybind key, mod X.add_keybind key, mod
$keybind_actions[[key, mod]] = block if block $keybind_actions[[key, mod]] = block if block
end end
def mousebind(btn, mod = 1, &block) def mousebind(btn, mod, &block)
if mod.is_a? Array
mod.each { |m| mousebind(btn, m, &block) }
return
end
X.add_mousebind btn, mod X.add_mousebind btn, mod
$mousebind_actions[[btn, mod]] = block if block $mousebind_actions[[btn, mod]] = block if block
end end
+12 -2
View File
@@ -1,3 +1,7 @@
def godot_window?(window)
`xprop -id #{window} WM_CLASS`.downcase.include?("godot")
end
class Window class Window
attr_accessor :window_id, :floating, :workspace, :def_floating, :size, :x, :y, :width, :height attr_accessor :window_id, :floating, :workspace, :def_floating, :size, :x, :y, :width, :height
@@ -5,8 +9,14 @@ class Window
@size = 0 @size = 0
@workspace = workspace @workspace = workspace
@window_id = window_id @window_id = window_id
geometry = X.get_geometry(window_id)
@x = geometry[:x]
@y = geometry[:y]
@width = geometry[:width]
@height = geometry[:height]
wm_n_hints = X.get_wm_n_hints(window_id) wm_n_hints = X.get_wm_n_hints(window_id)
@floating = false @floating = godot_window?(window_id)
@def_floating = @floating
if wm_n_hints if wm_n_hints
if fixed_size_or_aspect?(wm_n_hints) if fixed_size_or_aspect?(wm_n_hints)
@floating = true @floating = true
@@ -24,7 +34,7 @@ class Window
end end
X.set_wm_state window_id, 1 X.set_wm_state window_id, 1
transient_for = X.get_wm_transient_for(window_id) transient_for = X.get_wm_transient_for(window_id)
unless transient_for.zero? if !transient_for.zero? && !godot_window?(window_id)
@floating = true @floating = true
@def_floating = true @def_floating = true
@width = wm_n_hints[:max_width] @width = wm_n_hints[:max_width]
+1
View File
@@ -156,5 +156,6 @@ class Workspace
X.show window.window_id X.show window.window_id
X.set_wm_state window.window_id, 1 X.set_wm_state window.window_id, 1
end end
X.focus $root
end end
end end
+14 -7
View File
@@ -1,22 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
opts=" opts=" Lock
󰒲 Suspend 󰒲 Suspend
 Stop KutuWM
 Shutdown  Shutdown
󰜉 Reboot" 󰜉 Reboot
 Hibernate
 Stop KutuWM"
sel=$(printf "%s\n" "$opts" | dmenu -i -p "Select Power Option:" \ sel=$(printf "%s\n" "$opts" | dmenu -i -p "Select Power Option:" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'HurmitNerdFont-16') -nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'AgaveNerdFont-16')
# user pressed Esc
[ -z "$sel" ] && exit 0 [ -z "$sel" ] && exit 0
case "$sel" in case "$sel" in
*Shutdown*) *Shutdown*)
confirm=$(printf "No\nYes" | dmenu -i -p "Are you sure you want to shutdown? :" \ confirm=$(printf "No\nYes" | dmenu -i -p "Are you sure you want to shutdown? :" \
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'HurmitNerdFont-16') -nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'AgaveNerdFont-16')
[ "$confirm" = "Yes" ] && exec shutdown -h now [ "$confirm" = "Yes" ] && exec shutdown -h now
;; ;;
*Reboot*) *Reboot*)
@@ -24,11 +24,18 @@ case "$sel" in
-nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'HurmitNerdFont-16') -nf '#e0af68' -nb '#1f2335' -sb '#f7768e' -sf '#1a1b26' -fn 'HurmitNerdFont-16')
[ "$confirm" = "Yes" ] && exec reboot [ "$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*) *Stop\ KutuWM*)
exec kutu-run.rb stop exec kutu-run.rb stop
;; ;;
*Suspend*) *Suspend*)
~/dotfiles/scripts/lock.sh &
exec systemctl suspend exec systemctl suspend
;; ;;
*Lock*)
~/dotfiles/scripts/lock.sh &
;;
esac esac
+2 -2
View File
@@ -2,13 +2,13 @@
choice=$( choice=$(
( (
printf "%s\n" godot mvox mox aseprite terraria printf "%s\n" godot mvox mox aseprite terraria zomboid silksong factorio oxygen
compgen -c 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)$' | 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 | sort |
dmenu -i -p "Enter command  " \ dmenu -i -p "Enter command  " \
-nf '#4abaaf' -nb '#1f2335' -sb '#7aa2f7' -sf '#102030' -fn 'HurmitNerdFont-16' -nf '#4abaaf' -nb '#1f2335' -sb '#7aa2f7' -sf '#102030' -fn 'AgaveNerdFont-16'
) )
[ -z "$choice" ] && exit 0 [ -z "$choice" ] && exit 0
+13 -7
View File
@@ -1,15 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
picom --config ~/.config/i3/picom.conf & picom --config ~/dotfiles/picom/dot-config/picom/picom.conf &
greenclip daemon & clipmenud &
# xss-lock --transfer-sleep-lock -- ~/dotfiles/scripts/lock.sh & # xss-lock --transfer-sleep-lock -- ~/dotfiles/scripts/lock.sh &
dunst -config ~/.config/dunst/dunstrc & dunst -config ~/.config/dunst/dunstrc &
bluetoothctl power off #magick -size 1920x1080 xc:#000000 /tmp/f_bg.png
#feh --bg-fill /tmp/f_bg.png
magick -size 1920x1080 xc:#000000 /tmp/f_bg.png
feh --bg-fill /tmp/f_bg.png
xsetroot -cursor_name left_ptr xsetroot -cursor_name left_ptr
xrdb ~/.Xresources
setxkbmap us 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