diff options
| author | Mehdi Sadeghi <mehdi@mehdix.org> | 2021-06-11 17:13:48 +0200 |
|---|---|---|
| committer | Mehdi Sadeghi <mehdi@mehdix.org> | 2021-06-11 17:14:52 +0200 |
| commit | da4ff3db82916d18029cfbdacf3f5866a391b7ba (patch) | |
| tree | e91b387b0a01fabc350d7658b2fa4922c06569ba /.local | |
| parent | 5886d668f0216f0cc44894f6d71f97e8d95f255e (diff) | |
Add jdate to i3status. Use dmenu.
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/any_position_wrapper.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/.local/bin/any_position_wrapper.sh b/.local/bin/any_position_wrapper.sh new file mode 100755 index 0000000..d6c6afc --- /dev/null +++ b/.local/bin/any_position_wrapper.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# This i3status wrapper allows to add custom information in any position of the statusline +# It was developed for i3bar (JSON format) + +# The idea is to define "holder" modules in i3status config and then replace them + +# In order to make this example work you need to add +# order += "tztime holder__hey_man" +# and +# tztime holder__hey_man { +# format = "holder__hey_man" +# } +# in i3staus config + +# Don't forget that i3status config should contain: +# general { +# output_format = i3bar +# } +# +# and i3 config should contain: +# bar { +# status_command exec /path/to/this/script.sh +# } + +# Make sure jq is installed +# That's it + +# You can easily add multiple custom modules using additional "holders" + +function update_holder { + + local instance="$1" + local replacement="$2" + echo "$json_array" | jq --argjson arg_j "$replacement" "(.[] | (select(.instance==\"$instance\"))) |= \$arg_j" +} + +function remove_holder { + + local instance="$1" + echo "$json_array" | jq "del(.[] | (select(.instance==\"$instance\")))" +} + +function irdate { + local json="{ \"full_text\": \"$(jdate '+%h %m %b %Y')\", \"color\": \"#00FF00\" }" + json_array=$(update_holder holder__jdate "$json") +} + +i3status | (read line; echo "$line"; read line ; echo "$line" ; read line ; echo "$line" ; while true +do + read line + json_array="$(echo $line | sed -e 's/^,//')" + irdate + echo ",$json_array" +done) |
