Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 20023  / 2 Years ago, sat, august 20, 2022, 7:04:46

Running: Xubuntu 14.04 32-bit.


I have read several outdated, not working, working different that I want answers here and elsewhere. I had a script that resulted in shutting my Laptop down at boot time after I set it to autostart.


I also tried it install complexshutdown despite that tool having died in 2011 and has a bug on Lauchpad that his exact option is not available. It not even installed on 14.04 here.


I am looking for a simple straightforward script that is actually tested and working that I can put into the autostart that is doing nothing but checking for activity (mouse/keyboard) and shutting down my laptop if there was none for 2 hours.


Thanks.


More From » scripts

 Answers
7

This is probably the best solution. No need for screensaver tweaking and running.



Install sudo apt-get install xprintidle



Put this script into autostart:



#!/bin/bash

idletime=$((1000*60*60*2)) # 2 hours in milliseconds

while true; do
idle=`xprintidle`
echo $idle
if (( $idle > $idletime )); then
#sudo shutdown -P now
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true
fi
sleep 1
done


The comments and @Jobin 's answer did lead me to investigate myself again and I actually found a unfinished script with xprinttime but without any loop in the script. Probably not finished this because my linux/bash knowlege was not good at the time. I also did put the script I had in rc.local or something like that triggered the shutdown on boot. Thanks to @Jobin for the reminder how to add startup apps in XFCE, I already knew this but ... and credits for the dbus thing, never saw that, better then shutdown since it not requires root.


[#26215] Saturday, August 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
utschang

Total Points: 357
Total Questions: 120
Total Answers: 119

Location: Croatia
Member since Sat, May 2, 2020
4 Years ago
utschang questions
Mon, Aug 30, 21, 14:09, 3 Years ago
Tue, May 17, 22, 20:44, 2 Years ago
Sun, Jul 11, 21, 23:54, 3 Years ago
Tue, Sep 7, 21, 04:23, 3 Years ago
;