Add module which allows you to toggle modules on/off

This commit is contained in:
speedie 2022-12-22 23:11:38 +01:00
parent fe1c9cf3f0
commit 0995683a26
13 changed files with 133 additions and 71 deletions

View file

@ -5,6 +5,8 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ -e "/tmp/module_bat_hidden" ] && exit
# clicking
CLICK() {
# values

View file

@ -6,6 +6,7 @@ command -v date > /dev/null || exit
# load config
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ -e "/tmp/module_date_hidden" ] && exit
# click

View file

@ -2,6 +2,7 @@
# dfmpeg module for status/stellar
command -v speedwm-dfmpeg > /dev/null || exit
[ -e "/tmp/module_dfmpeg_hidden" ] && exit
# load config
module_config

View file

@ -8,6 +8,7 @@ module_config
[ -z "$ICON" ] && ICON="$ITEM12_ICON"
[ -z "$EMAIL_UNREADS" ] && EMAIL_UNREADS="$(find $ITEM12_EMAIL_DIR/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f >/tmp/module_email_data 2>/dev/null && wc -l </tmp/module_email_data || echo 0)"
[ -d "$ITEM12_EMAIL_DIR" ] || exit
[ -e "/tmp/module_email_hidden" ] && exit
# clicking
CLICK() {

View file

@ -5,6 +5,7 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM9" = "true" ] || exit
[ -e "/tmp/module_music_hidden" ] && exit
# get information, the following functions depend on this
GETPROP() {

View file

@ -6,6 +6,7 @@ module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ -z "$URL" ] && URL="1.1.1.1"
[ "$ENABLE_ITEM6" = "true" ] || exit
[ -e "/tmp/module_net_hidden" ] && exit
# get stats
GETNSTAT() {

View file

@ -4,6 +4,7 @@
# load config
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ -e "/tmp/module_news_hidden" ] && exit
[ "$ENABLE_ITEM10" = "true" ] || exit
command -v newsboat > /dev/null || exit

View file

@ -5,6 +5,7 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM1" = "true" ] || exit
[ -e "/tmp/module_ram_hidden" ] && exit
command -v free > /dev/null || exit
# get status

View file

@ -5,6 +5,7 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM8" != "true" ] && exit
[ -e "/tmp/module_temp_hidden" ] && exit
command -v sensors > /dev/null || exit
# click

View file

@ -6,6 +6,7 @@ module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM2" = "true" ] || exit
command -v date > /dev/null || exit
[ -e "/tmp/module_time_hidden" ] && exit
# click
CLICK() {

49
modules/module_toggle Executable file
View file

@ -0,0 +1,49 @@
#!/bin/sh
# module_toggle
orig=34
module_time=1
module_date=2
module_bat=3
module_vol=4
module_ram=5
module_net=6
module_temp=7
module_weather=8
module_music=9
module_dfmpeg=10
module_news=11
module_email=12
module_bat_id="$(expr $orig + $module_bat)"
module_date_id="$(expr $orig + $module_date)"
module_time_id="$(expr $orig + $module_time)"
module_vol_id="$(expr $orig + $module_vol)"
module_ram_id="$(expr $orig + $module_ram)"
module_net_id="$(expr $orig + $module_net)"
module_temp_id="$(expr $orig + $module_temp)"
module_weather_id="$(expr $orig + $module_weather)"
module_music_id="$(expr $orig + $module_music)"
module_dfmpeg_id="$(expr $orig + $module_dfmpeg)"
module_news_id="$(expr $orig + $module_news)"
module_email_id="$(expr $orig + $module_email)"
init() {
case "${1}" in
"module_bat") [ -e "/tmp/module_bat_hidden" ] && rm -f /tmp/module_bat_hidden || touch /tmp/module_bat_hidden; kill -$module_bat_id $(pidof status) ;;
"module_date") [ -e "/tmp/module_date_hidden" ] && rm -f /tmp/module_date_hidden || touch /tmp/module_date_hidden; kill -$module_date_id $(pidof status) ;;
"module_time") [ -e "/tmp/module_time_hidden" ] && rm -f /tmp/module_time_hidden || touch /tmp/module_time_hidden; kill -$module_time_id $(pidof status) ;;
"module_vol") [ -e "/tmp/module_vol_hidden" ] && rm -f /tmp/module_vol_hidden || touch /tmp/module_vol_hidden; kill -$module_vol_id $(pidof status) ;;
"module_ram") [ -e "/tmp/module_ram_hidden" ] && rm -f /tmp/module_ram_hidden || touch /tmp/module_ram_hidden; kill -$module_ram_id $(pidof status) ;;
"module_net") [ -e "/tmp/module_net_hidden" ] && rm -f /tmp/module_net_hidden || touch /tmp/module_net_hidden; kill -$module_net_id $(pidof status) ;;
"module_temp") [ -e "/tmp/module_temp_hidden" ] && rm -f /tmp/module_temp_hidden || touch /tmp/module_temp_hidden; kill -$module_temp_id $(pidof status) ;;
"module_weather") [ -e "/tmp/module_weather_hidden" ] && rm -f /tmp/module_weather_hidden || touch /tmp/module_weather_hidden; kill -$module_weather_id $(pidof status) ;;
"module_music") [ -e "/tmp/module_music_hidden" ] && rm -f /tmp/module_music_hidden || touch /tmp/module_music_hidden; kill -$module_music_id $(pidof status) ;;
"module_dfmpeg") [ -e "/tmp/module_dfmpeg_hidden" ] && rm -f /tmp/module_dfmpeg_hidden || touch /tmp/module_dfmpeg_hidden; kill -$module_dfmpeg_id $(pidof status) ;;
"module_news") [ -e "/tmp/module_news_hidden" ] && rm -f /tmp/module_news_hidden || touch /tmp/module_news_hidden; kill -$module_news_id $(pidof status) ;;
"module_email") [ -e "/tmp/module_email_hidden" ] && rm -f /tmp/module_email_hidden || touch /tmp/module_email_hidden; kill -$module_email_id $(pidof status) ;;
esac
}
init "${@}"

View file

@ -5,6 +5,7 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM4" != "true" ] && exit
[ -e "/tmp/module_vol_hidden" ] && exit
command -v pactl > /dev/null && BACKEND=pactl || BACKEND=amixer
command -v awk > /dev/null || exit

View file

@ -5,6 +5,7 @@
module_config
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
[ "$ENABLE_ITEM5" = "true" ] || exit
[ -e "/tmp/module_weather_hidden" ] && exit
command -v curl > /dev/null || exit
# weather data