You are not logged in.

#1 2009-11-12 23:43:01

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,360

[solved] pm-utils, how to run a script as logged-in user AFTER resume

All the scripts in /etc/pm/sleep.d are run as root. Is there any way for me to put a script such that it runs as my logged-in user AFTER all the scripts in /etc/pm/sleep.d. I tried putting su -c "command" - <username> but that doesn't have the full user environment, hence dbus session bus doesn't work yet.

EDIT: Solved: see solution by lucke below.

Last edited by ngoonee (2009-11-14 20:40:50)


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#2 2009-11-13 16:41:29

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: [solved] pm-utils, how to run a script as logged-in user AFTER resume

It might help to know what command you're having trouble with--perhaps there's a better/easier way to execute it.

The scripts in /etc/pm/sleep.d are called in numeric order during suspend.  That is, if you have a script titled 44-myfix-for-foo, it will run before a script titled 88-myfix-for-bar.  These scripts are then executed in reverse order upon resume.


thayer williams ~ thayerwilliams.ca

Offline

#3 2009-11-13 17:01:25

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [solved] pm-utils, how to run a script as logged-in user AFTER resume

Here's how I handle quitting some apps via dbus before suspend:

1) I save DBUS_SESSION_BUS_ADDRESS in KDE's autostart (echo $DBUS_SESSION_BUS_ADDRESS > /home/lucke/.dbus_session).

2) I run "DBUS_SESSION_BUS_ADDRESS=`cat /home/lucke/.dbus_session` su lucke -c "kquitapp amarok; kquitapp kmix"" in pm-utils.

Offline

#4 2009-11-13 18:13:41

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,360

Re: [solved] pm-utils, how to run a script as logged-in user AFTER resume

Thanks lucke, that sounds a bit hackish but i think it'll work.

And thayer, I know the order of the scripts, but they're all run as root, which was my main issue. I'm trying to run jack2, which uses `jack_control start` to start jack via dbus.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB