bootstrap and system config improvements
This commit is contained in:
parent
745075530c
commit
cce3b87edb
17 changed files with 513 additions and 141 deletions
147
scripts/hypr
147
scripts/hypr
|
|
@ -1,5 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
require() {
|
||||
for cmd in "$@"; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || {
|
||||
echo "hypr: missing dependency: $cmd" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: hypr <subcommand> [app] [args...]
|
||||
|
|
@ -9,7 +18,7 @@ Commands:
|
|||
brightness {up,down} Adjust brightness accordingly and notify
|
||||
spawnfocus <app> [args...] Focus existing window or spawn app with args
|
||||
pull [app] Pull window to current workspace (picker if no app)
|
||||
borders Initialize dynamic borders
|
||||
windowrules Apply dynamic window rules
|
||||
exit Safely exit hyprland
|
||||
|
||||
Options:
|
||||
|
|
@ -31,12 +40,14 @@ case "$cmd" in
|
|||
exit 0
|
||||
;;
|
||||
exit)
|
||||
require hyprctl
|
||||
pkill hypridle
|
||||
pkill hyprpaper
|
||||
hyprctl dispatch exit
|
||||
exit 0
|
||||
;;
|
||||
brightness)
|
||||
require brightnessctl notify-send
|
||||
BRIGHT_STEP=5
|
||||
max_brightness="$(brightnessctl max)"
|
||||
case "$1" in
|
||||
|
|
@ -55,6 +66,7 @@ brightness)
|
|||
esac
|
||||
;;
|
||||
volume)
|
||||
require pactl notify-send
|
||||
SINK="@DEFAULT_SINK@"
|
||||
VOL_STEP=5
|
||||
get_vol() { pactl get-sink-volume "$SINK" | awk 'NR==1{print $5+0}'; }
|
||||
|
|
@ -92,60 +104,72 @@ volume)
|
|||
fi
|
||||
;;
|
||||
pull)
|
||||
require hyprctl jq rofi
|
||||
APP="$1"
|
||||
if [ -n "$APP" ]; then
|
||||
case "$APP" in
|
||||
google-chrome | google-chrome-stable) CLASS="google-chrome" ;;
|
||||
chromium | ungoogled-chromium) CLASS="Chromium" ;;
|
||||
firefox) CLASS="firefox" ;;
|
||||
alacritty) CLASS="Alacritty" ;;
|
||||
code | vscodium) CLASS="Code" ;;
|
||||
signal-desktop | signal) CLASS="signal" ;;
|
||||
telegram-desktop | telegram) CLASS="TelegramDesktop" ;;
|
||||
ghostty) CLASS="com.mitchellh.ghostty" ;;
|
||||
bitwarden-desktop | bitwarden) CLASS="Bitwarden" ;;
|
||||
slack) CLASS="Slack" ;;
|
||||
discord) CLASS="discord" ;;
|
||||
vesktop) CLASS="vesktop" ;;
|
||||
*) CLASS="$APP" ;;
|
||||
esac
|
||||
CUR_ADDR=$(hyprctl -j activewindow | jq -r '.address')
|
||||
WIN_ADDRS=$(
|
||||
hyprctl -j clients 2>/dev/null | jq -r --arg class "$CLASS" '
|
||||
.[]? | select(
|
||||
((.xdgTag // "") | ascii_downcase | contains($class | ascii_downcase)) or
|
||||
((.initialClass // "") | ascii_downcase | contains($class | ascii_downcase)) or
|
||||
((.class // "") | ascii_downcase | contains($class | ascii_downcase))
|
||||
) | "\(.class)\t\(.title)\t\(.address)"'
|
||||
)
|
||||
WIN_COUNT=$(echo "$WIN_ADDRS" | grep -c .)
|
||||
if [ "$WIN_COUNT" -eq 1 ]; then
|
||||
WIN_ADDR=$(echo "$WIN_ADDRS" | awk -F'\t' '{print $3}')
|
||||
elif [ "$WIN_COUNT" -gt 1 ]; then
|
||||
SELECTED=$(echo "$WIN_ADDRS" |
|
||||
awk -F'\t' -v cur="$CUR_ADDR" '{if($3!=cur) print $1 ": " $2 "\t" $3}' |
|
||||
rofi -dmenu -i -p "pull window")
|
||||
WIN_ADDR=$(echo "$SELECTED" | awk -F'\t' '{print $2}')
|
||||
fi
|
||||
fi
|
||||
if [ -z "$SELECTED" ]; then
|
||||
case "$APP" in
|
||||
google-chrome | google-chrome-stable) CLASS="google-chrome" ;;
|
||||
zen | zen-browser) CLASS="zen" ;;
|
||||
chromium | ungoogled-chromium) CLASS="Chromium" ;;
|
||||
firefox) CLASS="firefox" ;;
|
||||
alacritty) CLASS="Alacritty" ;;
|
||||
code | vscodium) CLASS="Code" ;;
|
||||
signal-desktop | signal) CLASS="signal" ;;
|
||||
telegram-desktop | telegram) CLASS="TelegramDesktop" ;;
|
||||
ghostty) CLASS="com.mitchellh.ghostty" ;;
|
||||
bitwarden-desktop | bitwarden) CLASS="Bitwarden" ;;
|
||||
slack) CLASS="Slack" ;;
|
||||
discord) CLASS="discord" ;;
|
||||
vesktop) CLASS="vesktop" ;;
|
||||
element-desktop | element) CLASS="element" ;;
|
||||
*) CLASS="$APP" ;;
|
||||
esac
|
||||
|
||||
CUR_WS=$(hyprctl activeworkspace -j | jq -r '.id')
|
||||
|
||||
CUR_ADDR=$(hyprctl -j activewindow | jq -r '.address // empty')
|
||||
|
||||
WIN_ADDRS=$(hyprctl -j clients 2>/dev/null | jq -r --arg pat "$CLASS" '
|
||||
.[]?
|
||||
| select(
|
||||
(.class? | ascii_downcase | contains($pat | ascii_downcase)) or
|
||||
(.initialClass? | ascii_downcase | contains($pat | ascii_downcase)) or
|
||||
(.xdgTag? // "" | ascii_downcase | contains($pat | ascii_downcase))
|
||||
)
|
||||
| "\(.class)\t\(.title // "no title")\t\(.address)"
|
||||
')
|
||||
|
||||
WIN_COUNT=$(echo "$WIN_ADDRS" | grep -c '^' || :)
|
||||
|
||||
if [ "$WIN_COUNT" -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ -z "$WIN_ADDR" ]; then
|
||||
CUR_ADDR=$(hyprctl -j activewindow | jq -r '.address')
|
||||
WIN_ADDRS=$(hyprctl -j clients 2>/dev/null | jq -r '.[]? | "\(.class)\t\(.title)\t\(.address)"')
|
||||
SELECTED=$(echo "$WIN_ADDRS" |
|
||||
awk -F'\t' -v cur="$CUR_ADDR" '{if($3!=cur) print $1 ": " $2 "\t" $3}' |
|
||||
rofi -dmenu -i -p "pull window")
|
||||
|
||||
if [ "$WIN_COUNT" -eq 1 ]; then
|
||||
WIN_ADDR=$(echo "$WIN_ADDRS" | awk -F'\t' '{print $3}')
|
||||
else
|
||||
ROFI_LINES=$(
|
||||
echo "$WIN_ADDRS" |
|
||||
awk -F'\t' -v cur="$CUR_ADDR" '
|
||||
$3 != cur { printf "%s : %s\t%s\n", $1, $2, $3 }
|
||||
'
|
||||
)
|
||||
|
||||
[ -z "$ROFI_LINES" ] && exit 0
|
||||
|
||||
SELECTED=$(echo "$ROFI_LINES" | rofi -dmenu -i -p "pull window")
|
||||
|
||||
[ -z "$SELECTED" ] && exit 0
|
||||
|
||||
WIN_ADDR=$(echo "$SELECTED" | awk -F'\t' '{print $2}')
|
||||
fi
|
||||
if [ -n "$WIN_ADDR" ]; then
|
||||
CURRENT_WS="$(hyprctl activeworkspace | head -n1 | awk -F'[()]' '{print $2}')"
|
||||
hyprctl dispatch movetoworkspace "$CURRENT_WS,address:$WIN_ADDR"
|
||||
hyprctl dispatch focuswindow "address:$WIN_ADDR"
|
||||
fi
|
||||
|
||||
[ -z "$WIN_ADDR" ] && exit 0
|
||||
|
||||
hyprctl dispatch movetoworkspace "${CUR_WS},address:${WIN_ADDR}"
|
||||
hyprctl dispatch focuswindow "address:${WIN_ADDR}"
|
||||
;;
|
||||
spawnfocus)
|
||||
require hyprctl jq rofi socat
|
||||
WS=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
|
|
@ -177,6 +201,7 @@ spawnfocus)
|
|||
case "$APP" in
|
||||
google-chrome | google-chrome-stable) CLASS="google-chrome" ;;
|
||||
chromium | ungoogled-chromium) CLASS="Chromium" ;;
|
||||
zen | zen-browser) CLASS="zen" ;;
|
||||
firefox) CLASS="firefox" ;;
|
||||
alacritty) CLASS="Alacritty" ;;
|
||||
code | vscodium) CLASS="Code" ;;
|
||||
|
|
@ -187,6 +212,7 @@ spawnfocus)
|
|||
slack) CLASS="Slack" ;;
|
||||
discord) CLASS="discord" ;;
|
||||
vesktop) CLASS="vesktop" ;;
|
||||
element-desktop | element) CLASS="element" ;;
|
||||
*) CLASS="$APP" ;;
|
||||
esac
|
||||
|
||||
|
|
@ -275,6 +301,31 @@ spawnfocus)
|
|||
done
|
||||
fi
|
||||
;;
|
||||
windowrules)
|
||||
require hyprctl socat
|
||||
socat -u UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" - | while IFS= read -r line; do
|
||||
event="${line%%>>*}"
|
||||
data="${line#*>>}"
|
||||
case "$event" in
|
||||
windowtitlev2)
|
||||
window_id="${data%%,*}"
|
||||
window_title="${data#*,}"
|
||||
window_title=$(echo "$window_title" | tr '[:upper:]' '[:lower:]')
|
||||
case "$window_title" in
|
||||
*'extension: (bitwarden password manager) - bitwarden'*)
|
||||
hyprctl --batch "dispatch setfloating address:0x$window_id; dispatch centerwindow address:0x$window_id"
|
||||
;;
|
||||
*'sign in - google accounts '*)
|
||||
hyprctl --batch "dispatch setfloating address:0x$window_id; \
|
||||
dispatch resizewindowpixel exact 30% 70%,address:0x$window_id; \
|
||||
dispatch centerwindow address:0x$window_id"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown subcommand: $cmd"
|
||||
usage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue