Created
July 22, 2021 15:25
-
-
Save dmgl/da819efed77e5e1bfb99c41ba62b6bb5 to your computer and use it in GitHub Desktop.
Autoenable bluetooth (added to startup)
This file contains 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
#!/usr/bin/env bash | |
OBJECT_PATH=/org/freedesktop/login1/session/$XDG_SESSION_ID | |
BUS_NAME=org.freedesktop.login1 | |
UNLOCK="$OBJECT_PATH: $BUS_NAME.Session.Unlock ()" | |
GDBUS_MONITOR="gdbus monitor --system --dest $BUS_NAME --object-path $OBJECT_PATH" | |
function log { | |
echo "$(date +'%F %T.%3N') [$$]" "$@" | |
} | |
function run_daemon { | |
local signal | |
while read -r signal; do | |
log "$signal" | |
if [[ $signal == "$UNLOCK" ]]; then | |
sleep 2 | |
btnum=`rfkill list|grep hci0| cut -f 1 -d ':'` | |
rfkill block $btnum | |
rfkill unblock $btnum | |
log "bluetooth enable" # >> dmgl_enable_bluetooth_log.txt | |
fi | |
done < <(eval "exec $GDBUS_MONITOR") | |
} | |
run_daemon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment