mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
compton-trans: cleanup. add remove-prop option.
This commit is contained in:
parent
054d343622
commit
25d31a1f5e
1 changed files with 21 additions and 14 deletions
|
@ -25,13 +25,19 @@ if test -z "$(command -v xprop)" -o -z "$(command -v xwininfo)"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
wprefix=
|
||||||
window=
|
window=
|
||||||
opacity=
|
opacity=
|
||||||
cur=
|
cur=
|
||||||
i=
|
delete=
|
||||||
|
treeout=
|
||||||
|
wid=
|
||||||
|
topmost=
|
||||||
|
lineno=
|
||||||
|
|
||||||
# Read options
|
# Read options
|
||||||
while getopts 'scn:w:o:' option; do
|
while getopts 'scdn:w:o:' option; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
s) wprefix=''; window='' ;;
|
s) wprefix=''; window='' ;;
|
||||||
c)
|
c)
|
||||||
|
@ -39,6 +45,7 @@ while getopts 'scn:w:o:' option; do
|
||||||
| sed 's/^.*\(0x\S*\).*$/\1/')
|
| sed 's/^.*\(0x\S*\).*$/\1/')
|
||||||
wprefix='-id'; window=$active
|
wprefix='-id'; window=$active
|
||||||
;;
|
;;
|
||||||
|
d) delete=1 ;;
|
||||||
n) wprefix='-name'; window=$OPTARG ;;
|
n) wprefix='-name'; window=$OPTARG ;;
|
||||||
w) wprefix='-id'; window=$OPTARG ;;
|
w) wprefix='-id'; window=$OPTARG ;;
|
||||||
o) opacity=$OPTARG ;;
|
o) opacity=$OPTARG ;;
|
||||||
|
@ -50,18 +57,12 @@ done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
test -n "$1" && opacity=$1
|
test -n "$1" && opacity=$1
|
||||||
|
|
||||||
# Validate opacity value
|
|
||||||
if test -z "$opacity"; then
|
|
||||||
echo 'No opacity specified.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# clean up opacity. xargs == a poor man's trim.
|
# clean up opacity. xargs == a poor man's trim.
|
||||||
opacity=$(echo "$opacity" | sed 's/%//g' | xargs)
|
opacity=$(echo "$opacity" | sed 's/%//g' | xargs)
|
||||||
#opacity=$(echo "$opacity" | sed 's/%//g' | sed 's/^ \+\| \+$//g')
|
|
||||||
|
|
||||||
if test -z "$opacity"; then
|
# Validate opacity value
|
||||||
echo 'Invalid opacity value.'
|
if test -z "$opacity" -a -z "$delete"; then
|
||||||
|
echo 'No opacity specified.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -80,13 +81,13 @@ if test -z "$wid"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure it's not root window
|
# Make sure it's not root window
|
||||||
if echo "$treeout" | fgrep 'Parent window id: 0x0' > /dev/null; then
|
if echo "$treeout" | fgrep -q 'Parent window id: 0x0'; then
|
||||||
echo 'Cannot set opacity on root window.'
|
echo 'Cannot set opacity on root window.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If it's already the topmost window
|
# If it's already the topmost window
|
||||||
if echo "$treeout" | grep 'Parent window id: 0x[[:xdigit:]]* (the root window)' > /dev/null; then
|
if echo "$treeout" | grep -q 'Parent window id: 0x[[:xdigit:]]* (the root window)'; then
|
||||||
topmost=$wid
|
topmost=$wid
|
||||||
else
|
else
|
||||||
# Get the whole window tree
|
# Get the whole window tree
|
||||||
|
@ -118,8 +119,14 @@ if test -z "$topmost"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Remove the opacity property.
|
||||||
|
if test -n "$delete"; then
|
||||||
|
xprop -id "$topmost" -remove _NET_WM_WINDOW_OPACITY
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Calculate the desired opacity
|
# Calculate the desired opacity
|
||||||
if echo "$opacity" | grep '^[+-]' > /dev/null; then
|
if echo "$opacity" | grep -q '^[+-]'; then
|
||||||
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
||||||
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
||||||
test -z "$cur" && cur=0xffffffff
|
test -z "$cur" && cur=0xffffffff
|
||||||
|
|
Loading…
Reference in a new issue