Better bindings

This commit is contained in:
2026-06-21 16:44:45 +01:00
parent fecc16e904
commit a43a24e8ba
5 changed files with 76 additions and 104 deletions
+76 -14
View File
@@ -25,6 +25,10 @@ local function bindlr(key, cmd, desc, opts)
bindl(key, cmd, desc, opts)
end
local function notify(text)
hl.notification.create({ text = text, duration = 2000 })
end
-- Laptop multimedia keys for volume and LCD brightness (with OSD)
bindlr("XF86AudioRaiseVolume", exec(osdclient .. " --output-volume raise"), "Volume up")
bindlr("XF86AudioRaiseVolume", exec(osdclient .. " --output-volume raise"), "Volume up")
@@ -70,8 +74,53 @@ bind("SUPER + Q", hl.dsp.window.close(), "Close window")
bind("SUPER + P", hl.dsp.window.pseudo()--[[# dwindle]], "Pseudo window")
bind("SUPER + F", hl.dsp.window.fullscreen(0), "Full screen")
bind("SUPER + CTRL + F", hl.dsp.window.fullscreen(1), "Full width")
bind("SUPER + T", exec("station-hyprland-window-pop"), "Pop window out (float & pin)")
bind("SUPER + CTRL + L", exec("station-hyprland-workspace-layout-toggle"), "Toggle workspace layout")
bind("SUPER + T", function()
local width = 1300
local height = 900
local pinned = hl.get_active_window().pinned
if pinned then
hl.dispatch(hl.dsp.window.pin())
hl.dispatch(hl.dsp.window.float({ action = "toggle" }))
hl.dispatch(hl.dsp.window.tag({ tag = "-pop" }))
else
hl.dispatch(hl.dsp.window.float({ action = "toggle" }))
hl.dispatch(hl.dsp.window.resize({ x = width, y = height }))
hl.dispatch(hl.dsp.window.center())
hl.dispatch(hl.dsp.window.pin())
hl.dispatch(hl.dsp.window.alter_zorder({ mode = "top" }))
hl.dispatch(hl.dsp.window.tag({ tag = "+pop" }))
end
end, "Pop window out (float & pin)")
bind("SUPER + CTRL + L", function()
local layouts = { "dwindle", "scrolling", "monocle", "master" }
local workspace = hl.get_active_workspace()
if hl.get_active_special_workspace() then
workspace = hl.get_active_special_workspace()
end
local next_layout = "dwindle"
if not workspace then
return
end
for i = 1, #layouts do
if layouts[i] == workspace.tiled_layout then
local next_layout_idx = (i % #layouts) + 1
next_layout = layouts[next_layout_idx]
break
end
end
if workspace.special then
hl.workspace_rule({ workspace = tostring(workspace.name), layout = next_layout })
else
hl.workspace_rule({ workspace = tostring(workspace.id), layout = next_layout })
end
notify("󱂬 Workspace layout set to " .. next_layout)
end, "Toggle workspace layout")
-- Move focus with SUPER + arrow keys
bind("SUPER + H", hl.dsp.focus({ direction = "left" }), "Move window focus left")
@@ -153,12 +202,26 @@ bind(
exec("hyprctl dispatch setprop \"address:$(hyprctl activewindow -j | jq -r '.address')\" opaque toggle"),
"Toggle window transparency"
)
bind("SUPER + SHIFT + BACKSPACE", exec("station-hyprland-window-gaps-toggle"), "Toggle window gaps")
bind(
"SUPER + CTRL + Backspace",
exec("station-hyprland-window-single-square-aspect-toggle"),
"Toggle single-window square aspect"
)
bind("SUPER + SHIFT + BACKSPACE", function()
local gaps = hl.get_config("general.gaps_out")
if gaps.top == 0 then
hl.config({
general = {
gaps_out = 10,
gaps_in = 5,
border_size = 2,
},
})
else
hl.config({
general = {
gaps_out = 0,
gaps_in = 0,
border_size = 0,
},
})
end
end, "Toggle window gaps")
-- Notifications
bind("SUPER + COMMA", exec("makoctl dismiss"), "Dismiss last notification")
@@ -180,17 +243,16 @@ bind("SUPER + PRINT", exec("pkill hyprpicker || hyprpicker -a"), "Color picker")
-- bind("SUPER CTRL + S", exec("station-menu share"), "Share")
-- Waybar-less information
bind("SUPER + CTRL + ALT + T", exec('notify-send " $(date +"%A %H:%M — %d %B W%V %Y")"'), "Show time")
bind("SUPER + CTRL + ALT + T", exec('notify " $(date +"%A %H:%M — %d %B W%V %Y")"'), "Show time")
bind(
"SUPER + CTRL + ALT + B",
exec('notify-send "󰁹 Battery is at $(station-battery-remaining)%"'),
"Show battery remaining"
)
bind(
"SUPER + CTRL + ALT + W",
exec('notify-send "$(hyprctl activewindow -j | jq -r \'"Window: (.title)\nClass: (.class)"\')"'),
"Show active window name and class"
)
bind("SUPER + CTRL + ALT + W", function()
local window = hl.get_active_window()
notify("Window: " .. window.title .. "\nClass: " .. window.class)
end, "Show active window name and class")
-- Control panels
bind("SUPER + CTRL + A", exec("station-launch-audio"), "Audio controls")
@@ -1,15 +0,0 @@
#!/bin/bash
# Toggles the window gaps globally between no gaps and the default 10/5/2.
gaps=$(hyprctl getoption general:gaps_out -j | jq -r '.custom' | awk '{print $1}')
if [[ $gaps == "0" ]]; then
hyprctl keyword general:gaps_out 10
hyprctl keyword general:gaps_in 5
hyprctl keyword general:border_size 2
else
hyprctl keyword general:gaps_out 0
hyprctl keyword general:gaps_in 0
hyprctl keyword general:border_size 0
fi
-46
View File
@@ -1,46 +0,0 @@
#!/bin/bash
# Toggle to pop-out a tile to stay fixed on a display basis.
# Usage:
# station-hyprland-window-pop [width height [x y]]
#
# Arguments:
# width Optional. Width of the floating window. Default: 1300
# height Optional. Height of the floating window. Default: 900
# x Optional. X position of the window. Must provide both X and Y to take effect.
# y Optional. Y position of the window. Must provide both X and Y to take effect.
#
# Behavior:
# - If the window is already pinned, it will be unpinned and removed from the pop layer.
# - If the window is not pinned, it will be floated, resized, moved/centered, pinned, brought to top, and popped.
width=${1:-1300}
height=${2:-900}
x=${3:-}
y=${4:-}
active=$(hyprctl activewindow -j)
pinned=$(echo "$active" | jq ".pinned")
addr=$(echo "$active" | jq -r ".address")
if [[ $pinned == "true" ]]; then
hyprctl -q --batch \
"dispatch pin address:$addr;" \
"dispatch togglefloating address:$addr;" \
"dispatch tagwindow -pop address:$addr;"
elif [[ -n $addr ]]; then
hyprctl dispatch togglefloating address:$addr
hyprctl dispatch resizeactive exact $width $height address:$addr
if [[ -n $x && -n $y ]]; then
hyprctl dispatch moveactive $x $y address:$addr
else
hyprctl dispatch centerwindow address:$addr
fi
hyprctl -q --batch \
"dispatch pin address:$addr;" \
"dispatch alterzorder top address:$addr;" \
"dispatch tagwindow +pop address:$addr;"
fi
@@ -1,13 +0,0 @@
#!/bin/bash
# Check current single_window_aspect_ratio setting
CURRENT_VALUE=$(hyprctl getoption "layout:single_window_aspect_ratio" 2>/dev/null | head -1)
# Parse vec2 output: "vec2: [1, 1]" or "vec2: [0, 0]"
if [[ $CURRENT_VALUE == *"[1, 1]"* ]]; then
hyprctl keyword layout:single_window_aspect_ratio "0 0"
notify-send " Disable single-window square aspect ratio"
else
hyprctl keyword layout:single_window_aspect_ratio "1 1"
notify-send " Enable single-window square aspect"
fi
@@ -1,16 +0,0 @@
#!/bin/bash
# Toggle the layout on the current active workspace between dwindle and scrolling
ACTIVE_WORKSPACE=$(hyprctl activeworkspace -j | jq -r '.id')
CURRENT_LAYOUT=$(hyprctl activeworkspace -j | jq -r '.tiledLayout')
case "$CURRENT_LAYOUT" in
dwindle) NEW_LAYOUT=scrolling ;;
scrolling) NEW_LAYOUT=monocle ;;
monocle) NEW_LAYOUT=master ;;
*) NEW_LAYOUT=dwindle ;;
esac
hyprctl keyword workspace $ACTIVE_WORKSPACE, layout:$NEW_LAYOUT
notify-send "󱂬 Workspace layout set to $NEW_LAYOUT"