Run a script at unlock?
Asked Answered
A

3

6

Hey, I'd like to get a shell script to run everytime I unlock my computer, on KDE 4. I learned that I could run one by overwriting /usr/lib/kde4/libexec/krunner_lock with a shell script doing its thing, then the original krunner_lock binary, and I'd basically want to do the opposite: launch a script that "undoes" what the locking script does. I'm on Kubuntu 9.04 64-bit but I appreciate answers for any operating system, in case I ever want to do the same on that system.

Adduct answered 30/5, 2009 at 1:19 Comment(0)
A
2

Figured it out on the KDE forums here. Porges's solution is pretty close to the answer but it's not quite there yet. You have to pass the arguments that the script receives to the real krunner_lock, like so: krunner_lock_bin $@

Adduct answered 30/5, 2009 at 1:20 Comment(1)
just curious if "real krunner_lock" eq "real_krunner_lock"Quantify
A
1

Version for year 2015 that works under Kubuntu 14.10 using the Desktop Widgets locker:

#!/bin/bash

lockpidname="/usr/bin/plasma-overlay --nofork"

$lockpidname

check_slock () {
if [[ $(pgrep -fla $lockpidname) ]]; then 
SLOCKED=1
else
SLOCKED=0
fi
}

while true; do
  sleep 5
  check_slock
  case $SLOCKED  in 
  0) 
  echo "System unlocked run something here"
  break
  ;; 
  esac

done

This is for situation when you want to assign CTRL+ATL+L combination under the Custom section within the Global Keyboard Shortcuts.

Atli answered 30/5, 2009 at 1:20 Comment(0)
T
1

Reading from this page, it seems like krunner_lock will stay running as long as the screen is locked, so you should be able to place the commands after the line that runs it and they will run once the screen unlocks.

e.g.

#!/bin/bash
...
# do stuff
...
real_krunner_lock # exits once screen unlocks...
...
# undo stuff
Teaching answered 30/5, 2009 at 1:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.