This is not an application ready to use!
I label this as experimental here!
What it's about:
I saw some desktops providing an icon to shutdown immediately or similar.
What happens to me often is, that i have applications with unsaved changes on different desktops. So when i shutdown, all these unsaved changes are lost due to killing the WM.
Here's something to try out:
A friendly shutdown app that doesn't just kill apps but tries to close programs gracefully when shutting down, rebooting, restarting wm or exiting to prompt.
(Xorg terminate keyboard shortcut ctrl+alt+backspace will not be altered)
What it does:
Move open windows to the current desktop, activate them and send the key code alt+F4.
This will request a 'Close' command by jwm rather than just killing windows with unsaved content.
Closing a window with unsaved changes should bring up a save dialog which then prevents from shutting down.
Problem is to merge this with Puppy installs.
When creating this as ROX application directory it is possible to just drag it to desktop and use its optional rightclick menu.
Implementation into regular shutdown process seems to be more complicated.
Important notes:
· Do not run this from a terminal!!
· Older versions of xdotool do not support command chaining and may cause errors...
· wmexit code verified/tested downwards compatible to slacko 6.3.2 (so i guess it works in woofCE created puppies later than 2016)
· This ROX Application Directory was build with xdotool binaries from slacko(32 and 64bit)14.2 repos used as fallback in case there is no xdotool installed.
· NO WARRANTY - Use at your own risk
Comments, suggestions and/or improvements welcome
EDIT:
attachment removed last but not least due to licensing voilation.
AppRun:
Code: Select all
#!/bin/bash
# close open programs gracefully
# do not run in terminal
[ -t 0 ] && exit 1
[ -z "$(which xdotool)" ] && exit 2
# move open windows to active desktop, activate window and send key alt+F4
PROP="$(xprop -root _NET_CLIENT_LIST_STACKING _NET_CURRENT_DESKTOP)"
STACK="${PROP%$'\n'*}"
STACK="${STACK#*\#}"
DESK="${PROP##* }"
# on slow machine longer sleep needed (tested: Atom N270 ~1s)
for WID in ${STACK//,}; do
xdotool set_desktop_for_window $WID $DESK sleep .2 windowactivate --sync $WID key alt+F4
[ $? -ne 0 ] && echo "Your xdotool is too old..." 1>&2 && break
done
# all windows closed?
PROP="$(xprop -root _NET_CLIENT_LIST_STACKING)"
[ "${PROP#*\#}" = " " ] || exit 255
# weird situation here: button ok returns 0, timeout returns 255
Xdialog --title Shutdown --buttons-style text --ok-label 'Oh no!!' --timeout 5 --msgbox 'Shutdown' 200x80
[ $? -eq 0 ] && exit 255
wmpoweroff $@
AppInfo.xml:
Code: Select all
<?xml version="1.0"?>
<AppInfo>
<Summary>Close apps gracefully and shutdown</Summary>
<Summary xml:lang="de">Programme "höflich" beenden und herunterfahren</Summary>
<AppMenu>
<Item option="wmpoweroff">
<Label>Shutdown</Label>
<Label xml:lang="de">Herunterfahren</Label>
</Item>
<Item option="wmreboot">
<Label>Reboot</Label>
<Label xml:lang="de">Neu starten</Label>
</Item>
<Item option="restartwm">
<Label>Restart WM</Label>
<Label xml:lang="de">Desktop neu starten</Label>
</Item>
<Item option="wmexit">
<Label>Exit to prompt</Label>
<Label xml:lang="de">Desktop beenden</Label>
</Item>
</AppMenu>
</AppInfo>
.DirIcon:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="100" width="100">
<circle cx="50" cy="48" r="45" style="fill:#FFF"/>
<circle cx="50" cy="48" r="45" style="fill:#c52727;opacity:0.8"/>
<circle cx="50" cy="52" r="45" style="fill:#000;opacity:0.3"/>
<circle cx="50" cy="50" r="45" style="fill:#c52727"/>
<g style="fill:none;stroke:#fff;stroke-width:10px;stroke-linecap:round;stroke-linejoin:round;">
<path d="m 50,16 0,25"/>
<path d="m 70,26 a 30,30 0 1 1 -40,0"/>
</g>
</svg>