You are not logged in.
Hello,
This is the first time i made a service for systemd myself, and i can't get it to work ![]()
The service is simple; since xmobar fails to refresh itself after waking up the laptop (which i can't find a fix), i wanted to make a service to kill the process everytime the laptop wakes and restart a new one.
Here is the content of my service, located in /usr/lib/systemd/system :
[jape@T420 system]$ cat refreshxmobar.service
[Unit]
Description=MADEBYJPBD Refresh xmobar script
After=suspend.target
After=hibernate.target
[Service]
Type=oneshot
User=jape
Environment=DISPLAY=:0
ExecStart=/usr/bin/refreshxmobar
[Install]
WantedBy=sleep.target
WantedBy=hibernate.target[jape@T420 system]$ pwd
/etc/systemd/system
[jape@T420 system]$ cat refreshxmobar.service
[Unit]
Description=MADEBYJPBD Refresh xmobar script
After=suspend.target
After=hibernate.target
[Service]
Type=oneshot
User=jape
Environment=DISPLAY=:0
ExecStart=/usr/bin/refreshxmobar
[Install]
WantedBy=sleep.target
WantedBy=hibernate.target
[jape@T420 system]$ Here's the content of /usr/bin/refreshxmobar :
[jape@T420 system]$ cat /usr/bin/refreshxmobar
#!/bin/sh
if pidof -s xmobar > /dev/null; then
echo 'present';
pkill xmobar && xmobar&
else
echo 'non';
xmobar&
fiWhen trying to enable using
sudo systemctl enable refreshxmobar.servicesymlinks are created both for hibernate and sleep.
when starting, it simply kills xmobar, nothing else, and the service does not appear on the list if i use the systemctl command.
What am i doing wrong?
Thanks.
ThinkPad P16s AMD / KDE
Offline
1. you don't need both hibernate.target and sleep.target, only one will do
2. your service is oneshot, so when you start the service it kills xmobar and exit, about restarting xmobar check running your script directly in terminal
I would suggest to make this service simple and enable it rather than starting it, and see what happens on reboot/restart.
Last edited by Docbroke (2016-02-10 07:30:27)
Arch is home!
https://github.com/Docbroke
Offline
This won't work anyway, whenever I kill & restart xmobar from the X session the stdin reader doesn't work because the program startup is mediated from the xmonad binary.
It just does this:
How are you starting xmobar?
I call it from xmonad.hs: https://github.com/Head-on-a-Stick/conf … nad.hs#L15
My xmobar refreshes just fine after waking from suspend.
Jin, Jîyan, Azadî
Offline
This won't work anyway, whenever I kill & restart xmobar from the X session the stdin reader doesn't work because the program startup is mediated from the xmonad binary.
It just does this:
http://s15.postimg.org/4avln8hmf/2016_0 … _scrot.png
How are you starting xmobar?I call it from xmonad.hs: https://github.com/Head-on-a-Stick/conf … nad.hs#L15
My xmobar refreshes just fine after waking from suspend.
I am not using xmonad. xmobar runs as standalone and it works manually so i guess there is no reason it cannot be automated.
1. you don't need both hibernate.target and sleep.target, only one will do
2. your service is oneshot, so when you start the service it kills xmobar and exit, about restarting xmobar check running your script directly in terminalI would suggest to make this service simple and enable it rather than starting it, and see what happens on reboot/restart.
This is what it currently looks like :
[jape@T420 system]$ cat refreshxmobar.service
[Unit]
Description=MADEBYJPBD Refresh xmobar script
After=sleep.target
[Service]
User=jape
Environment=DISPLAY=:0
ExecStart=/usr/bin/refreshxmobar
[Install]
WantedBy=sleep.targetIf i enable the service, it does not appear on my list when i issue the command systemctl.
systemctl status refreshxmobar.service gives me the following (i issued a start command 3 times, all it did was kill my xmobar) :
[jape@T420 system]$ systemctl status refreshxmobar.service
● refreshxmobar.service - MADEBYJPBD Refresh xmobar script
Loaded: loaded (/etc/systemd/system/refreshxmobar.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Feb 10 18:13:22 T420 systemd[1]: Started MADEBYJPBD Refresh xmobar script.
Feb 10 18:23:29 T420 systemd[1]: Started MADEBYJPBD Refresh xmobar script.
Feb 10 18:23:29 T420 refreshxmobar[3984]: present
Feb 10 18:23:42 T420 systemd[1]: Started MADEBYJPBD Refresh xmobar script.I still can't put my finger on what i am doing wrong ![]()
thanks.
ThinkPad P16s AMD / KDE
Offline
did you reboot after enabling the service?
you have removed service type, I suggest 'Type=simple'
also try running your script directly in terminal, what does it do,
refreshxmobarif the script works as intended, next step is to look at your service, if scipt doesn't work fix it first. I am not using xmobar so can not test it.
Arch is home!
https://github.com/Docbroke
Offline
did you reboot after enabling the service?
you have removed service type, I suggest 'Type=simple'
What would a reboot accomplish? It's tied to sleep, not boot. And "simple" is implied, but then xmobar shouldn't be backgrounded -- with the script as it is, setting it to "forking" would prevent xmobar from being killed when the script exits.
But that would probably only make it work for the first time you resume from sleep, because the service will already be running when subsequent sleeps are initiated. As a quick fix, you could try it as follows. Start xmobar (from ~/.xinitrc or similar) with a small wrapper script like this:
while :; do xmobar; doneAnd combine this with a oneshot service that runs after sleep.target and simply kills xmobar (so you can do without the refreshxmobar script and the Environment setting).
Offline
After enabling service it starts on next boot.
When I first created service for slock to start after sleep, it did immediately lock the screen on starting the service but didn't lock after suspend, but when I did enable it it was working as intended. Some services works well only after reboot, simply starting the service didn't work well.
Arch is home!
https://github.com/Docbroke
Offline