Bash Script After User Login


I am having a issue setting up a script to start upon user login. I am using KDE desktop. I am aware I could use systemd or something related with the desktop environment. However, this script requires a terminal for user input and this confuses me. I also want it to only run the first time I long in (just in case I time out and they run again)How can I make this work?



This sounds like an XY Problem.

Why are you running a script, with user input, one time only?

1 Like

Why not use caffeine to prevent your machine from timing out, when that is an issue? Otherwise, let’er time out.

To start vpn and mount encrypted drives.

OK, so definitely an XY Problem.

VPN can be set up via Network Manager and brought up on boot.

Encrypted drives can be mounted separately too - there are various tools to manage that, depending on the encryption you are using.

There shouldn’t be any need for a custom script with very specific runtime requirements.

1 Like

I don’t know if it will be issue just want to make sure it does not become one. If several attempts at mounting are made I don’t know what may happen.

Then don’t use a script, listen to @jonathon.

Gnome-disk-utility can help you with encrypted drive mount options. Select the drive on left and edit mount options (this will edit your fstab).

For the login script you can add the script to be run on login from kde system settings app. Type autostart on the app search bar. However running a vpn will require root previleges i presume so you will have to type in your password each time you login.