1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00
picom/settrans

81 lines
1.7 KiB
Text
Raw Normal View History

2011-12-07 13:35:22 -05:00
#!/bin/bash
# transset in a bash script
2012-02-06 03:16:49 -05:00
# copyright (c) 2011-2012, christopher jeffrey
2011-12-07 13:35:22 -05:00
# usage:
# by window id
#trans -w "$WINDOWID" -o 75
# by name
#trans -n "urxvt" -o 75
# by current window
#trans -c -o 75
# by selection
#trans -s -o 75
2011-12-21 14:28:55 -05:00
# increment current window 5%
#trans -c -o +5
2011-12-07 13:35:22 -05:00
2011-12-21 14:28:55 -05:00
if [ -z "$(which xprop)" -o -z "$(which xwininfo)" ]; then
echo "Please install x11-utils/xorg-xprop/xorg-xwininfo." >&2
exit 1
fi
2011-12-07 13:35:22 -05:00
window=
opacity=
cur=
root=
parent=
active=
2012-02-06 03:16:49 -05:00
while getopts "scn:w:o:" option; do
case "$option" in
2011-12-07 13:35:22 -05:00
s) window="" ;;
c)
2011-12-21 14:28:55 -05:00
active=$(xprop -root -notype "_NET_ACTIVE_WINDOW" \
2011-12-07 13:35:22 -05:00
| sed 's/^.*\(0x\S*\).*$/\1/')
window="-id $active"
;;
n) window="-name $OPTARG" ;;
w) window="-id $OPTARG" ;;
o) opacity="$OPTARG" ;;
esac
done
root=$(xwininfo -all -root \
| grep "Root window id" \
| sed 's/^.*\(0x\S*\).*$/\1/')
2011-12-21 14:28:55 -05:00
parent=$window
while [ true ]; do
parent=$(xwininfo -all $parent \
| grep Parent \
| sed 's/^.*\(0x\S*\).*$/\1/')
if [ "$parent" = "$root" ]; then
break
fi
parent="-id $parent"
window=$parent
done
2011-12-07 13:35:22 -05:00
inc=$(echo "$opacity" | sed 's/^\(+\|-\).*$\|^.*$/\1/')
if [ -n "$inc" ]; then
cur=$(xprop $window -notype "_NET_WM_WINDOW_OPACITY" \
2011-12-21 14:28:55 -05:00
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
2011-12-07 13:35:22 -05:00
[ -z "$cur" ] && cur=$((0xffffffff))
cur=$((cur*100/0xffffffff))
opacity=$(echo "$opacity" | sed 's/\(\+\|\-\)//')
if [ "$inc" = "+" ]; then
opacity=$((cur+opacity))
else
opacity=$((cur-opacity))
fi
fi
if [ -n "$opacity" ] && [ -n "$window" ]; then
[ $opacity -le 0 ] && opacity=0
[ $opacity -ge 100 ] && opacity=100
opacity=$((opacity*0xffffffff/100))
xprop $window -f _NET_WM_WINDOW_OPACITY 32c \
-set _NET_WM_WINDOW_OPACITY "$opacity"
fi