4

We've been using sleepd with ubuntu 12.04 to put public desktops to suspend after 5-10 minutes of inactivity. We are planning to deploy 13.10 (later move to 14.04), and have found out that sleepd package is missing.

Is there any other tool or a system wide setting to do this job? How other system administrators solve this problem?

EDIT: In our dormitory we have 90+ students. Some have regular user access and some use only the guest account. The solution must work when there aren't any users logged in.

gajdipajti
  • 3,451

3 Answers3

1

I didn't test it, I could be missing a step.

  1. Use System Setting → Power / Brightness. Set all setting you need and as you want
  2. Create an override file from the current user settings and place it in /usr/share/glib-2.0/schemas/

    echo "[org.gnome.settings-daemon.plugins.power]" > 90_mypower.gschema.override
    gsettings list-recursively org.gnome.settings-daemon.plugins.power | awk '{ gsub("org.gnome.settings-daemon.plugins.power ","") ; print $1"="$2 }' >> 90_mypower.gschema.override
    
    sudo mv 90_mypower.gschema.override /usr/share/glib-2.0/schemas/
    sudo chown root:root /usr/share/glib-2.0/schemas/90_mypower.gschema.override
    sudo chmod +r /usr/share/glib-2.0/schemas/90_mypower.gschema.override
    
  3. Compile the schemas

    sudo glib-compile-schemas /usr/share/glib-2.0/schemas
    
  4. Create a lock file for all org.gnome.settings-daemon.plugins.power keys and place it in /etc/dconf/db/gdm.d/locks/

    gsettings list-keys org.gnome.settings-daemon.plugins.power | xargs -L 1 -I{} echo /org/gnome/settings-daemon/plugins/power/{} > 90-mypower-locks
    
    sudo cp 90-mypower-locks /etc/dconf/db/gdm.d/locks/90-mypower-locks
    sudo chown root:root /etc/dconf/db/gdm.d/locks/90-mypower-locks
    sudo chmod +r /etc/dconf/db/gdm.d/locks/90-mypower-locks
    
  5. Update for locks

    sudo dconf update
    

As you are looking for system administration, nice to learn:

  1. Watch dconf for change

    dconf watch /
    
  2. Change power setting from GUI, watch for messages

  3. Open dconf-editor, go through same path, select a key
  4. Look at bottom, it shows its schema name/id: org.gnome.settings-daemon.plugins.power

References:

user.dz
  • 48,105
  • This is a different approach, and needs a bit more testing than the modified sleepd answer. I'll give this also a try in the weekend. Thank you for the references. – gajdipajti Feb 19 '14 at 14:12
1

On the bottom of this answer are instructions for installing sleepd if you really insist. However that package is pretty much outdated for modern hardware.

If you are going to write a program, you can consider the following sources:

Instead of using sleep(3) in the code (like sleepd does), it is more battery-friendly if you use poll(3) or select(3) which have a timeout parameter. (This assumes that the /dev/input/* devices are poll-able, I don't know if that is the case but you should look up the documentation)


Upstream (git repo) has already removed the default hal dependency (commit), so you can try building from sources. The following commands were tested in a Kubuntu 13.10 Live environment. It installs the build dependencies, fixes a bug in the Makefile that prevented HAL from getting disabled and finally creates a deb package.

sudo apt-get install build-essential git debhelper libapm-dev
git clone git://git.kitenet.net/sleepd.git
cd sleepd
sed 's/ifdef USE_HAL/ifeq ($(USE_HAL), 1)/' -i Makefile
dpkg-buildpackage -b -us -uc

This produces a sleepd_2.05_amd64.deb package in the parent directory which you can then install on machines. This package requires a battery or AC interface to be present (e.g. /sys/class/power_supply/*), otherwise it will try APM. Since modern machines do not use APM, but ACPI, it will exit silently.

So while the package builds and install fine, you are better off with writing a new daemon if something like this is not already implemented.

Lekensteyn
  • 174,277
  • Thank you for your answer. I will give it a try in the weekend. – gajdipajti Feb 19 '14 at 14:09
  • Sorry for not answering. I tried the git method, and as you have written it won't work when there is nothing in power_supply. – gajdipajti Mar 30 '14 at 12:51
  • Thanks for the guide. The repo has since moved to here. I found I needed to use -H (and I also used -E) in /etc/default/sleepd. My final config was: PARAMS="-H -E -c 60 -u 900 -U 3600 -b 3" – joeytwiddle Dec 09 '15 at 15:20
0

is the power settings under system settings missing because thats where you can graphically set the time

enter image description here

as you can see if you have this which I'm sure you have, then you can modify it.

Zuko
  • 1,267
  • 11
  • 12
  • 3
    This is only for one user, and when a user is logged in. I need a system wide solution, which cannot be modified by users accidentally. Sorry, I wasn't specific. – gajdipajti Feb 16 '14 at 10:29