mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
exemples/script: Update dwl-tags
Update dwl-tags to works with dwl main branch now that the pull request was merged
This commit is contained in:
parent
4efb7df7db
commit
21a84aed72
1 changed files with 23 additions and 31 deletions
|
@ -6,9 +6,7 @@
|
||||||
#
|
#
|
||||||
# REQUIREMENTS:
|
# REQUIREMENTS:
|
||||||
# - inotifywait ( 'inotify-tools' on arch )
|
# - inotifywait ( 'inotify-tools' on arch )
|
||||||
# - 2021/02/25 - dwl pull request:
|
# - Launch dwl with `dwl > ~.cache/dwltags` or change $fname
|
||||||
# 'Interface to display tag information on status bar #91'
|
|
||||||
# https://github.com/djpohly/dwl/pull/91
|
|
||||||
#
|
#
|
||||||
# TAGS:
|
# TAGS:
|
||||||
# Name Type Return
|
# Name Type Return
|
||||||
|
@ -74,9 +72,9 @@
|
||||||
|
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
declare titleline tagline title taginfo isactive ctags mtags layout
|
declare output title layout activetags selectedtags
|
||||||
declare -a tags name
|
declare -a tags name
|
||||||
readonly fname=/tmp/dwltags-"$WAYLAND_DISPLAY"
|
readonly fname="$HOME"/.cache/dwltags
|
||||||
|
|
||||||
|
|
||||||
_cycle() {
|
_cycle() {
|
||||||
|
@ -99,21 +97,18 @@ _cycle() {
|
||||||
|
|
||||||
printf -- '%s\n' "${tag_name}_${tag}|string|${name[tag]}"
|
printf -- '%s\n' "${tag_name}_${tag}|string|${name[tag]}"
|
||||||
|
|
||||||
# Occupied
|
if (( "${selectedtags}" & mask )) 2>/dev/null; then
|
||||||
if (( "${ctags}" & mask )); then
|
printf -- '%s\n' "${tag_name}_${tag}_focused|bool|true"
|
||||||
|
printf -- '%s\n' "title|string|${title}"
|
||||||
|
else
|
||||||
|
printf '%s\n' "${tag_name}_${tag}_focused|bool|false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( "${activetags}" & mask )) 2>/dev/null; then
|
||||||
printf -- '%s\n' "${tag_name}_${tag}_occupied|bool|true"
|
printf -- '%s\n' "${tag_name}_${tag}_occupied|bool|true"
|
||||||
else
|
else
|
||||||
printf -- '%s\n' "${tag_name}_${tag}_occupied|bool|false"
|
printf -- '%s\n' "${tag_name}_${tag}_occupied|bool|false"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Focused
|
|
||||||
if (( "${mtags}" & mask )); then
|
|
||||||
printf -- '%s\n' "${tag_name}_${tag}_focused|bool|true"
|
|
||||||
printf -- '%s\n' "title|string|${title}"
|
|
||||||
else
|
|
||||||
printf -- '%s\n' "${tag_name}_${tag}_focused|bool|false"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
printf -- '%s\n' "layout|string|${layout}"
|
printf -- '%s\n' "layout|string|${layout}"
|
||||||
|
@ -126,28 +121,25 @@ _cycle
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
# Make sure the file exists
|
[[ ! -f "${fname}" ]] && printf -- '%s\n' \
|
||||||
while [ ! -f "${fname}" ]; do
|
"You need to redirect dwl stdout to ~/.cache/dwltags" >&2
|
||||||
inotifywait -qqe create "$(dirname "${fname}")"
|
|
||||||
done;
|
|
||||||
|
|
||||||
# Wait for dwl to close it after writing
|
inotifywait -qq --event modify "${fname}"
|
||||||
inotifywait -qqe close_write "${fname}"
|
|
||||||
|
|
||||||
# Get info from the file
|
# Get info from the file
|
||||||
titleline="$1"
|
output="$(tail -n4 "${fname}")"
|
||||||
tagline=$((titleline+1))
|
title="$(echo "${output}" | grep title | cut -d ' ' -f 3- )"
|
||||||
title=$(sed "${titleline}!d" "${fname}")
|
#selmon="$(echo "${output}" | grep 'selmon')"
|
||||||
taginfo=$(sed "${tagline}!d" "${fname}")
|
layout="$(echo "${output}" | grep layout | cut -d ' ' -f 3- )"
|
||||||
isactive=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 1)
|
|
||||||
ctags=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 2)
|
# Get the tag bit mask as a decimal
|
||||||
mtags=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 3)
|
activetags="$(echo "${output}" | grep tags | awk '{print $3}')"
|
||||||
layout=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 4-)
|
selectedtags="$(echo "${output}" | grep tags | awk '{print $4}')"
|
||||||
|
|
||||||
_cycle
|
_cycle
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
unset -v titleline tagline title taginfo isactive ctags mtags layout
|
unset -v output title layout activetags selectedtags
|
||||||
unset -v tags name
|
unset -v tags name
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue