Bug 447058 - Unable to add Login Script, or run scripts after Login
Summary: Unable to add Login Script, or run scripts after Login
Status: RESOLVED NOT A BUG
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Nicolas Fella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-16 03:43 UTC by Winston Nolan
Modified: 2021-12-22 04:33 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Startup Scripts (211.70 KB, image/png)
2021-12-16 03:43 UTC, Winston Nolan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Winston Nolan 2021-12-16 03:43:49 UTC
Created attachment 144590 [details]
Startup Scripts

SUMMARY
I want to run a script after logging into kde. On this page, https://userbase.kde.org/System_Settings/Autostart it mentions I create a Login Script. Within System Settings > Startup and Shutdown > Autostart there is no such option 

STEPS TO REPRODUCE
1. Navigate to System Settings > Startup and Shutdown > Autostart
2. Try to add a Login Script
3. Option does not exist

SOFTWARE/OS VERSIONS
Ubuntu: Ubuntu 20.04.3 LTS
Linux/KDE Plasma: plasmashell 5.18.5

ADDITIONAL INFORMATION
I have tried to add a progran, and a script and none of these work
Comment 1 Nicolas Fella 2021-12-16 13:10:37 UTC
The UI for this was redesigned at some point after your Plasma version and the documentation shows the new design.

The scripts seen in your screenshot should be executed on login ("Startup" in the old UI should be the same as "Login" in the new UI).

make sure that your script files are executable, i.e. make sure that running "./restart-latte-dock.sh" in a terminal works
Comment 2 Winston Nolan 2021-12-16 19:18:25 UTC
The script I am trying to run is meant to restart latte-dock after my laptop wakes up from sleep, after I login to KDE
The script looks like

➜ cat ./bin/restart-latte-dock.sh          
#!/usr/bin/env bash
/usr/bin/latte-dock --replace &
08:17:22 in ~ 
➜ ls -la ./bin/restart-latte-dock.sh                       
-rwxrwxr-x 1 win win 52 Dec  2 07:44 ./bin/restart-latte-dock.sh

But latte dock does not restart after I login to KDE
Comment 3 Nate Graham 2021-12-16 19:43:46 UTC
> after my laptop wakes up from sleep, after I login to KDE
Those are two different things. Which one do you want? Because we have "execute on login" scripts but we don't have "execute on wake up" scripts.
Comment 4 Winston Nolan 2021-12-16 19:47:56 UTC
When my laptop wakes up from sleep, I have to login to KDE. I wanted to run the script at that point (after I have logged into KDE)
Comment 5 Nicolas Fella 2021-12-16 19:48:59 UTC
You mean after you entered you password to unlock the screen?
Comment 6 Winston Nolan 2021-12-16 19:51:28 UTC
> You mean after you entered you password to unlock the screen?
Yes

At the end of the day, I close my laptop lid, and my laptop enters sleep mode. When I open my lid, I log into KDE, and I can continue where I left off. At this point my latte dock has the fuzzy graphics bug, from NVIDIA, and I have to run my script manually each time to restart latte dock. I wanted to automate that
Comment 7 Nate Graham 2021-12-16 19:57:24 UTC
OK, that's not logging in, that's unlocking the screen. So a login script will not automatically run when you unlock the screen. That is perhaps the source of the issue. The script should run when you log in after explicitly logging our or restarting the computer, but not when you unlock the screen.

Instead of manually having a script to restart latte dock on wakeup/unlock, it might be useful to file a bug report to the latte-dock prodict so that whatever bug you're trying to work around can be fixed properly. :)
Comment 8 Winston Nolan 2021-12-16 20:00:08 UTC
Thank you very much for phrasing what happens correctly
I was thinking that I am "Logging into KDE" but what I am actually doing is "Unlocking my session"

This is definitely not a bug then and I am marking it as not a bug

Thank you for all the assistance, I'm a big fan of KDE
Comment 9 Nate Graham 2021-12-16 20:25:00 UTC
You're welcome!
Comment 10 Winston Nolan 2021-12-22 04:33:04 UTC
Just dropping the fix here

I created a script with the contents

```
#!/usr/bin/env bash
# https://unix.stackexchange.com/a/361612/386718
dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" |
  while read x; do
    case "$x" in 
      *"boolean true"*) /usr/bin/sleep 1;;
      *"boolean false"*) /usr/bin/sleep 1 && /usr/bin/latte-dock --replace &;;  
    esac
  done
```

I added this script to be executed at startup

This script will listen to events for lock and unlock and restart latte dock on an unlock event