1
0
forked from extern/nix-config

sxhkd: Add separate kitty launch script

This made it possible to control the opacity of the terminal with sxhkd
keybinds.
This commit is contained in:
Donovan Glover 2023-01-07 03:22:00 -05:00
parent ba5675586a
commit 7833b3712f
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/bin/sh
SOCK=$(fd kitty --base-directory /tmp -d 1)
KITTY=$(xdotool search --class kitty)
[ -e "/tmp/opacity-of-terminal" ] || echo 0.9 > /tmp/opacity-of-terminal
[ "$1" == "up" ] && \
NEXT=$(fish -N -c "math (cat /tmp/opacity-of-terminal) + 0.02") ||
NEXT=$(fish -N -c "math (cat /tmp/opacity-of-terminal) - 0.02")
[ "$1" == "up" ] && [ "$(cat /tmp/opacity-of-terminal)" == "1" ] && NEXT=1
[ "$1" == "down" ] && [ "$(cat /tmp/opacity-of-terminal)" == "0" ] && NEXT=0
echo "$NEXT" > /tmp/opacity-of-terminal
[ "$1" == "up" ] && \
notify-send -t 1000 "kitty" "Increased opacity to $NEXT" ||
notify-send -t 1000 "kitty" "Decreased opacity to $NEXT"
[ -n "$KITTY" ] && \
([ -e "/tmp/$SOCK" ] && \
(kitty @ --to "unix:/tmp/$SOCK" set-background-opacity "$NEXT"))

10
sxhkd/.config/sxhkd/kitty.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
SOCK=$(fd kitty --base-directory /tmp -d 1)
KITTY=$(xdotool search --class kitty)
[ -n "$KITTY" ] && \
([ -e "/tmp/$SOCK" ] && \
(kitty @ --to "unix:/tmp/$SOCK" launch --type=tab && \
bspc node $KITTY -f)) \
|| kitty --single-instance --start-as maximized