#!/bin/sh # icewm-sessions-update [] -- write IceWM's "Switch desktop" submenu to # ($XDG_RUNTIME_DIR/icewm-switch-desktop.menu, the file /etc/icewm/menu # includes): one entry per installed session other than IceWM, each running # brintos-session switch. With no other session the file is removed, and the # menu has no submenu. /etc/icewm/startup runs this when the IceWM session # starts, so the submenu follows the sessions installed at that moment. The # submenu is the session's own file, not a line in /etc/icewm/menu, so a # read-only root has it too. if [ -n "$1" ]; then out=$1 elif [ -n "$XDG_RUNTIME_DIR" ]; then out=$XDG_RUNTIME_DIR/icewm-switch-desktop.menu else exit 0 fi LC_ALL=C export LC_ALL new=$out.new.$$ trap 'rm -f "$new"' EXIT # The icon: IceWM's own for the session where it has one, Weston's logo for # weston, else none ("-"). IceWM's "app" icon is a red cross. icon() { for f in /usr/share/icewm/icons/${1}_16x16.*; do [ -e "$f" ] && { echo "$1"; return; } break done case $1 in weston) [ -f /usr/share/weston/wayland.png ] && { echo /usr/share/weston/wayland.png; return; } ;; esac echo - } brintos-session-others icewm | { any= while IFS=" " read -r n t; do [ -n "$any" ] || echo 'menu "Switch desktop" folder {' any=1 printf 'prog "%s" %s brintos-session switch %s\n' "$(printf '%s' "$t" | tr -d '"')" "$(icon "$n")" "$n" done [ -z "$any" ] || echo '}' } > "$new" || exit 1 if [ ! -s "$new" ]; then rm -f "$out" exit 0 fi cmp -s "$new" "$out" && exit 0 chmod 0644 "$new" && mv -f "$new" "$out"