Created
December 7, 2018 12:27
-
-
Save ducdigital/c5e218a78493c219a33661885eebe076 to your computer and use it in GitHub Desktop.
Auto-lock your KDE when bluetooth device disconnected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| isLocked=false | |
| macaddress=00:00:00:00:00:00 | |
| while true; do | |
| connected=$(bluetoothctl connect $macaddress) | |
| if [[ $connected == *"org.bluez.Error.Failed"* ]]; then | |
| if $isLocked; then | |
| sleep 5 | |
| else | |
| loginctl lock-session | |
| isLocked=true | |
| sleep 15 | |
| fi | |
| else | |
| isLocked=false | |
| fi | |
| sleep 1 | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this script to work, you will need to have
bluetoothctlavailable and have your device paired.Change the
macaddressvariable to your device MAC address