sxmo, plugins: restart Conky on time/timezone/wallpaper/logout and shorten # Input mode hints
This commit is contained in:
@@ -3,3 +3,5 @@
|
||||
|
||||
# This script is called with both toggle wm and when loging out (i.e., restarting)
|
||||
# current window manager.
|
||||
pkill -x conky >/dev/null 2>&1 || true
|
||||
rm -f /tmp/sxmo_conky_time_state
|
||||
|
||||
@@ -89,7 +89,7 @@ if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
|
||||
fi
|
||||
|
||||
# Start the desktop widget (e.g. clock)
|
||||
pidof -s conky >/dev/null 2>&1 || superctl start sxmo_conky
|
||||
pidof -s conky >/dev/null 2>&1 || (DISPLAY=:0 CONKY_DPY=:0 setsid conky -c /home/user/.config/sxmo/conky.conf >/dev/null 2>&1 </dev/null &)
|
||||
|
||||
# Monitor the battery
|
||||
superctl start sxmo_battery_monitor
|
||||
|
||||
@@ -17,8 +17,55 @@
|
||||
# right). Our preference is to have "static" icons on the
|
||||
# right and "variable" icons (that come and go) on the left.
|
||||
|
||||
restart_conky() {
|
||||
lockdir="/tmp/sxmo_conky_restart.lock"
|
||||
if ! mkdir "$lockdir" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
superctl stop sxmo_conky >/dev/null 2>&1 || true
|
||||
pkill -x conky >/dev/null 2>&1 || true
|
||||
sleep 0.05
|
||||
pkill -9 -x conky >/dev/null 2>&1 || true
|
||||
(
|
||||
DISPLAY="${DISPLAY:-:0}" CONKY_DPY="${DISPLAY:-:0}" \
|
||||
setsid conky -c "${XDG_CONFIG_HOME:-/home/user/.config}/sxmo/conky.conf" >/dev/null 2>&1 </dev/null &
|
||||
)
|
||||
rmdir "$lockdir" 2>/dev/null || true
|
||||
}
|
||||
|
||||
set_time() {
|
||||
sxmobar -a time 99 " $(date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}")"
|
||||
force_conky="${1:-0}"
|
||||
state_file="/tmp/sxmo_conky_time_state"
|
||||
cur_btime="$(awk '/^btime / {print $2}' /proc/stat 2>/dev/null || echo 0)"
|
||||
cur_tz="$(readlink /etc/localtime 2>/dev/null || cat /etc/timezone 2>/dev/null || echo "")|$(date '+%Z%z')"
|
||||
do_restart="$force_conky"
|
||||
if ! pidof -s conky >/dev/null 2>&1; then
|
||||
do_restart=1
|
||||
elif [ -r "$state_file" ]; then
|
||||
old_btime=""
|
||||
old_tz=""
|
||||
{
|
||||
IFS= read -r old_btime || true
|
||||
IFS= read -r old_tz || true
|
||||
} < "$state_file"
|
||||
if [ "$cur_tz" != "$old_tz" ]; then
|
||||
do_restart=1
|
||||
else
|
||||
case "$cur_btime:$old_btime" in
|
||||
*[!0-9:]*) do_restart=1 ;;
|
||||
*)
|
||||
diff=$((cur_btime - old_btime))
|
||||
[ "$diff" -lt 0 ] && diff=$((-diff))
|
||||
[ "$diff" -ge 2 ] && do_restart=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
printf "%s\n%s\n" "$cur_btime" "$cur_tz" > "$state_file" 2>/dev/null || true
|
||||
if [ "$do_restart" = "1" ]; then
|
||||
restart_conky
|
||||
fi
|
||||
}
|
||||
|
||||
set_state() {
|
||||
@@ -465,7 +512,10 @@ case "$1" in
|
||||
shift
|
||||
set_battery "$@"
|
||||
;;
|
||||
time|modem|volume|state|notifications|notch|inputmethod)
|
||||
time)
|
||||
set_time 1
|
||||
;;
|
||||
modem|volume|state|notifications|notch|inputmethod)
|
||||
set_"$1"
|
||||
;;
|
||||
state_change)
|
||||
|
||||
Reference in New Issue
Block a user