From db6e868011cc78e3e1c774c658666e069822a300 Mon Sep 17 00:00:00 2001 From: novakne Date: Mon, 22 Feb 2021 11:04:02 +0100 Subject: [PATCH 1/3] exemples/scripts: dwl-tags.sh: display info about dwl tags --- examples/scripts/dwl-tags.sh | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 examples/scripts/dwl-tags.sh diff --git a/examples/scripts/dwl-tags.sh b/examples/scripts/dwl-tags.sh new file mode 100755 index 0000000..44ade8f --- /dev/null +++ b/examples/scripts/dwl-tags.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +# +# dwl-tags.sh - display dwl tags +# +# USAGE: dwl-tags.sh 1 +# +# REQUIREMENTS: +# - inotifywait ( 'inotify-tools' on arch ) +# - 2021/02/22 - dwl pull request: +# 'Interface to display tag information on status bar #91' +# https://github.com/djpohly/dwl/pull/91 +# +# TAGS: +# Name Type Return +# ------------------------------------- +# {dwltag} string dwl tags name/state +# +# Exemple configuration: +# - script: +# path: /absolute/path/to/dwl-tags.sh +# args: [1] +# content: {string: {text: "{dwltag}"}} + + +# Variables +declare titleline tagline title taginfo isactive ctags mtags layout +declare symbol_occupied_pre symbol_occupied_post symbol_focused_pre symbol_focused_post +declare -a tags name +readonly fname=/tmp/dwltags-"$WAYLAND_DISPLAY" + + +while true; do + + # Make sure the file exists + while [ ! -f "${fname}" ]; do + inotifywait -qqe create "$(dirname "${fname}")" + done; + + # Wait for dwl to close it after writing + inotifywait -qqe close_write "${fname}" + + # Get info from the file + titleline="$1" + tagline=$((titleline+1)) + title=$(sed "${titleline}!d" "${fname}") + taginfo=$(sed "${tagline}!d" "${fname}") + isactive=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 1) + ctags=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 2) + mtags=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 3) + layout=$(printf -- '%s\n' "${taginfo}" | cut -d ' ' -f 4-) + + tags=( "1" "2" "3" "4" "5" "6" "7" "8" "9" ) + + # Name of tag (optional) + # If there is no name, number are used + # + # Example: + # name=( "" "" "" "Media" ) + # -> return "" "" "" "Media" 5 6 7 8 9) + name=() + + # Symbol for occupied tags + # + # Format: "{symbol_occupied_pre}{TAGNAME}{symbol_occupied_post}" + # You can leave one empty if you don't want to surround the TAGNAME + symbol_occupied_pre="" + symbol_occupied_post="." + + # Symbol for the focused tag + # + # Format: "{symbol_focused_pre}{TAGNAME}{symbol_focused_post}" + # You can leave one empty if you don't want to surround the TAGNAME + symbol_focused_pre="[ " + symbol_focused_post=" ]" + + for i in {0..8}; do + mask=$((1< Date: Wed, 24 Feb 2021 19:57:01 +0100 Subject: [PATCH 2/3] exemples/scripts: dwl-tags.sh: use yambar capacities --- examples/scripts/dwl-tags.sh | 315 ++++++++++++++++++++++++++++------- 1 file changed, 251 insertions(+), 64 deletions(-) diff --git a/examples/scripts/dwl-tags.sh b/examples/scripts/dwl-tags.sh index 44ade8f..ea1bad6 100755 --- a/examples/scripts/dwl-tags.sh +++ b/examples/scripts/dwl-tags.sh @@ -11,26 +11,266 @@ # https://github.com/djpohly/dwl/pull/91 # # TAGS: -# Name Type Return -# ------------------------------------- -# {dwltag} string dwl tags name/state +# Name Type Return +# ---------------------------------------------------- +# {dwltag_N} string dwl tags name +# {dwltag_N_occupied} bool dwl tags state occupied +# {dwltag_N_focused} bool dwl tags state focused +# {dwl_layout} string dwl layout +# {dwl_title} string client title +# +# Now the fun part # # Exemple configuration: -# - script: -# path: /absolute/path/to/dwl-tags.sh -# args: [1] -# content: {string: {text: "{dwltag}"}} +# +# - script: +# path: /absolute/path/to/dwl-tags.sh +# args: [1] +# anchors: +# - occupied: &occupied {foreground: 57bbf4ff} +# - focused: &focused {foreground: fc65b0ff} +# - default: &default {foreground: d2ccd6ff} +# content: +# - map: +# margin: 4 +# tag: dwltag_0_occupied +# values: +# true: +# map: +# tag: dwltag_0_focused +# values: +# true: +# - string: {text: "{dwltag_0}", <<: *focused} +# false: +# - string: {text: "{dwltag_0}", <<: *occupied} +# false: +# map: +# tag: dwltag_0_focused +# values: +# true: +# - string: {text: "{dwltag_0}", <<: *focused} +# false: +# - string: {text: "{dwltag_0}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_1_occupied +# values: +# true: +# map: +# tag: dwltag_1_focused +# values: +# true: +# - string: {text: "{dwltag_1}", <<: *focused} +# false: +# - string: {text: "{dwltag_1}", <<: *occupied} +# false: +# map: +# tag: dwltag_1_focused +# values: +# true: +# - string: {text: "{dwltag_1}", <<: *focused} +# false: +# - string: {text: "{dwltag_1}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_2_occupied +# values: +# true: +# map: +# tag: dwltag_2_focused +# values: +# true: +# - string: {text: "{dwltag_2}", <<: *focused} +# false: +# - string: {text: "{dwltag_2}", <<: *occupied} +# false: +# map: +# tag: dwltag_2_focused +# values: +# true: +# - string: {text: "{dwltag_2}", <<: *focused} +# false: +# - string: {text: "{dwltag_2}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_3_occupied +# values: +# true: +# map: +# tag: dwltag_3_focused +# values: +# true: +# - string: {text: "{dwltag_3}", <<: *focused} +# false: +# - string: {text: "{dwltag_3}", <<: *occupied} +# false: +# map: +# tag: dwltag_3_focused +# values: +# true: +# - string: {text: "{dwltag_3}", <<: *focused} +# false: +# - string: {text: "{dwltag_3}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_4_occupied +# values: +# true: +# map: +# tag: dwltag_4_focused +# values: +# true: +# - string: {text: "{dwltag_4}", <<: *focused} +# false: +# - string: {text: "{dwltag_4}", <<: *occupied} +# false: +# map: +# tag: dwltag_4_focused +# values: +# true: +# - string: {text: "{dwltag_4}", <<: *focused} +# false: +# - string: {text: "{dwltag_4}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_5_occupied +# values: +# true: +# map: +# tag: dwltag_5_focused +# values: +# true: +# - string: {text: "{dwltag_5}", <<: *focused} +# false: +# - string: {text: "{dwltag_5}", <<: *occupied} +# false: +# map: +# tag: dwltag_5_focused +# values: +# true: +# - string: {text: "{dwltag_5}", <<: *focused} +# false: +# - string: {text: "{dwltag_5}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_6_occupied +# values: +# true: +# map: +# tag: dwltag_6_focused +# values: +# true: +# - string: {text: "{dwltag_6}", <<: *focused} +# false: +# - string: {text: "{dwltag_6}", <<: *occupied} +# false: +# map: +# tag: dwltag_6_focused +# values: +# true: +# - string: {text: "{dwltag_6}", <<: *focused} +# false: +# - string: {text: "{dwltag_6}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_7_occupied +# values: +# true: +# map: +# tag: dwltag_7_focused +# values: +# true: +# - string: {text: "{dwltag_7}", <<: *focused} +# false: +# - string: {text: "{dwltag_7}", <<: *occupied} +# false: +# map: +# tag: dwltag_7_focused +# values: +# true: +# - string: {text: "{dwltag_7}", <<: *focused} +# false: +# - string: {text: "{dwltag_7}", <<: *default} +# - map: +# margin: 4 +# tag: dwltag_8_occupied +# values: +# true: +# map: +# tag: dwltag_8_focused +# values: +# true: +# - string: {text: "{dwltag_8}", <<: *focused} +# false: +# - string: {text: "{dwltag_8}", <<: *occupied} +# false: +# map: +# tag: dwltag_8_focused +# values: +# true: +# - string: {text: "{dwltag_8}", <<: *focused} +# false: +# - string: {text: "{dwltag_8}", <<: *default} +# - list: +# spacing: 3 +# items: +# - string: {text: "{dwl_layout}"} +# - string: {text: "{dwl_title}"} # Variables declare titleline tagline title taginfo isactive ctags mtags layout -declare symbol_occupied_pre symbol_occupied_post symbol_focused_pre symbol_focused_post declare -a tags name readonly fname=/tmp/dwltags-"$WAYLAND_DISPLAY" +_cycle() { + tags=( "1" "2" "3" "4" "5" "6" "7" "8" "9" ) + + # Name of tag (optional) + # If there is no name, number are used + # + # Example: + # name=( "" "" "" "Media" ) + # -> return "" "" "" "Media" 5 6 7 8 9) + name=() + + for tag in "${!tags[@]}"; do + mask=$((1< return "" "" "" "Media" 5 6 7 8 9) - name=() - - # Symbol for occupied tags - # - # Format: "{symbol_occupied_pre}{TAGNAME}{symbol_occupied_post}" - # You can leave one empty if you don't want to surround the TAGNAME - symbol_occupied_pre="" - symbol_occupied_post="." - - # Symbol for the focused tag - # - # Format: "{symbol_focused_pre}{TAGNAME}{symbol_focused_post}" - # You can leave one empty if you don't want to surround the TAGNAME - symbol_focused_pre="[ " - symbol_focused_post=" ]" - - for i in {0..8}; do - mask=$((1< Date: Thu, 25 Feb 2021 08:26:10 +0100 Subject: [PATCH 3/3] exemples/scripts: dwl-tags.sh: fix exemple length rename yambar tags --- examples/scripts/dwl-tags.sh | 205 +++++------------------------------ 1 file changed, 30 insertions(+), 175 deletions(-) diff --git a/examples/scripts/dwl-tags.sh b/examples/scripts/dwl-tags.sh index ea1bad6..7e68257 100755 --- a/examples/scripts/dwl-tags.sh +++ b/examples/scripts/dwl-tags.sh @@ -6,18 +6,18 @@ # # REQUIREMENTS: # - inotifywait ( 'inotify-tools' on arch ) -# - 2021/02/22 - dwl pull request: +# - 2021/02/25 - dwl pull request: # 'Interface to display tag information on status bar #91' # https://github.com/djpohly/dwl/pull/91 # # TAGS: -# Name Type Return +# Name Type Return # ---------------------------------------------------- -# {dwltag_N} string dwl tags name -# {dwltag_N_occupied} bool dwl tags state occupied -# {dwltag_N_focused} bool dwl tags state focused -# {dwl_layout} string dwl layout -# {dwl_title} string client title +# {tag_N} string dwl tags name +# {tag_N_occupied} bool dwl tags state occupied +# {tag_N_focused} bool dwl tags state focused +# {layout} string dwl layout +# {title} string client title # # Now the fun part # @@ -33,189 +33,44 @@ # content: # - map: # margin: 4 -# tag: dwltag_0_occupied +# tag: tag_0_occupied # values: # true: # map: -# tag: dwltag_0_focused +# tag: tag_0_focused # values: -# true: -# - string: {text: "{dwltag_0}", <<: *focused} -# false: -# - string: {text: "{dwltag_0}", <<: *occupied} +# true: {string: {text: "{tag_0}", <<: *focused}} +# false: {string: {text: "{tag_0}", <<: *occupied}} # false: # map: -# tag: dwltag_0_focused +# tag: tag_0_focused # values: -# true: -# - string: {text: "{dwltag_0}", <<: *focused} -# false: -# - string: {text: "{dwltag_0}", <<: *default} +# true: {string: {text: "{tag_0}", <<: *focused}} +# false: {string: {text: "{tag_0}", <<: *default}} +# ... +# ... +# ... # - map: # margin: 4 -# tag: dwltag_1_occupied +# tag: tag_8_occupied # values: # true: # map: -# tag: dwltag_1_focused +# tag: tag_8_focused # values: -# true: -# - string: {text: "{dwltag_1}", <<: *focused} -# false: -# - string: {text: "{dwltag_1}", <<: *occupied} +# true: {string: {text: "{tag_8}", <<: *focused}} +# false: {string: {text: "{tag_8}", <<: *occupied}} # false: # map: -# tag: dwltag_1_focused +# tag: tag_8_focused # values: -# true: -# - string: {text: "{dwltag_1}", <<: *focused} -# false: -# - string: {text: "{dwltag_1}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_2_occupied -# values: -# true: -# map: -# tag: dwltag_2_focused -# values: -# true: -# - string: {text: "{dwltag_2}", <<: *focused} -# false: -# - string: {text: "{dwltag_2}", <<: *occupied} -# false: -# map: -# tag: dwltag_2_focused -# values: -# true: -# - string: {text: "{dwltag_2}", <<: *focused} -# false: -# - string: {text: "{dwltag_2}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_3_occupied -# values: -# true: -# map: -# tag: dwltag_3_focused -# values: -# true: -# - string: {text: "{dwltag_3}", <<: *focused} -# false: -# - string: {text: "{dwltag_3}", <<: *occupied} -# false: -# map: -# tag: dwltag_3_focused -# values: -# true: -# - string: {text: "{dwltag_3}", <<: *focused} -# false: -# - string: {text: "{dwltag_3}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_4_occupied -# values: -# true: -# map: -# tag: dwltag_4_focused -# values: -# true: -# - string: {text: "{dwltag_4}", <<: *focused} -# false: -# - string: {text: "{dwltag_4}", <<: *occupied} -# false: -# map: -# tag: dwltag_4_focused -# values: -# true: -# - string: {text: "{dwltag_4}", <<: *focused} -# false: -# - string: {text: "{dwltag_4}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_5_occupied -# values: -# true: -# map: -# tag: dwltag_5_focused -# values: -# true: -# - string: {text: "{dwltag_5}", <<: *focused} -# false: -# - string: {text: "{dwltag_5}", <<: *occupied} -# false: -# map: -# tag: dwltag_5_focused -# values: -# true: -# - string: {text: "{dwltag_5}", <<: *focused} -# false: -# - string: {text: "{dwltag_5}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_6_occupied -# values: -# true: -# map: -# tag: dwltag_6_focused -# values: -# true: -# - string: {text: "{dwltag_6}", <<: *focused} -# false: -# - string: {text: "{dwltag_6}", <<: *occupied} -# false: -# map: -# tag: dwltag_6_focused -# values: -# true: -# - string: {text: "{dwltag_6}", <<: *focused} -# false: -# - string: {text: "{dwltag_6}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_7_occupied -# values: -# true: -# map: -# tag: dwltag_7_focused -# values: -# true: -# - string: {text: "{dwltag_7}", <<: *focused} -# false: -# - string: {text: "{dwltag_7}", <<: *occupied} -# false: -# map: -# tag: dwltag_7_focused -# values: -# true: -# - string: {text: "{dwltag_7}", <<: *focused} -# false: -# - string: {text: "{dwltag_7}", <<: *default} -# - map: -# margin: 4 -# tag: dwltag_8_occupied -# values: -# true: -# map: -# tag: dwltag_8_focused -# values: -# true: -# - string: {text: "{dwltag_8}", <<: *focused} -# false: -# - string: {text: "{dwltag_8}", <<: *occupied} -# false: -# map: -# tag: dwltag_8_focused -# values: -# true: -# - string: {text: "{dwltag_8}", <<: *focused} -# false: -# - string: {text: "{dwltag_8}", <<: *default} +# true: {string: {text: "{tag_8}", <<: *focused}} +# false: {string: {text: "{tag_8}", <<: *default}} # - list: # spacing: 3 # items: -# - string: {text: "{dwl_layout}"} -# - string: {text: "{dwl_title}"} +# - string: {text: "{layout}"} +# - string: {text: "{title}"} # Variables @@ -238,7 +93,7 @@ _cycle() { for tag in "${!tags[@]}"; do mask=$((1<