compton-trans: add a 'get' option.
This commit is contained in:
parent
86b20e0a08
commit
ad23872801
|
@ -32,7 +32,7 @@ wprefix=
|
|||
window=
|
||||
opacity=
|
||||
cur=
|
||||
delete=
|
||||
action=
|
||||
treeout=
|
||||
wid=
|
||||
topmost=
|
||||
|
@ -48,7 +48,7 @@ while test $# -gt 0; do
|
|||
LASTIND=1
|
||||
|
||||
# Read options
|
||||
while getopts ':scdn:w:o:' option "$@"; do
|
||||
while getopts ':scdgn:w:o:' option "$@"; do
|
||||
case "$option" in
|
||||
s) wprefix=''; window='' ;;
|
||||
c)
|
||||
|
@ -56,7 +56,8 @@ while test $# -gt 0; do
|
|||
| sed 's/^.*\(0x\S*\).*$/\1/')
|
||||
wprefix='-id'; window=$active
|
||||
;;
|
||||
d) delete=1 ;;
|
||||
d) action='delete' ;;
|
||||
g) action='get' ;;
|
||||
n) wprefix='-name'; window=$OPTARG ;;
|
||||
w) wprefix='-id'; window=$OPTARG ;;
|
||||
o) opacity=$OPTARG ;;
|
||||
|
@ -81,7 +82,7 @@ done
|
|||
opacity=$(echo "$opacity" | sed 's/%//g' | xargs)
|
||||
|
||||
# Validate opacity value
|
||||
if test -z "$delete" && ! echo "$opacity" | grep -q '^[+-]\?[0-9]\+$'; then
|
||||
if test -z "$action" && ! echo "$opacity" | grep -q '^[+-]\?[0-9]\+$'; then
|
||||
echo "Invalid opacity specified: $opacity."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -140,17 +141,25 @@ if test -z "$topmost"; then
|
|||
fi
|
||||
|
||||
# Remove the opacity property.
|
||||
if test -n "$delete"; then
|
||||
if test x"$action" = x'delete'; then
|
||||
xprop -id "$topmost" -remove _NET_WM_WINDOW_OPACITY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get current opacity.
|
||||
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
||||
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
||||
test -z "$cur" && cur=0xffffffff
|
||||
cur=$((cur * 100 / 0xffffffff))
|
||||
|
||||
# Output current opacity.
|
||||
if test x"$action" = x'get'; then
|
||||
echo "$cur"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Calculate the desired opacity
|
||||
if echo "$opacity" | grep -q '^[+-]'; then
|
||||
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
||||
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
||||
test -z "$cur" && cur=0xffffffff
|
||||
cur=$((cur * 100 / 0xffffffff))
|
||||
opacity=$(($cur + $opacity))
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue