From 7833b3712ffb2a12b8c852219d1329f96f9be167 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 7 Jan 2023 03:22:00 -0500 Subject: [PATCH] sxhkd: Add separate kitty launch script This made it possible to control the opacity of the terminal with sxhkd keybinds. --- sxhkd/.config/sxhkd/kitty-next.sh | 23 +++++++++++++++++++++++ sxhkd/.config/sxhkd/kitty.sh | 10 ++++++++++ 2 files changed, 33 insertions(+) create mode 100755 sxhkd/.config/sxhkd/kitty-next.sh create mode 100755 sxhkd/.config/sxhkd/kitty.sh diff --git a/sxhkd/.config/sxhkd/kitty-next.sh b/sxhkd/.config/sxhkd/kitty-next.sh new file mode 100755 index 00000000..cd53b724 --- /dev/null +++ b/sxhkd/.config/sxhkd/kitty-next.sh @@ -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")) diff --git a/sxhkd/.config/sxhkd/kitty.sh b/sxhkd/.config/sxhkd/kitty.sh new file mode 100755 index 00000000..8b9d86a8 --- /dev/null +++ b/sxhkd/.config/sxhkd/kitty.sh @@ -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