You are not logged in.

#1 2013-06-17 13:11:02

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

How to restart via dbus after resume from suspend?

Hello world,

I have the following problem sometimes:
The very nice Gnome-Shell extension "system-monitor"'s CPU graph remains sometimes a flat line after resume from standby.
Therefore, I'd like to restart it after resume. I got the two needed pieces for this, but they don't fit together and I don't understand why:

Piece 1: restarting system monitor:

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Extensions.ReloadExtension system-monitor@paradoxxx.zero.gmail.com

works when run from terminal or alt+F2 or from a regular script.

Piece 2: do something sometime after resume:
According to the wiki about systemd, I do that in /etc/systemd/system/resume@.service: (and enabling for myself of course)

[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStart=/bin/sh -c "sleep 20s ; gedit" 

[Install]
WantedBy=suspend.target

this in fact opens gedit 20s after resume, like it should.  (this is just an obvious example, opening gedit is no real use.)

the problem: Piece 1 and 2 don't fit together!
/etc/systemd/system/resume@.service:

[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStart=/bin/sh -c "sleep 20s ; gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Extensions.ReloadExtension system-monitor@paradoxxx.zero.gmail.com" 

[Install]
WantedBy=suspend.target

Doesn't restart my system-monitor!
I also tried by putting the gdbus call in a script (which works) and calling that script by  /etc/systemd/system/resume@.service, but that doesn't work again.

Has anybody an idea what's the problem in putting the two pieces together?
Or how else I can restart the system-monitor after resume automatically?

Offline

#2 2013-06-20 09:09:12

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: How to restart via dbus after resume from suspend?

OK, I'm a bit further and got a error message now:
In /etc/systemd/system/resume@.service I start the script /home/carl/scripts/reload-sys-mon.sh

but that leads to the following error message:

$ sudo systemctl status resume@carl
resume@carl.service - User resume actions
   Loaded: loaded (/etc/systemd/system/resume@.service; enabled)
   Active: deactivating (stop-sigterm) since Do 2013-06-20 10:53:08 CEST; 571ms ago
  Process: 1548 ExecStart=/usr/bin/sh -c /home/carl/scripts/reload-sys-mon.sh (code=exited, status=0/SUCCESS)
   CGroup: name=systemd:/system/resume@.service/resume@carl.service
           └─1554 dbus-launch --autolaunch=0b13b59cd91045ad9b746f7b36da8550 --binary-syntax --close-stderr

Jun 20 10:53:05 cookbook systemd[1]: Starting User resume actions...
Jun 20 10:53:05 cookbook systemd[1]: Started User resume actions.
Jun 20 10:53:08 cookbook sh[1548]: Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any service files 

So the problem is some kind of strange dbus problem: If I execute my reload-sys-mon.sh script directly, it works without problem!
But if systemd calls it, it gives me the error above.
Why?

Reference: the reload-sys-mon.sh script:

#!/bin/bash

sleep 10s && gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Extensions.ReloadExtension system-monitor@paradoxxx.zero.gmail.com

exit 0

And indeed, in  /usr/share/dbus-1/services there is no service file for org.gnome.Shell.
Looking at the other files there, making such a file seems not so hard (just 3 lines, e.g. [D-BUS Service]   Name=org.freedesktop.ColorHelper    Exec=/usr/lib/colord/colord-session), but I don't know what to put in the "Exec=" line. I tried Exec=/usr/bin/gnome-shell, but that didn't work.

So does anyone know how to create such a service file for org.gnome.Shell?

Last edited by Carl Karl (2013-06-20 10:30:22)

Offline

#3 2013-06-20 15:17:44

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: How to restart via dbus after resume from suspend?

OK, another step further:

I get the same error when I run that script as sudo:

sudo sh -c "/home/carl/scripts/reload-sys-mon.sh"
Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Shell was not provided by any .service files

So I suppose the problem is, systemd calls this as root instead of user
(although stated as "[Service]
User=%I")

So the question seems to be now:

How do I call that script on resume as a user, not as root?

Offline

#4 2013-06-20 15:34:28

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: How to restart via dbus after resume from suspend?

Carl Karl wrote:

So the question seems to be now:

How do I call that script on resume as a user, not as root?

No, that seems not to be the question:
Adding a "touch" command to my script shows that the file created by touch has user rights, not root rights.

Strange. :-(

Offline

Board footer

Powered by FluxBB