Because my umpc handles suspend/hibernation poorly, I've had to script a shutdown after timed idle.
The main script:
#!/bin/bash
idletime=$((15601000)) # 15 min in milliseconds 
#idletime=$((520330)) # about one minute, for testing 
idle=0
while [ $idle -lt $idletime ];do
    idle=xprintidle 
    sleep 1 
done 
/home/jake/Scripts_Icons/Word_Shutdown 
sleep 2 
sudo shutdown -P now
The Word_Shutdown script:
#!/bin/bash
if test $(wmctrl -l | grep "Microsoft Word" 2>&1 | wc -l) -eq 1; then
    wmctrl -a "Microsoft Word"
    sleep .2
    xdotool keydown 0xffea + key 4
    sleep .2
    xdotool keyup 0xffea
    sleep .2
    xdotool key y 
fi
It works, but in order to monitor the battery life properly, I would like my uptimes during the sessions on one battery charge to be combined into one uptime.
Is that possible? I see that tuptime will show the uptime of the previous session and start monitoring the uptime of the current session. Is there a way to combine these outputs into a single readout eg 3hr 4 min ?
The tuptime command output:
[jake@P3 ~]$  sudo tuptime -S 2 
System startups:    8  since  06:14:53 PM 06/20/2022 
System shutdowns:   0 ok  +  7 bad 
System life:            17h 50m 4s
System uptime:          16.15%  =  2h 52m 46s 
System downtime:    83.85%  =  14h 57m 18s
Average uptime:     21m 36s 
Average downtime:   2h 8m 11s
Current uptime:     2h 9m 1s  since  09:55:56 AM 06/21/2022
The "System uptime" apparently combines all uptimes between shutdowns.
I have tried:
tuptime | awk -F'=' '/System uptime:/ {print $2}'
It works but, prints the seconds and the leading space as well i.e   2h 52m 46s. Is there a way to cut the seconds and the leading white space, leaving just the hours and minutes i.e. 2h 52m?
Or does uptime itself have a handle that can similarly jiggled?
 
     
    