You are not logged in.

#1 2014-10-11 05:10:22

misterburt
Member
Registered: 2014-10-11
Posts: 4

Autostarting nm-applet with a .service file

Hello, this is my very first forum post as you can see. Please be gentle.

I'm trying to get nm-applet to autostart with awesome window manager.According to https://wiki.archlinux.org/index.php/Ne … er#Testing

NetworkManager applets are designed to load upon login so no further configuration should be necessary for most users.

but this doesn't seem to be the case for me after enabling NetworkManager.service. I have no issues starting nm-applet w/out the extra stuff designated in the link.

I created the following service file but I cannot figure out how to get it to load.

[Unit]
Description=Start nm-applet in tray panel
After=graphical.target
Requires=NetworkManager.service

[Service]
Type=forking
ExecStart=/usr/bin/nm-applet

[Install]
WantedBy=graphical.target
[rob@X200 ~]$ systemctl --failed
  UNIT                    LOAD   ACTIVE SUB    DESCRIPTION
● start-nm-applet.service loaded failed failed Start nm-applet in tray panel

Here's the output from journalctl:

Oct 10 20:44:24 X200 systemd[1]: Starting Start nm-applet in tray panel...
Oct 10 20:44:24 X200 nm-applet[194]: (nm-applet:194): Gdk-ERROR **: error: XDG_RUNTIME_DIR not set in t
Oct 10 20:44:24 X200 systemd[1]: start-nm-applet.service: control process exited, code=dumped status=5
Oct 10 20:44:24 X200 systemd[1]: Failed to start Start nm-applet in tray panel.
Oct 10 20:44:24 X200 systemd[1]: Unit start-nm-applet.service entered failed state.
Oct 10 20:44:25 X200 systemd-coredump[195]: Process 194 (nm-applet) of user 0 dumped core.

In researching the problem I found on the Ubuntu forums I believe someone saying that certain environmental variables have priority over others and are loaded earlier. This led me to believe I should put in the service file a

After=whatever .service is associated with loading XDG_RUNTIME_DIR 

or perhaps I ought to use the Requires designator? Anyways I couldn't find a working solution after a few days of research and trial and error.

I've tried different variants for the ExecStart field including a .sh script,

ExecStart=/bin/sh -c 'nm-applet'

with no luck.

Hopefully this is a trivial issue to solve. Thanks for taking your time to help me solve this.

Offline

#2 2014-10-11 07:54:12

cargoan
Member
Registered: 2013-07-13
Posts: 20

Re: Autostarting nm-applet with a .service file

systemd-logind.service via pam_systemd.so sets xdg variables.

Offline

#3 2014-10-11 08:22:24

misterburt
Member
Registered: 2014-10-11
Posts: 4

Re: Autostarting nm-applet with a .service file

Thanks for the response. I figured out I don't need to go through the hassle of restarting my computer every single time I'd like to see if changes were made; it's quite a time-saving discovery.


I added the systemd-logind.service to the file and I get the exact same error, despite

[rob@X200 system]$ env | grep XDG_RUN
XDG_RUNTIME_DIR=/run/user/1000

Offline

#4 2014-10-11 12:00:43

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: Autostarting nm-applet with a .service file

I suppose that nm-applet should be available after a DE is up and running. Usually when an user logged into DE.
What about adding nm-applet to $HOME/.xinitrc ?


do it good first, it will be faster than do it twice the saint wink

Offline

#5 2014-10-11 12:33:49

cargoan
Member
Registered: 2013-07-13
Posts: 20

Re: Autostarting nm-applet with a .service file

multiple ways for autostart with awesome:
http://awesome.naquadah.org/wiki/Autostart

Offline

#6 2014-10-11 16:27:35

mindcrime
Member
Registered: 2014-10-11
Posts: 33

Re: Autostarting nm-applet with a .service file

I do it the "simple way" from the link posted above. In rc.lua:

awful.util.spawn_with_shell("nm-applet")

It'll spawn another instance of the applet after restarting the window manager, however. So just kill nm-applet before restarting Awesome:

ps ux
kill -9 xxxx

It's inefficient but assuming you don't restart Awesome every 10 minutes it gets the job done.

Last edited by mindcrime (2014-10-11 16:39:12)


Arch user since August 2014.
Currently flirting with BSPWM ~\\~ CLI enthusiast.
Also currently building an Arch desktop PC. Suggestions welcome!
Please excuse occasional beginner questions.

Offline

#7 2014-10-11 18:56:09

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,397

Re: Autostarting nm-applet with a .service file

It is not easy to start a graphical tool with systemd, because it has to know:
- who is the user that have to run that tool (nm-applet)
- where (on which display)
- what dbus session has to register too  (not entirely sure about this)
- what environment variables will have nm-applet

So take the easy path and start nm-applet from awesome, or if you're brave, take a look to the service file included here:
https://aur.archlinux.org/packages/batterylife/

Last edited by kokoko3k (2014-10-11 18:58:30)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

Board footer

Powered by FluxBB