sxmo, plugins: restart Conky on time/timezone/wallpaper/logout and shorten # Input mode hints

This commit is contained in:
Luxferre
2026-10-25 16:06:47 +02:00
parent 7c707844cc
commit 651720b56b
32 changed files with 273 additions and 35 deletions
+1
View File
@@ -26,6 +26,7 @@ permit nopass :wheel as root cmd /usr/libexec/msm-modem-uim-selection
permit nopass :wheel as root cmd msm-modem-uim-selection
permit nopass :wheel as root cmd setup-timezone
permit nopass :wheel as root cmd /sbin/setup-timezone
permit nopass :wheel as root cmd /usr/sbin/setup-timezone
permit nopass :wheel as root cmd rtcwake
permit nopass :wheel as root cmd tee args -a /sys/power/wake_lock
permit nopass :wheel as root cmd tee args -a /sys/power/wake_unlock
+1 -1
View File
@@ -1,4 +1,4 @@
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.local/bin:$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH"
export EDITOR=nano
export VISUAL=nano
@@ -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
+1 -1
View File
@@ -1,4 +1,4 @@
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.local/bin:$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH"
export EDITOR=nano
export VISUAL=nano
@@ -80,25 +80,41 @@ else
xset s off s noblank s 0 0 -dpms >/dev/null 2>&1 || true
fi
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
WP_FILE="/usr/share/wallpapers/bananarchy.png"
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper" ]; then
custom_wp="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper" 2>/dev/null)"
[ -n "$custom_wp" ] && [ -f "$custom_wp" ] && WP_FILE="$custom_wp"
fi
WP_FLAG="--bg-fill"
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" ]; then
wp_mode="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" 2>/dev/null)"
case "$wp_mode" in
scale|--bg-scale) WP_FLAG="--bg-scale" ;;
max|--bg-max) WP_FLAG="--bg-max" ;;
center|--bg-center) WP_FLAG="--bg-center" ;;
tile|--bg-tile) WP_FLAG="--bg-tile" ;;
*) WP_FLAG="--bg-fill" ;;
esac
fi
feh --no-fehbg "$WP_FLAG" "$WP_FILE" >/dev/null 2>&1 </dev/null &
pidof -s conky >/dev/null 2>&1 || CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
pkill -9 -x conky >/dev/null 2>&1 || true
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
(DISPLAY=:0 CONKY_DPY=:0 setsid conky -c /home/user/.config/sxmo/conky.conf >/dev/null 2>&1 </dev/null &)
pidof -s fcitx5 >/dev/null 2>&1 || fcitx5 -d >/tmp/fcitx5.log 2>&1 </dev/null &
sxmo_hook_start.sh >/tmp/sxmo_hook_start.log 2>&1 </dev/null &
exec dwm >/tmp/dwm.log 2>&1
first_iter=1
while :; do
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
WP_FILE="/usr/share/wallpapers/bananarchy.png"
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper" ]; then
custom_wp="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper" 2>/dev/null)"
[ -n "$custom_wp" ] && [ -f "$custom_wp" ] && WP_FILE="$custom_wp"
fi
WP_FLAG="--bg-fill"
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" ]; then
wp_mode="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" 2>/dev/null)"
case "$wp_mode" in
scale|--bg-scale) WP_FLAG="--bg-scale" ;;
max|--bg-max) WP_FLAG="--bg-max" ;;
center|--bg-center) WP_FLAG="--bg-center" ;;
tile|--bg-tile) WP_FLAG="--bg-tile" ;;
*) WP_FLAG="--bg-fill" ;;
esac
fi
feh --no-fehbg "$WP_FLAG" "$WP_FILE" >/dev/null 2>&1 </dev/null &
if [ "$first_iter" = "0" ]; then
pkill -x conky >/dev/null 2>&1 || true
sleep 0.05
pkill -9 -x conky >/dev/null 2>&1 || true
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
(DISPLAY=:0 CONKY_DPY=:0 setsid conky -c /home/user/.config/sxmo/conky.conf >/dev/null 2>&1 </dev/null &)
pidof -s fcitx5 >/dev/null 2>&1 || fcitx5 -d >/tmp/fcitx5.log 2>&1 </dev/null &
fi
first_iter=0
dwm >/tmp/dwm.log 2>&1 || true
sleep 0.2
done
+4 -2
View File
@@ -157,11 +157,13 @@ case "$1" in
;;
logout)
sxmo_hook_logout.sh || true
case "$SXMO_WM" in
pkill -9 -x conky >/dev/null 2>&1 || true
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
case "${SXMO_WM:-dwm}" in
"i3") i3-msg exit ;;
"sway") swaymsg exit ;;
"river") riverctl exit ;;
"dwm") pkill dwm ;;
"dwm") pkill -x dwm || pkill dwm ;;
esac
;;
togglewm) sxmo_togglewm.sh ;;
@@ -9,7 +9,7 @@
change_alpine() {
echo "Changing timezone to $1"
doas setup-timezone -z "$1"
doas -n setup-timezone -z "$1" 2>/dev/null || doas setup-timezone -z "$1"
sxmo_hook_statusbar.sh time
echo "Timezone changed ok"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+164
View File
@@ -0,0 +1,164 @@
#!/bin/sh
PREFIX=/usr
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"
zroot="$ROOT"usr/share/zoneinfo
usage() {
cat <<-__EOF__
usage: setup-timezone [-h] [-k|-i] [TIMEZONE]
Sets the timezone for the system.
options:
-h Show this help
-i Install tzdata and symlink instead of making a copy
-k Keep previous copies of tzdata
TIMEZONE is relative $zroot.
If TIMEZONE is not specified user will be prompted.
__EOF__
exit $1
}
show_tz_list() {
local i z= list=
local path="$zroot/$1"
[ -d "$path" ] || return 1
for i in $(find $path/ -maxdepth 1); do
case $i in
*.tab|*/) continue;;
esac
if [ -d "$i" ]; then
z="$z ${i##*/}/"
else
z="$z ${i##*/}"
fi
done
( cd_assert $path && ls --color=never -Cd $z )
}
setup_tz() {
local zonepath="$1"
local zone="${zonepath#*/zoneinfo/}"
if ! $INSTALL_TZDATA; then
local zdir="${zonepath%/*}"/
zdir="${zdir#*/zoneinfo/}"
if ! $KEEP_TZDATA; then
rm -rf "${ROOT}"etc/zoneinfo
fi
mkdir -p "${ROOT}"etc/zoneinfo/$zdir
cp "$zonepath" "${ROOT}"etc/zoneinfo/$zdir/
zonepath=/etc/zoneinfo/$zone
fi
rm -f "${ROOT}"etc/localtime
ln -s "$zonepath" "${ROOT}"etc/localtime
printf "%s\n" "$zone" > "${ROOT}"etc/timezone 2>/dev/null || true
if [ -z "$ROOT" ] || [ "$ROOT" = "/" ]; then
rm -f /tmp/sxmo_conky_time_state
if pidof -s Xorg >/dev/null 2>&1; then
su -s /bin/sh user -c '
export PATH="/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin"
export DISPLAY=:0
export XDG_RUNTIME_DIR="/run/user/10000"
export XDG_CONFIG_HOME="/home/user/.config"
sxmo_hook_statusbar.sh time >/dev/null 2>&1 || {
pkill -9 -x conky >/dev/null 2>&1 || true
(DISPLAY=:0 CONKY_DPY=:0 setsid conky -c /home/user/.config/sxmo/conky.conf >/dev/null 2>&1 </dev/null &)
}
' >/dev/null 2>&1 || true
fi
fi
}
INSTALL_TZDATA=false
KEEP_TZDATA=false
while getopts "hikz:" opt; do
case $opt in
h) usage 0;;
i) INSTALL_TZDATA=true;;
k) KEEP_TZDATA=true;;
z) ZONE="$OPTARG";; # backwards compat
'?') usage "1" >&2;;
esac
done
shift $(( $OPTIND - 1))
if [ -z "$ZONE" ]; then
ZONE="$1"
fi
if [ "$ZONE" = "none" ]; then
exit 0
fi
need_apk=true
if [ -d "$zroot" ]; then
if [ -n "$ZONE" ] && [ -f "$zroot/$ZONE" ]; then
need_apk=false
elif [ -z "$ZONE" ] && [ -f "$zroot/UTC" ]; then
need_apk=false
fi
fi
if $need_apk; then
if $INSTALL_TZDATA; then
pkg=tzdata
apkdel=
else
pkg="--force --virtual .setup-timezone tzdata"
apkdel=".setup-timezone"
fi
apk add --no-progress --quiet $pkg || die "Failed to install tzdata package"
if [ -n "$apkdel" ]; then
trap "exit 1" INT TERM HUP
trap "apk del --no-progress --quiet $apkdel" EXIT
fi
fi
if [ -L "${ROOT}"etc/localtime ]; then
default_timezone=$(readlink "${ROOT}"etc/localtime)
default_timezone=${default_timezone#*/zoneinfo/}
else
default_timezone=UTC
fi
if [ -n "$ZONE" ]; then
[ -f "$zroot/$ZONE" ] || die "'$ZONE' is not a valid timezone on this system"
setup_tz "$zroot"/"$ZONE"
else
while true; do
show_tz_list
echo ""
ask "Which timezone are you in? (or '?' or 'none')" "$default_timezone"
timezone=$(printf %s "$resp" | sed 's/\/\+/\//g; s/\/$//')
case "$timezone" in
none|abort) break;;
""|"?") continue;;
esac
while [ -d "$zroot/$timezone" ]; do
show_tz_list "$timezone"
echo ""
ask "What sub-timezone of '$timezone' are you in? (or '?')"
zone=$(printf %s "$resp" | sed 's/\/\+/\//g; s/\/$//')
case "$zone" in
""|"?") continue;;
esac
default_timezone="$timezone"
timezone="$timezone/$zone"
done
if [ -f "$zroot/$timezone" ]; then
setup_tz "$zroot/$timezone"
break
fi
echo "'$timezone' is not a valid timezone on this system"
done
fi
@@ -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)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -549,7 +549,7 @@ int runContactsApp(int argc, char** argv) {
}
};
drawFieldBox(44, 56, editField == 0, "Name (# changes case):", editName,
drawFieldBox(44, 56, editField == 0, "Name (# Input mode):", editName,
"Type name on keypad...");
drawFieldBox(106, 56, editField == 1,
"Number (Hold 0 for +):", editNumber, "Enter phone number...");
+1 -1
View File
@@ -852,7 +852,7 @@ int runFilesApp(int argc, char** argv) {
kWinWidth - 32);
drawPango(layoutSmall, &colMuted, 10, 126, 20,
"0-9: multi-tap #: cycle case", 220);
"# Input mode", 220);
drawSoftkeyBar("Save", "Save",
inputValue.empty() ? "Cancel" : "Del");
+1 -1
View File
@@ -970,7 +970,7 @@ int runModemApp(int argc, char** argv) {
// Row 0: AT Command Input Box (Y=contentY..contentY+46)
drawPango(layoutSmall, &colYellow, 8, contentY, 18,
std::string(kIconTerm) + " AT Command (# mode, * +?=):");
std::string(kIconTerm) + " AT (# Input mode):");
int mbW = pangoTextWidth(layoutSmall, modeBadge);
drawPango(layoutSmall, &colGreen, kWinWidth - mbW - 8, contentY, 18, modeBadge);
+1 -1
View File
@@ -847,7 +847,7 @@ int runNetworksApp(int argc, char** argv) {
drawPango(layoutMain, &colWhite, 24, 100, 34, disp + "_", kWinWidth - 48);
drawPango(layoutSmall, &colMuted, 18, 144, 18,
"[#] Cycle input mode (abc/Abc/ABC/123/Sym)");
"# Input mode", kWinWidth - 36);
drawPango(layoutSmall, &colMuted, 18, 164, 18,
"[*] Toggle Show/Hide password");
drawPango(layoutSmall, &colMuted, 18, 184, 18,
+1 -1
View File
@@ -717,7 +717,7 @@ int runSmsApp(int argc, char** argv) {
if (msgSel) bodyDisp += "|";
if (bodyDisp.empty()) {
drawPango(layoutSmall, &colMuted, 12, 78, 20,
"Type message (0-9, # case)...", kWinWidth - 24);
"Type message (# Input mode)...", kWinWidth - 24);
} else {
pango_layout_set_width(layoutMain, (kWinWidth - 24) * PANGO_SCALE);
pango_layout_set_wrap(layoutMain, PANGO_WRAP_WORD_CHAR);
+1 -1
View File
@@ -827,7 +827,7 @@ int runThemesApp(int argc, char** argv) {
drawPango(layoutSmall, &colMuted, 10, 124, 20,
"Saves to ~/.xthemes/<Name>.xth", 220);
drawPango(layoutSmall, &colMuted, 10, 146, 20,
"0-9: multi-tap #: cycle case", 220);
"# Input mode", 220);
drawSoftkeyBar("Save", "Save", nameInput.empty() ? "Cancel" : "Del");
} else if (mode == ViewMode::ConfirmDelete && !themes.empty()) {
+4 -1
View File
@@ -184,7 +184,10 @@ void applyAndSaveWallpaper(const std::string& path, int modeIdx) {
if (ofs) ofs << kScaleModes[modeIdx].id << "\n";
}
runAsyncCmd(std::string("feh --no-fehbg ") + kScaleModes[modeIdx].fehFlag +
" " + shellQuote(path) + " >/dev/null 2>&1");
" " + shellQuote(path) +
" >/dev/null 2>&1; "
"PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" "
"sxmo_hook_statusbar.sh time >/dev/null 2>&1");
}
int runWallpapersApp(int argc, char** argv) {