Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 33 lines (28 sloc) 891 Bytes
#!/bin/bash
##
# Wrapper around dzen2 that allows width and x to be defined as a screen
# percentage. The percentage width is define via the new '-wp' arg and
# percentage x as -xp, both of which must be supplied before any other dzen
# arguments.
#
# $ dzen2 -wp 30 -xp 60 ...
##
external="^\(VGA\|DVI\|DP\|HDMI\)-\?[0-9]\+"
internal="^\(eDP\|LVDS\)-\?[0-9]\+"
pattern="connected \(primary \)\?\([0-9]\+\)x.*$"
width=$(xrandr 2> /dev/null | grep "$external $pattern" | sed "s/$external $pattern/\3/")
if [ -z "$width" ] ; then
width=$(xrandr 2> /dev/null | grep "$internal $pattern" | sed "s/$internal $pattern/\3/")
fi
while [ 1 ] ; do
if [ "$1" == "-wp" ] ; then
arg="$arg -w `expr $(expr $width '*' $2) / 100`"
elif [ "$1" == "-xp" ] ; then
arg="$arg -x `expr $(expr $width '*' $2) / 100`"
else
break
fi
shift
shift
done
cat - | /usr/bin/dzen2 $arg "$@"