Skip to content

Instantly share code, notes, and snippets.

@dre1080
Created August 7, 2025 11:41
Show Gist options
  • Select an option

  • Save dre1080/7f50c20e18629733c852a40e31471f9c to your computer and use it in GitHub Desktop.

Select an option

Save dre1080/7f50c20e18629733c852a40e31471f9c to your computer and use it in GitHub Desktop.
hyprland helper scripts
env = KEYBOARD_STATUS_FILE,$XDG_RUNTIME_DIR/keyboard.status
exec-once = rm -f $KEYBOARD_STATUS_FILE
device {
name = at-translated-set-2-keyboard
enabled = true
}
#!/usr/bin/env bash
enable_keyboard() {
printf "true" >"$KEYBOARD_STATUS_FILE"
notify-send -u normal "Enabling Keyboard"
hyprctl -r -- keyword device[at-translated-set-2-keyboard]:enabled true
}
disable_keyboard() {
printf "false" >"$KEYBOARD_STATUS_FILE"
notify-send -u normal "Disabling Keyboard"
hyprctl -r -- keyword device[at-translated-set-2-keyboard]:enabled false
}
if ! [ -f "$KEYBOARD_STATUS_FILE" ]; then
disable_keyboard
else
if [ $(cat "$KEYBOARD_STATUS_FILE") = "true" ]; then
disable_keyboard
elif [ $(cat "$KEYBOARD_STATUS_FILE") = "false" ]; then
enable_keyboard
fi
fi
#!/bin/sh
# Toggles the active window between PiP and tiled.
IS_FLOATING=$(hyprctl activewindow -j | jq -r .floating)
if [ "$IS_FLOATING" = "true" ]; then
notify-send -u normal "PiP mode deactivated"
hyprctl dispatch settiled active
else
MON_ID=$(hyprctl activewindow -j | jq -r .monitor)
MON_W=$(hyprctl monitors -j | jq -r .["$MON_ID"].width)
MON_H=$(hyprctl monitors -j | jq -r .["$MON_ID"].height)
MON_X=$(hyprctl monitors -j | jq -r .["$MON_ID"].x)
MON_Y=$(hyprctl monitors -j | jq -r .["$MON_ID"].y)
WIN_W=384
WIN_H=216
POS_X=$(( MON_X + MON_W - WIN_W - 10 ))
POS_Y=$(( MON_Y + MON_H - WIN_H - 10 ))
notify-send -u normal "PiP mode activated"
hyprctl dispatch setfloating active
hyprctl dispatch pin active
hyprctl dispatch resizeactive exact "$WIN_W" "$WIN_H"
hyprctl dispatch moveactive exact "$POS_X" "$POS_Y"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment