Question

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.

Was it helpful?

Solution

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 $@

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top