herbstluftwm: fix all-gray workspaces on unfocused monitor instead of
colored for focused
This commit is contained in:
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
# hc is shorter than herbstclient :)
|
# hc is shorter than herbstclient :)
|
||||||
hc() {
|
hc() {
|
||||||
herbstclient "$@"
|
herbstclient "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# set mod keys
|
# set mod keys
|
||||||
@ -92,9 +92,9 @@ hc keybind "$M-m" cycle_monitor
|
|||||||
|
|
||||||
# cycle layouts
|
# cycle layouts
|
||||||
hc keybind "$M-Tab" \
|
hc keybind "$M-Tab" \
|
||||||
or , and . compare tags.focus.curframe_wcount = 2 \
|
or , and . compare tags.focus.curframe_wcount = 2 \
|
||||||
. cycle_layout +1 vertical horizontal max vertical grid \
|
. cycle_layout +1 vertical horizontal max vertical grid \
|
||||||
, cycle_layout +1
|
, cycle_layout +1
|
||||||
|
|
||||||
# rotate and mirror
|
# rotate and mirror
|
||||||
hc keybind "$M-apostrophe" mirror vertical
|
hc keybind "$M-apostrophe" mirror vertical
|
||||||
@ -148,12 +148,12 @@ tag_keys=(a s d f g z x c v b)
|
|||||||
|
|
||||||
hc rename default "${tag_names[0]}" || true
|
hc rename default "${tag_names[0]}" || true
|
||||||
for i in "${!tag_names[@]}"; do
|
for i in "${!tag_names[@]}"; do
|
||||||
hc add "${tag_names[$i]}"
|
hc add "${tag_names[$i]}"
|
||||||
key="${tag_keys[$i]}"
|
key="${tag_keys[$i]}"
|
||||||
if ! [ -z "$key" ]; then
|
if ! [ -z "$key" ]; then
|
||||||
hc keybind "$M-$key" use_index $i
|
hc keybind "$M-$key" use_index $i
|
||||||
hc keybind "$M-$S-$key" move_index $i
|
hc keybind "$M-$S-$key" move_index $i
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -218,7 +218,6 @@ for monitor in $(hc list_monitors | cut -d: -f1); do
|
|||||||
"$panel" "$monitor" &
|
"$panel" "$monitor" &
|
||||||
done
|
done
|
||||||
|
|
||||||
picom --experimental-backends &
|
|
||||||
pidof dunst || dunst &
|
pidof dunst || dunst &
|
||||||
pidof mpd || mpd &
|
pidof mpd || mpd &
|
||||||
pidof flameshot || flameshot &
|
pidof flameshot || flameshot &
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
. "${HOME}/.cache/wal/colors.sh"
|
. "${HOME}/.cache/wal/colors.sh"
|
||||||
|
|
||||||
quote() {
|
quote() {
|
||||||
local q="$(printf '%q ' "$@")"
|
local q="$(printf '%q ' "$@")"
|
||||||
printf '%s' "${q% }"
|
printf '%s' "${q% }"
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_quoted="$(quote "${herbstclient_command[@]:-herbstclient}")"
|
hc_quoted="$(quote "${herbstclient_command[@]:-herbstclient}")"
|
||||||
@ -12,8 +12,8 @@ hc() { "${herbstclient_command[@]:-herbstclient}" "$@"; }
|
|||||||
monitor=${1:-0}
|
monitor=${1:-0}
|
||||||
geometry=($(hc monitor_rect "$monitor"))
|
geometry=($(hc monitor_rect "$monitor"))
|
||||||
if [ -z "$geometry" ]; then
|
if [ -z "$geometry" ]; then
|
||||||
echo "Invalid monitor $monitor"
|
echo "Invalid monitor $monitor"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# geometry has the format W H X Y
|
# geometry has the format W H X Y
|
||||||
x=$((${geometry[0]} + 12))
|
x=$((${geometry[0]} + 12))
|
||||||
@ -26,197 +26,209 @@ font="*mono*"
|
|||||||
# Try to find textwidth binary.
|
# Try to find textwidth binary.
|
||||||
# In e.g. Ubuntu, this is named dzen2-textwidth.
|
# In e.g. Ubuntu, this is named dzen2-textwidth.
|
||||||
if which textwidth &>/dev/null; then
|
if which textwidth &>/dev/null; then
|
||||||
textwidth="textwidth"
|
textwidth="textwidth"
|
||||||
elif which dzen2-textwidth &>/dev/null; then
|
elif which dzen2-textwidth &>/dev/null; then
|
||||||
textwidth="dzen2-textwidth"
|
textwidth="dzen2-textwidth"
|
||||||
elif which xftwidth &>/dev/null; then # For guix
|
elif which xftwidth &>/dev/null; then # For guix
|
||||||
textwidth="xtfwidth"
|
textwidth="xtfwidth"
|
||||||
else
|
else
|
||||||
echo "This script requires the textwidth tool of the dzen2 project."
|
echo "This script requires the textwidth tool of the dzen2 project."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
####
|
####
|
||||||
# true if we are using the svn version of dzen2
|
# true if we are using the svn version of dzen2
|
||||||
# depending on version/distribution, this seems to have version strings like
|
# depending on version/distribution, this seems to have version strings like
|
||||||
# "dzen-" or "dzen-x.x.x-svn"
|
# "dzen-" or "dzen-x.x.x-svn"
|
||||||
if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then
|
if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then
|
||||||
dzen2_svn="true"
|
dzen2_svn="true"
|
||||||
else
|
else
|
||||||
dzen2_svn=""
|
dzen2_svn=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then
|
if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then
|
||||||
mawk needs "-W interactive" to line-buffer stdout correctly
|
mawk needs "-W interactive" to line-buffer stdout correctly
|
||||||
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
|
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
|
||||||
uniq_linebuffered() {
|
uniq_linebuffered() {
|
||||||
awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@"
|
awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# other awk versions (e.g. gawk) issue a warning with "-W interactive", so
|
# other awk versions (e.g. gawk) issue a warning with "-W interactive", so
|
||||||
# we don't want to use it there.
|
# we don't want to use it there.
|
||||||
uniq_linebuffered() {
|
uniq_linebuffered() {
|
||||||
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
|
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# get the current pulseaudio volume, or state incase muted
|
# get the current pulseaudio volume, or state incase muted
|
||||||
pulsegetvol() {
|
pulsegetvol() {
|
||||||
if [ $(pamixer --get-mute) == 1 ]; then
|
if [ $(pamixer --get-mute) == 1 ]; then
|
||||||
echo -ne "^fg($foreground)muted\n"
|
echo -ne "^fg($foreground)muted\n"
|
||||||
else
|
else
|
||||||
volume=$(pamixer --get-volume-human)
|
volume=$(pamixer --get-volume-human)
|
||||||
echo -n "^fg($foreground)$volume"
|
echo -n "^fg($foreground)$volume"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# using pactl we can subscribe to pulseaudio and check for changes
|
# using pactl we can subscribe to pulseaudio and check for changes
|
||||||
pulsesub() {
|
pulsesub() {
|
||||||
pactl subscribe | grep --line-buffered "change.*sink" | while read -r line; do
|
pactl subscribe | grep --line-buffered "change.*sink" | while read -r line; do
|
||||||
echo -ne "pulseaudio\t$(pulsegetvol)\n"
|
echo -ne "pulseaudio\t$(pulsegetvol)\n"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# used when reloading / quitting, kills all event generators as they no longer have a use
|
# used when reloading / quitting, kills all event generators as they no longer have a use
|
||||||
list_descendants() {
|
list_descendants() {
|
||||||
local children=$(ps -o pid= --ppid "$1")
|
local children=$(ps -o pid= --ppid "$1")
|
||||||
for pid in $children; do
|
for pid in $children; do
|
||||||
list_descendants "$pid"
|
list_descendants "$pid"
|
||||||
done
|
done
|
||||||
echo "$children"
|
echo "$children"
|
||||||
}
|
}
|
||||||
|
|
||||||
hc pad $monitor $(($panel_height + 12))
|
hc pad $monitor $(($panel_height + 12))
|
||||||
|
|
||||||
{
|
{
|
||||||
### Event generator ###
|
### Event generator ###
|
||||||
# based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
|
# based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this:
|
||||||
# <eventname>\t<data> [...]
|
# <eventname>\t<data> [...]
|
||||||
# e.g.
|
# e.g.
|
||||||
# date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
|
# date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
|
||||||
|
|
||||||
#mpc idleloop player &
|
#mpc idleloop player &
|
||||||
pulsesub &
|
pulsesub &
|
||||||
while true; do
|
while true; do
|
||||||
# "date" output is checked once a second, but an event is only
|
# "date" output is checked once a second, but an event is only
|
||||||
# generated if the output changed compared to the previous run.
|
# generated if the output changed compared to the previous run.
|
||||||
date +$"date ^fg($foreground)%a %b %d %H:%M"
|
date +$"date ^fg($foreground)%a %b %d %H:%M"
|
||||||
sleep 1 || break
|
sleep 1 || break
|
||||||
done > >(uniq_linebuffered) &
|
done > >(uniq_linebuffered) &
|
||||||
hc --idle
|
hc --idle
|
||||||
} 2>/dev/null | {
|
} 2>/dev/null | {
|
||||||
IFS=$'\t' read -ra tags <<<"$(hc tag_status $monitor)"
|
IFS=$'\t' read -ra tags <<<"$(hc tag_status $monitor)"
|
||||||
visible=true
|
visible=true
|
||||||
date=""
|
date=""
|
||||||
windowtitle=""
|
windowtitle=""
|
||||||
volume="$(pulsegetvol)"
|
volume="$(pulsegetvol)"
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
### Output ###
|
### Output ###
|
||||||
# This part prints dzen data based on the _previous_ data handling run,
|
# This part prints dzen data based on the _previous_ data handling run,
|
||||||
# and then waits for the next event to happen.
|
# and then waits for the next event to happen.
|
||||||
|
|
||||||
separator="^bg()^fg($color8)|"
|
separator="^bg()^fg($color8)|"
|
||||||
# draw tags
|
# draw tags
|
||||||
for i in "${tags[@]}"; do
|
for i in "${tags[@]}"; do
|
||||||
case ${i:0:1} in
|
case ${i:0:1} in
|
||||||
'#')
|
|
||||||
# tag is focused
|
|
||||||
echo -n "^bg($color2)^fg()"
|
|
||||||
;;
|
|
||||||
':')
|
|
||||||
# tag is not empty
|
|
||||||
echo -n "^bg()^fg($foreground)"
|
|
||||||
;;
|
|
||||||
'!')
|
|
||||||
# tag containts an urgent window
|
|
||||||
echo -n "^bg($color6)^fg()"
|
|
||||||
;;
|
|
||||||
'-')
|
|
||||||
# tag is viewed on a non-focused monitor
|
|
||||||
echo -n "^bg($color1)^fg()"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# tag is empty
|
|
||||||
echo -n "^bg()^fg($color8)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ ! -z "$dzen2_svn" ]; then
|
|
||||||
# clickable tags if using SVN dzen
|
|
||||||
echo -n "^ca(1,$hc_quoted focus_monitor \"$monitor\" && "
|
|
||||||
echo -n "$hc_quoted use \"${i:1}\") ${i:1} ^ca()"
|
|
||||||
else
|
|
||||||
# non-clickable tags if using older dzen
|
|
||||||
echo -n " ${i:1} "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo -n "$separator"
|
|
||||||
echo -n "^bg()^fg() ${windowtitle//^/^^}"
|
|
||||||
# small adjustments
|
|
||||||
right="$volume $separator $date"
|
|
||||||
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
|
|
||||||
# get width of right aligned text.. and add some space..
|
|
||||||
width=$($textwidth "$font" "$right_text_only ")
|
|
||||||
echo -n "^pa($(($panel_width - $width)))$right"
|
|
||||||
echo
|
|
||||||
|
|
||||||
### Data handling ###
|
|
||||||
# This part handles the events generated in the event loop, and sets
|
|
||||||
# internal variables based on them. The event and its arguments are
|
|
||||||
# read into the array cmd, then action is taken depending on the event
|
|
||||||
# name.
|
|
||||||
# "Special" events (quit_panel/togglehidepanel/reload) are also handled
|
|
||||||
# here.
|
|
||||||
|
|
||||||
# wait for next event
|
'.')
|
||||||
IFS=$'\t' read -ra cmd || break
|
# the tag is empty
|
||||||
# find out event origin
|
# TODO Add your formatting tags
|
||||||
case "${cmd[0]}" in
|
echo -n "^bg()^fg($color8)"
|
||||||
tag*)
|
;;
|
||||||
#echo "resetting tags" >&2
|
':')
|
||||||
IFS=$'\t' read -ra tags <<<"$(hc tag_status $monitor)"
|
# the tag is not empty
|
||||||
;;
|
echo -n "^bg()^fg($foreground)"
|
||||||
date)
|
;;
|
||||||
#echo "resetting date" >&2
|
'+')
|
||||||
date="${cmd[@]:1}"
|
# the tag is viewed on the specified MONITOR, but this monitor is not focused.
|
||||||
;;
|
echo -n "^bg($color1)^fg()"
|
||||||
quit_panel)
|
;;
|
||||||
kill $(list_descendants $$)
|
'#')
|
||||||
exit
|
# the tag is viewed on the specified MONITOR and it is focused.
|
||||||
;;
|
echo -n "^bg($color2)^fg()"
|
||||||
togglehidepanel)
|
;;
|
||||||
currentmonidx=$(hc list_monitors | sed -n '/\[FOCUS\]$/s/:.*//p')
|
'-')
|
||||||
if [ "${cmd[1]}" -ne "$monitor" ]; then
|
# the tag is viewed on a different MONITOR, but this monitor is not focused.
|
||||||
continue
|
echo -n "^bg($color1)^fg()"
|
||||||
fi
|
;;
|
||||||
if [ "${cmd[1]}" = "current" ] && [ "$currentmonidx" -ne "$monitor" ]; then
|
'%')
|
||||||
continue
|
# the tag is viewed on a different MONITOR and it is focused.
|
||||||
fi
|
echo -n "^bg($color2)^fg()"
|
||||||
echo "^togglehide()"
|
;;
|
||||||
if $visible; then
|
'!')
|
||||||
visible=false
|
# the tag contains an urgent window
|
||||||
hc pad $monitor 0
|
# TODO Add your formatting tags
|
||||||
else
|
echo -n "^bg($color6)^fg()"
|
||||||
visible=true
|
;;
|
||||||
hc pad $monitor $(($panel_height + 12))
|
esac
|
||||||
fi
|
if [ ! -z "$dzen2_svn" ]; then
|
||||||
;;
|
# clickable tags if using SVN dzen
|
||||||
reload)
|
echo -n "^ca(1,$hc_quoted focus_monitor \"$monitor\" && "
|
||||||
kill $(list_descendants $$)
|
echo -n "$hc_quoted use \"${i:1}\") ${i:1} ^ca()"
|
||||||
exit
|
else
|
||||||
;;
|
# non-clickable tags if using older dzen
|
||||||
focus_changed | window_title_changed)
|
echo -n " ${i:1} "
|
||||||
windowtitle="${cmd[@]:2}"
|
fi
|
||||||
;;
|
done
|
||||||
pulseaudio)
|
echo -n "$separator"
|
||||||
volume="${cmd[@]:1}"
|
echo -n "^bg()^fg() ${windowtitle//^/^^}"
|
||||||
;;
|
# small adjustments
|
||||||
esac
|
right="$volume $separator $date"
|
||||||
done
|
right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
|
||||||
|
# get width of right aligned text.. and add some space..
|
||||||
|
width=$($textwidth "$font" "$right_text_only ")
|
||||||
|
echo -n "^pa($(($panel_width - $width)))$right"
|
||||||
|
echo
|
||||||
|
|
||||||
### dzen2 ###
|
### Data handling ###
|
||||||
# After the data is gathered and processed, the output of the previous block
|
# This part handles the events generated in the event loop, and sets
|
||||||
# gets piped to dzen2.
|
# internal variables based on them. The event and its arguments are
|
||||||
|
# read into the array cmd, then action is taken depending on the event
|
||||||
|
# name.
|
||||||
|
# "Special" events (quit_panel/togglehidepanel/reload) are also handled
|
||||||
|
# here.
|
||||||
|
|
||||||
|
# wait for next event
|
||||||
|
IFS=$'\t' read -ra cmd || break
|
||||||
|
# find out event origin
|
||||||
|
case "${cmd[0]}" in
|
||||||
|
tag*)
|
||||||
|
#echo "resetting tags" >&2
|
||||||
|
IFS=$'\t' read -ra tags <<<"$(hc tag_status $monitor)"
|
||||||
|
;;
|
||||||
|
date)
|
||||||
|
#echo "resetting date" >&2
|
||||||
|
date="${cmd[@]:1}"
|
||||||
|
;;
|
||||||
|
quit_panel)
|
||||||
|
kill $(list_descendants $$)
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
togglehidepanel)
|
||||||
|
currentmonidx=$(hc list_monitors | sed -n '/\[FOCUS\]$/s/:.*//p')
|
||||||
|
if [ "${cmd[1]}" -ne "$monitor" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "${cmd[1]}" = "current" ] && [ "$currentmonidx" -ne "$monitor" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "^togglehide()"
|
||||||
|
if $visible; then
|
||||||
|
visible=false
|
||||||
|
hc pad $monitor 0
|
||||||
|
else
|
||||||
|
visible=true
|
||||||
|
hc pad $monitor $(($panel_height + 12))
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
kill $(list_descendants $$)
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
focus_changed | window_title_changed)
|
||||||
|
windowtitle="${cmd[@]:2}"
|
||||||
|
;;
|
||||||
|
pulseaudio)
|
||||||
|
volume="${cmd[@]:1}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
### dzen2 ###
|
||||||
|
# After the data is gathered and processed, the output of the previous block
|
||||||
|
# gets piped to dzen2.
|
||||||
|
|
||||||
} 2>/dev/null | dzen2 -w $panel_width -x $x -y $y -fn mononoki-15 -h $panel_height \
|
} 2>/dev/null | dzen2 -w $panel_width -x $x -y $y -fn mononoki-15 -h $panel_height \
|
||||||
-e "button3=;button4=exec:$hc_quoted use_index -1;button5=exec:$hc_quoted use_index +1" \
|
-e "button3=;button4=exec:$hc_quoted use_index -1;button5=exec:$hc_quoted use_index +1" \
|
||||||
-ta l -bg "$background" -fg "$foreground"
|
-ta l -bg "$background" -fg "$foreground"
|
||||||
|
|||||||
Reference in New Issue
Block a user