2

I am running Kubuntu 18.04, and have a simple script to reset the plasmashell every time after suspend/lockscreen since there's a known bug that corrupts folder/file names upon returning from suspend.

#!/bin/bash

dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" |
while read x; do
    case "$x" in
        *"boolean true"*) echo SCREEN_LOCKED;; 
        *"boolean false"*) killall plasmashell | kstart plasmashell;;
    esac
done

This script works fine when run from a terminal.
However, when placed in crontab to load at reboot the process is not loading and can not be found in htop list.

Using crontab -e as the user I've added this in the file

@reboot /home/user/Documents/IK_Scripts/IK_ResetPlasma_BASH.sh > /home/user/Desktop/LogF

The LogF is generated after reboot, but the script does not appear to be loading.

Is this the correct way of having this script running constantly as a background process or is there a correct way of doing that? In essence i would like this script to be loading after reboot and running in the background for whenever i return from lock screen.

Any help will be greatly appreciated!

5
  • What plasmashell are you running at the moment just after a reboot? I don't think you're even logged in when this job runs.
    – Kusalananda
    May 20, 2018 at 17:49
  • it's plasmashell version 5.12.4, if that is what you mean.
    – Petaflop
    May 20, 2018 at 17:53
  • Sure, but it's not running just after a reboot, before you log in, is it? The cron job is likely running before you have the time to log in. Do you get error messages mailed to you by the cron daemon?
    – Kusalananda
    May 20, 2018 at 17:55
  • I think i understand what you mean, but being fairly new to linux i might need a little more help to figure this out. Once loaded shouldn't this script be active all the time, more like a process running in the background? Or better yet, how can i have this script running as a background process all the time?
    – Petaflop
    May 20, 2018 at 17:57
  • would adding the script into an appropriate /etc/rcX.d do the job?
    – Petaflop
    May 20, 2018 at 18:15

1 Answer 1

0

Of course the correct way is the always the easiest and obvious way...

In this case in Kubuntu 18.04 go to:

System Settings --> Startup and Shutdown --> Autostart --> Select the script!

  • Don't forget to make the script file executable!

Works like a charm and the process takes virtually no memory as it is running in the background, and every time i resume the laptop from suspend the folder/file names are not corrupted!

2
  • Is there sensible folder where such scripts would preferably be stored?
    – Max N
    Feb 4, 2019 at 21:13
  • It's your call really. One suggestion is to make a scripts folder in your ~/Documents, thusly these scripts are backuped whenever you backup home.
    – Petaflop
    Feb 6, 2019 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .