-
-
Save thingsiplay/eaafca24f43ec1cf98fa72d9015f71cf to your computer and use it in GitHub Desktop.
#!/bin/env bash | |
# Usage: | |
# qforceupdate | |
# qforceupdate checkupdates | |
if [ "${#}" == 0 ] | |
then | |
# requires ln -s ~/.cache/qtile/qtilesocket.\:0 ~/.cache/qtile/qtilesocket.\:0.0 | |
qtile cmd-obj -o cmd -f list_widgets \ | |
| sed "s/^\[//" \ | |
| sed "s/\]$//" \ | |
| sed "s/^ *'//" \ | |
| sed "s/',*$//" | |
else | |
for widget_name in "${@}" | |
do | |
qtile cmd-obj -o widget "${widget_name}" -f force_update | |
done | |
fi |
qtile cmd-obj -o cmd -f list_widgets |sed 's/[^[:alnum:]_]\+//g'
this is much simplier
#!/usr/bin/env bash
widgets=($(qtile cmd-obj -o cmd -f list_widgets |sed 's/[^[:alnum:]_]\+//g'))
for index in "${!widgets[@]}"
do
printf "%d:%s " "$(($index+1))" "${widgets[$index]}"
done
printf "\n"
read -n 2 -p "Select widget: " index
widget="$((index-1))"
max=$((${#widgets[@]}-1))
case $widget in
[1-$max])
printf "%s\n" "Updating ${widgets[$widget]}"
qtile cmd-obj -o widget ${widgets[$widget]} -f force_update
;;
"-1")
printf "%s\n" "Updating all widgets"�
for index in "${!widgets[@]}"
do
qtile cmd-obj -o widget ${widgets[$index]} -f force_update
done
;;
*)
echo "Invalid selection"
;;
esac
Add some interaction
Hi @poslat-pismo , good to see alternatives! Unfortunately I stopped using Qtile (shame on me, but plan on returning) and cannot test your commands at the moment. Your first command which simplifies it into a single sed makes sense. The second script is probably useful to test right away if a certain widget name is the correct one, before using the widget name in an automation script.
But its too specific for my taste. The listing command was added for exactly that, to be able to make menu scripts if someone wants to. I would probably use the widget listing command and combine it with a fuzzy finder, something like qforceupdate "$(qforceupdate | fzf)"
(untested command!).
This is for the widgets in the Qtile bar. The bash script can update specific widgets without reloading Qtile or the entire config file.
Note: If you get any "ipc" related error, then try the command
ln -s ~/.cache/qtile/qtilesocket.\:0 ~/.cache/qtile/qtilesocket.\:0.0
to create a symlink. For some reason Qtile expects a filename with .0 at the end.