Announcement

Collapse
No announcement yet.

excuting .sh scripts on startup or shutdown

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [DESKTOP] excuting .sh scripts on startup or shutdown

    I've searched through KFN, and I cannot find a question regarding the placement and execution of a start or shutdown script.. I have it on my VM, to backup to another drive some important settings (not everything like you would with a backup).
    My only thought is I asked this somewhere else, version 19 (that's the VM original Version) on the Internet. As my Profile suggests, I just don't remember where.
    I've also search and read about 17 different ways to do this. All don't make sense, or as I am reading them, my brain isn't following.
    My code was
    set %T (Date %yy%MM%DD)
    Set %F = (kubuntu-settings)
    something maybe copy (/attached drive/backup/(%T-kubuntu-%F)
    /End
    Or Very Similar. I cannot access that .sh file ATM.

    Can someone, whom knows how, please post a guide or walk through that is easy enough to understand.
    Many Thanks

    #2
    For the simple approach, for KDE plasma, in 24.04 in system settings, under the system heading, it's called "Autostart". In previous releases it was under a different heading and called something like "start up and shutdown".

    You can also put files in ~/.config/plasma-workspace/env, They show in system settings as "Pre-startup Scripts", but one can't add them there. At one point I found it necessary to use that place to set environment variables for all of plasma, because the ancient .profile and .bashrc mechanisms were being run too late. Note that the scripts are run by dash, which does not honour a "shebang" (the first line of the script saying something like #!/bin/bash); using bash syntax just makes the script silently exit.

    There's also several ways to do this with systemd, putting files somewhere in /usr/lib/systemd or /etc. Then they happen at system startup, rather than log in and out (assuming that you don't automatically log in). You can't do desktop environment stuff then.

    Regards, John Little

    Comment

    Working...