From c9ccd8fb714e02bb123bad1d8e83ef1713180763 Mon Sep 17 00:00:00 2001 From: Bernd Busse Date: Thu, 22 Oct 2020 22:48:59 +0200 Subject: [PATCH] picom-trans: Add inline `--help` output and update manpage Fixes: #513 --- bin/picom-trans | 30 ++++++++++++++++++++++++++++-- man/picom-trans.1.asciidoc | 33 +++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/bin/picom-trans b/bin/picom-trans index 331487c..b72fb2f 100755 --- a/bin/picom-trans +++ b/bin/picom-trans @@ -23,6 +23,26 @@ # $ picom-trans -c --delete # Reset all windows # $ picom-trans --reset +print_usage() { + echo "Usage: $0 [options] [+|-]opacity" + echo "" + echo "Options:" + echo " -h, --help Print this help message." + echo " -o, --opacity OPACITY Specify the new opacity value in range 1-100 for the window. If" + echo " prefixed with + or -, increment or decrement from the target" + echo " window’s current opacity." + echo "" + echo "Actions:" + echo " -g, --get Print the target window's opacity." + echo " -d, --delete Delete opacity of the target window." + echo " -r, --reset Reset opacity for all windows." + echo "" + echo "Window Selection:" + echo " -s, --select Select target window with mouse cursor. (DEFAULT)" + echo " -c, --current Select the currently active window as target." + echo " -n, --name WINDOW_NAME Specify and try to match a window name." + echo " -w, --window WINDOW_ID Specify the window id of the target window." +} case "$0" in *compton-trans*) echo "Warning: compton has been renamed, please use picom-trans instead" >& 2;; @@ -34,6 +54,11 @@ if test -z "$(command -v xprop)" -o -z "$(command -v xwininfo)"; then exit 1 fi +if test $# -eq 0; then + print_usage >& 2 + exit 1 +fi + # Variables active= wprefix= @@ -62,10 +87,10 @@ while test $# -gt 0; do OPTIND=1 # Read options - while getopts 'scrdgn:w:o:-:' option "$@"; do + while getopts 'hscrdgn:w:o:-:' option "$@"; do if test "$option" = '-'; then case "$OPTARG" in - select | current | reset | delete | get) + help | select | current | reset | delete | get) v='' ;; name | window | opacity) @@ -84,6 +109,7 @@ while test $# -gt 0; do OPTARG=$v fi case "$option" in + h) print_usage; exit 0 ;; s) wprefix=''; window='' ;; c) active=$(xprop -root -notype _NET_ACTIVE_WINDOW \ diff --git a/man/picom-trans.1.asciidoc b/man/picom-trans.1.asciidoc index 81bd7f7..d77087e 100644 --- a/man/picom-trans.1.asciidoc +++ b/man/picom-trans.1.asciidoc @@ -21,20 +21,29 @@ DESCRIPTION OPTIONS ------- -*-w* 'WINDOW_ID':: +*-w*, *--window*='WINDOW_ID':: Specify the window id of the target window. -*-n* 'WINDOW_NAME':: +*-n*, *--name*='WINDOW_NAME':: Specify and try to match a window name. -*-c*:: +*-c*, *--current*:: Specify the currently active window as target. Only works if EWMH '_NET_ACTIVE_WINDOW' property exists on root window. -*-s*:: +*-s*, *--select*:: Select target window with mouse cursor. This is the default if no window has been specified. -*-o* 'OPACITY':: -Specify the new opacity value for the window. This value can be anywhere from 1-100. If it is prefixed with a plus or minus (+/-), this will increment or decrement from the target window's current opacity instead. +*-o*, *--opacity*='OPACITY':: +Specify the new opacity value for the window. This value can be anywhere from 1-100. If it is prefixed with a plus or minus (+/-), this will increment or decrement from the target window's current opacity instead. + +*-g*, *--get*:: +Print the target window's opacity instead of setting it. + +*-d*, *--delete*:: +Delete opacity of the target window instead of setting it. + +*-r*, *--reset*:: +Reset opacity for all windows instead of setting it. EXAMPLES -------- @@ -75,6 +84,18 @@ picom-trans -c +5 picom-trans -c -- -5 ------------ +* Delete current window's opacity: ++ +------------ +picom-trans -c --delete +------------ + +* Reset all windows: ++ +------------ +picom-trans --reset +------------ + BUGS ---- Please submit bug reports to .