GNOME Bugzilla – Bug 333031
run user scripts before doing stuff
Last modified: 2020-11-07 12:18:52 UTC
It would be useful if g-p-m would run user defined scripts before doing stuff. See http://xvsxp.com/power/ http://xvsxp.com/power/images/ups33.jpg http://xvsxp.com/power/images/ups-configuration.jpg for how OS X and Windows XP does this. I think just having /etc/gnome-power-manager/admin-scripts/<X>.d/ directories where X = {suspend, hibernate, shutdown, battery_critical, on_ups_power} is sufficient. Needs some thinking about exactly what actions are useful. Could pass reasons and hal udi's in the environment. Should run these scripts in the context of the user (e.g. pass $DISPLAY and $DBUS_SESSION_BUS_ADDRESS) so they can interact with the desktop. Run all scripts in sequence (alphabetically) one after one. If a script returns something != 0 it means cancel the action. Also means other scripts following the one that returns != 0 isn't called. If scripts need root the admin can setuid himself. g-p-m should ship with no scripts whatsoever - this should _only_ be used by the admin.
>/etc/gnome-power-manager/admin-scripts/<X>.d/ per-system (etc) or per-user (/home/foo/.gnome)? >Run all scripts in sequence (alphabetically) one after one. You do this already in HAL, and I was wondering if you can point me towards how you did this. I'm not lazy, I'm busy. Honest! >g-p-m should ship with no scripts whatsoever - this should _only_ be used by >the admin. What about some sample code, that is commented out, like #uncomment and change the email to your admin email address to send an email #fooo richard@hughsie.com Richard.
> per-system (etc) or per-user (/home/foo/.gnome)? It's an admin feature so per-system. > > Run all scripts in sequence (alphabetically) one after one. > You do this already in HAL, and I was wondering if you can point me towards how > you did this. I'm not lazy, I'm busy. Honest! We don't do this anymore in hal... However look at hal/hald-runner for info on how to spawn executables... > What about some sample code, that is commented out, like No, I don't think we don't want the overhead. If the admin uses this feature he better knows what he is doing. Suggest to include examples in the user guide though.
Okay, I've been thinking about how and why to impliment this. What stuff could the user want in the scipts to run at shutdow, suspend, ups_low etc? The notion of having scripts to configure is sort of odd, considering the whole idea of this g-p-m/hal thing is to "just work". The only actions that I can comprehend are: [*] Email someone of the event The rest of the stuff in my head (stopping and starting services, telling evolution we are going to suspend, etc) should just work without using scripts using the registration interface we talked about. You got any more ideas for examples, so I can justify adding a whole chunk of new code? Thanks.
Sorry to blow my own trumpet here, but this is exactly the kind of thing upstart is designed for.
Umm. I don't get how upstart could help us in this regard...
This is exactly what it's designed to do, run user scripts (or sysadmin scripts, or package scripts) on system events. Rather than deal with with iterating a directory yourself, building an environment, spawning a process, dealing with killing it, etc. you would just send an event to upstart (via dbus, if you like) and have it take care of that.
This should be useful for me because... I want to send messages to gaim to disconnect all accounts on suspend and to reconnect them on resume using DBus. I wrote a working script in python but if I use OnSuspend and OnResume in the hibernate configuration to start it, the script runs with root privileges and it doesn't work as it should (I want to interact with some applications using the DBus session of the user that runs g-p-m).
Laurento, can you attach your scripts? I can add them to gnome-power-manager if you wish - I already include actions to deal with NetworkManager and gnome-screensaver.
Created attachment 78833 [details] simple_gaim_ctrl.py Sure! Here you are. These are the script options: --version show program's version number and exit -h, --help show this help message and exit -c, --connect Connect ALL Gaim account -d, --disconnect Disconnect ALL Gaim account You can combine -c and -d (-cd or -dc) to reconnect all account if you want.
Okay, I think it's best we just provide a DBUS api that applications get notifiaction hooks for. I'll talk to the GAIM guys and see what they think of the idea.
bugzilla.gnome.org is being replaced by gitlab.gnome.org. We are closing all old feature requests in Bugzilla which have not seen updates for many years. If you still use gnome-power-manager and if you are still requesting this feature in a currently supported version of GNOME (currently that would be 3.38), then please feel free to report it at https://gitlab.gnome.org/GNOME/gnome-power-manager/-/issues/ Thank you for reporting this issue and we are sorry it could not be implemented.