Thursday, February 22, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1068  / 2 Years ago, tue, september 14, 2021, 1:22:21

I have problem because my friends with I live often forget to shut down our computer.
I don't know how solution use to pretend it. There is ubuntu system installed.

I am looking for solution that user will be force to click and confirm (once a hour) that someone uses computer. If he doesn't it computer automatically should do shutdown.

Is there any solution for this problem ?

More From » shutdown


That's a working script of what you want to do:

while true; do
sleep 59m
zenity --question --text "Are you using the pc (click anything)?"&
#the user has 1 minute to answer, otherwise PC will shut down
sleep 1m
if kill $zenity_id 2> /dev/null; then
#zenity was still running, shutdown the pc
dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown

Every once an hour it displays a pop-up asking 'Are you still here?', if the user clicks on something, then it doesn't shutdown for another one hour (in one hour the pop-up is shown again), but if more than 1 minute passes without interaction with the dialog, then the PC automatically shuts down.
In order to start this on startup, create a file with the above code and make it executable (right click->properties->permissions->allow executing file as program) and click on the power button to the top right of your screen, select startup applications and add this script.

[#38875] Wednesday, September 15, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 11
Total Questions: 121
Total Answers: 109

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago