mirror of https://github.com/yshui/picom.git
picom-trans: add `--toggle` action to toggle between set opacity and unset.
Fixes: #472
This commit is contained in:
parent
c9ccd8fb71
commit
a854acc2d0
|
@ -21,6 +21,8 @@
|
||||||
# $ picom-trans -c +5
|
# $ picom-trans -c +5
|
||||||
# Delete current window's opacity
|
# Delete current window's opacity
|
||||||
# $ picom-trans -c --delete
|
# $ picom-trans -c --delete
|
||||||
|
# Toggle current window's opacity between 90 and unset
|
||||||
|
# $ picom-trans -c --toggle 90
|
||||||
# Reset all windows
|
# Reset all windows
|
||||||
# $ picom-trans --reset
|
# $ picom-trans --reset
|
||||||
print_usage() {
|
print_usage() {
|
||||||
|
@ -35,6 +37,8 @@ print_usage() {
|
||||||
echo "Actions:"
|
echo "Actions:"
|
||||||
echo " -g, --get Print the target window's opacity."
|
echo " -g, --get Print the target window's opacity."
|
||||||
echo " -d, --delete Delete opacity of the target window."
|
echo " -d, --delete Delete opacity of the target window."
|
||||||
|
echo " -t, --toggle Toggle the target window's opacity, i.e. set if not already set"
|
||||||
|
echo " and delete else."
|
||||||
echo " -r, --reset Reset opacity for all windows."
|
echo " -r, --reset Reset opacity for all windows."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Window Selection:"
|
echo "Window Selection:"
|
||||||
|
@ -87,10 +91,10 @@ while test $# -gt 0; do
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
|
|
||||||
# Read options
|
# Read options
|
||||||
while getopts 'hscrdgn:w:o:-:' option "$@"; do
|
while getopts 'hscrtdgn:w:o:-:' option "$@"; do
|
||||||
if test "$option" = '-'; then
|
if test "$option" = '-'; then
|
||||||
case "$OPTARG" in
|
case "$OPTARG" in
|
||||||
help | select | current | reset | delete | get)
|
help | select | current | reset | toggle | delete | get)
|
||||||
v=''
|
v=''
|
||||||
;;
|
;;
|
||||||
name | window | opacity)
|
name | window | opacity)
|
||||||
|
@ -117,6 +121,7 @@ while test $# -gt 0; do
|
||||||
wprefix='-id'; window=$active
|
wprefix='-id'; window=$active
|
||||||
;;
|
;;
|
||||||
r) action='reset' ;;
|
r) action='reset' ;;
|
||||||
|
t) action='toggle' ;;
|
||||||
d) action='delete' ;;
|
d) action='delete' ;;
|
||||||
g) action='get' ;;
|
g) action='get' ;;
|
||||||
n) wprefix='-name'; window=$OPTARG ;;
|
n) wprefix='-name'; window=$OPTARG ;;
|
||||||
|
@ -206,15 +211,17 @@ if test -z "$topmost"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get current opacity.
|
||||||
|
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
||||||
|
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
||||||
|
|
||||||
# Remove the opacity property.
|
# Remove the opacity property.
|
||||||
if test x"$action" = x'delete'; then
|
if test x"$action" = x'delete' -o \( x"$action" = x'toggle' -a -n "$cur" \); then
|
||||||
xprop -id "$topmost" -remove _NET_WM_WINDOW_OPACITY
|
xprop -id "$topmost" -remove _NET_WM_WINDOW_OPACITY
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get current opacity.
|
# Unset opacity equals fully opaque
|
||||||
cur=$(xprop -id "$topmost" -notype _NET_WM_WINDOW_OPACITY \
|
|
||||||
| sed 's/^.*\b\([0-9]\+\).*$\|^.*$/\1/')
|
|
||||||
test -z "$cur" && cur=0xffffffff
|
test -z "$cur" && cur=0xffffffff
|
||||||
cur=$((cur * 100 / 0xffffffff))
|
cur=$((cur * 100 / 0xffffffff))
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@ Print the target window's opacity instead of setting it.
|
||||||
*-d*, *--delete*::
|
*-d*, *--delete*::
|
||||||
Delete opacity of the target window instead of setting it.
|
Delete opacity of the target window instead of setting it.
|
||||||
|
|
||||||
|
*-t*, *--toggle*::
|
||||||
|
Toggle the target window's opacity: Set opacity if not already set, and delete if already set.
|
||||||
|
|
||||||
*-r*, *--reset*::
|
*-r*, *--reset*::
|
||||||
Reset opacity for all windows instead of setting it.
|
Reset opacity for all windows instead of setting it.
|
||||||
|
|
||||||
|
@ -90,6 +93,12 @@ picom-trans -c -- -5
|
||||||
picom-trans -c --delete
|
picom-trans -c --delete
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
* Toggle current window's opacity between 90 and unset
|
||||||
|
+
|
||||||
|
------------
|
||||||
|
picom-trans -c --toggle 90
|
||||||
|
------------
|
||||||
|
|
||||||
* Reset all windows:
|
* Reset all windows:
|
||||||
+
|
+
|
||||||
------------
|
------------
|
||||||
|
|
Loading…
Reference in New Issue