Merge branch 'master' into richardgv-dev

Conflicts:
	bin/compton-trans
	man/compton-trans.1

- Add some explaination in README.md.

- Rename CMakeLists.txt to _CMakeLists.txt to avoid confusion.
This commit is contained in:
Richard Grenville 2012-11-14 18:42:09 +08:00
commit 62ea373ee5
4 changed files with 69 additions and 54 deletions

View File

@ -57,13 +57,21 @@ __R__ for runtime
* libGL (B,R) (Will probably be made optional soon) * libGL (B,R) (Will probably be made optional soon)
* asciidoc (B) (if you wish to run `make docs`) * asciidoc (B) (if you wish to run `make docs`)
To build, make sure you have the above dependencies: ### How to build
To build, make sure you have the dependencies above:
``` bash ``` bash
# Make the main program
$ make $ make
# Make the newer man pages
$ make docs
# Install
$ make install $ make install
``` ```
(Compton does include a `_CMakeLists.txt` in the tree, but we haven't decided whether we should switch to CMake yet. The `Makefile` is fully usable right now.)
## Example Usage ## Example Usage
``` bash ``` bash

View File

@ -1,19 +1,23 @@
#!/bin/bash #!/bin/bash
#
# compton-trans
# transset in a bash script # transset in a bash script
# Copyright (c) 2011-2012, Christopher Jeffrey # Copyright (c) 2011-2012, Christopher Jeffrey
#
# Usage: # Usage:
# by window id # By window id
# settrans -w "$WINDOWID" -o 75 # $ compton-trans -w "$WINDOWID" 75
# by name # By name
# settrans -n "urxvt" -o 75 # $ compton-trans -n "urxvt" 75
# by current window # By current window
# settrans -c -o 75 # $ compton-trans -c 75
# by selection # By selection
# settrans -s -o 75 # $ compton-trans 75
# increment current window 5% # $ compton-trans -s 75
# settrans -c -o +5 # Increment current window 5%
# $ compton-trans -c +5
# "command" is a shell built-in, faster than "which" # "command" is a shell built-in, faster than "which"
if test -z "$(command -v xprop)" -o -z "$(command -v xwininfo)"; then if test -z "$(command -v xprop)" -o -z "$(command -v xwininfo)"; then
@ -48,77 +52,77 @@ shift $(($OPTIND - 1))
# Validate opacity value # Validate opacity value
if [ -z "$opacity" ]; then if [ -z "$opacity" ]; then
echo "No opacity specified." echo "No opacity specified."
exit 1 exit 1
fi fi
opacity="$(echo "$opacity" \ opacity="$(echo "$opacity" \
| sed -rn 's/^[[:space:]]*([+-]?[[:digit:]]+)[[:space:]]*$/\1/p')" | sed -rn 's/^[[:space:]]*([+-]?[[:digit:]]+)[[:space:]]*$/\1/p')"
if [ -z "$opacity" ]; then if [ -z "$opacity" ]; then
echo "Invalid opacity value." echo "Invalid opacity value."
exit 1 exit 1
fi fi
# Get ID of the target window # Get ID of the target window
if [ -z "$wprefix" ]; then if [ -z "$wprefix" ]; then
treeout=$(xwininfo -children -frame) treeout=$(xwininfo -children -frame)
else else
treeout=$(xwininfo -children $wprefix"$window") treeout=$(xwininfo -children $wprefix"$window")
fi fi
wid=$(echo "$treeout" | sed -n 's/^xwininfo:.*: \(0x[[:xdigit:]]*\).*$/\1/p') wid=$(echo "$treeout" | sed -n 's/^xwininfo:.*: \(0x[[:xdigit:]]*\).*$/\1/p')
if [ -z "$wid" ]; then if [ -z "$wid" ]; then
echo "Failed to find window." echo "Failed to find window."
exit 1 exit 1
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 "Parent window id: 0x0" > /dev/null; 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 "Parent window id: 0x[[:xdigit:]]* (the root window)" > /dev/null; then
topmost="$wid" topmost="$wid"
else else
# Get the whole window tree # Get the whole window tree
treeout="$(xwininfo -root -tree)" treeout="$(xwininfo -root -tree)"
if [ -z "$treeout" ]; then if [ -z "$treeout" ]; then
echo "Failed to get root window tree." echo "Failed to get root window tree."
exit 1 exit 1
fi fi
# Find the line number of the target window in the window tree # Find the line number of the target window in the window tree
lineno="$(echo -n "$treeout" | grep -nw "$wid" | head -n1 | cut -d ':' -f 1)" lineno="$(echo -n "$treeout" | grep -nw "$wid" | head -n1 | cut -d ':' -f 1)"
if [ -z "$lineno" ]; then if [ -z "$lineno" ]; then
echo "Failed to find window in window tree." echo "Failed to find window in window tree."
exit 1 exit 1
fi fi
# Find the highest ancestor of the target window below # Find the highest ancestor of the target window below
topmost=$(echo -n "$treeout" | head -n $(($lineno + 1)) | sed -n 's/^ \(0x[[:xdigit:]]*\).*/\1/p' | tail -n1) topmost=$(echo -n "$treeout" | head -n $(($lineno + 1)) | sed -n 's/^ \(0x[[:xdigit:]]*\).*/\1/p' | tail -n1)
fi fi
if [ -z "$topmost" ]; then if [ -z "$topmost" ]; then
echo "Failed to find the highest parent window below root of the" \ echo "Failed to find the highest parent window below root of the" \
"selected window." "selected window."
exit 1 exit 1
fi fi
# Calculate the desired opacity # Calculate the desired opacity
if echo "$opacity" | grep '^[+-]' > /dev/null; then if echo "$opacity" | grep '^[+-]' > /dev/null; then
sign=$(echo "$opacity" | cut -b1) sign=$(echo "$opacity" | cut -b1)
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/')
[ -z "$cur" ] && cur=0xffffffff [ -z "$cur" ] && cur=0xffffffff
cur=$((cur * 100 / 0xffffffff)) cur=$((cur * 100 / 0xffffffff))
opacity="$(echo "$opacity" | sed 's/^[+-]//')" opacity="$(echo "$opacity" | sed 's/^[+-]//')"
opacity=$(($cur $sign $opacity)) opacity=$(($cur $sign $opacity))
fi fi
[ $opacity -lt 0 ] && opacity=0 [ $opacity -lt 0 ] && opacity=0
@ -127,4 +131,4 @@ fi
# Set opacity # Set opacity
opacity=$(($opacity * 0xffffffff / 100)) opacity=$(($opacity * 0xffffffff / 100))
xprop -id "$topmost" -f _NET_WM_WINDOW_OPACITY 32c \ xprop -id "$topmost" -f _NET_WM_WINDOW_OPACITY 32c \
-set _NET_WM_WINDOW_OPACITY "$opacity" -set _NET_WM_WINDOW_OPACITY "$opacity"

View File

@ -39,19 +39,22 @@ target window's current opacity instead.
.SH EXAMPLES .SH EXAMPLES
.TP .TP
Set window id to opacity of 75%. Set window id to opacity of 75%.
compton-trans -w "$WINDOWID" -o 75 compton-trans -w "$WINDOWID" 75
.TP .TP
Set window name, "urxvt", to opacity of 75%. Set window name, "urxvt", to opacity of 75%.
compton-trans -n "urxvt" -o 75 compton-trans -n "urxvt" 75
.TP .TP
Set current window to opacity of 75%. Set current window to opacity of 75%.
compton-trans -c -o 75 compton-trans -c 75
.TP .TP
Select target window and set opacity to 75%. Select target window and set opacity to 75%.
compton-trans -s -o 75 compton-trans -s 75
.TP .TP
Increment current window 5% opacity. Increment current window opacity by 5%.
compton-trans -c -o +5 compton-trans -c +5
.TP
Decrement current window opacity by 5%.
compton-trans -c -- -5
.SH BUGS .SH BUGS
Please report any you find to https://github.com/chjj/compton. Please report any you find to https://github.com/chjj/compton.