In order to handle monitor hotplug I've created a unit that launches a script that detects plugged monitors and do appropriate action, code is here

In monitor_hotplug.sh I reload different processes using some signals or options :

   # Or restart panel 
   xfce4-panel -r

   #reload conky
   killall -s SIGUSR1 conky 

But in some cases I have to reload process like this:

  # restart  plank
  killall -s SIGHUP plank

It has some drawbacks :

  • unit active until plank termination
  • plank starting must be last command in script
  • I cannot start several processes like this

To solve it, I ve change unit type to forking, and starting plank as a background process

  # restart  plank
  killall -s SIGHUP plank

Is it the correct way to do this? How can I restart other processes like this from script?

  • IMVHO this is quite a dirty hack. Cannot you just kill plank and rely on the mechanism initially starting it to respanw it? Aren't plank and the other processes (xfce4-panel, conky) automatically detecting the change? – Bigon Jan 9 '18 at 10:13
  • Unfortunately, plank xfce4-panel conky must be manually refreshed when monitor configuration changed. I cannot rely on plank starting mechanism (xfce application startup), there is no option to restart an exited process. – rem Jan 9 '18 at 11:25
  • The problem here by restarting plank like this is that it will end up with a different environment, being set in a different systemd session and will probably not be killed properly when closing your session (and will have a wrong security context is you are using SELinux). – Bigon Jan 9 '18 at 11:34
  • Sure. I've change script to kill plank from monnitor_hotplug.sh script. It is automatically restarted using plank_forever.sh script that is started from xfce startup application menu. Service can now be a 'simple' service' – rem Jan 10 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.