Created
May 30, 2022 06:22
-
-
Save cshuaimin/04406113e5106ab0d591d8ff20b96091 to your computer and use it in GitHub Desktop.
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/nu | |
let dev = '/sys/class/backlight/acpi_video0/brightness' | |
let back = '/tmp/backlight' | |
gdbus monitor -y -d org.freedesktop.login1 | |
| each { |line| | |
^echo ($line | parse -r ''LockedHint': <(?P<locked>\w+)>' | get 0.locked) | |
| into bool | |
| if $in { | |
^cp $dev $back | |
} else { | |
sudo nu -c $'open ($back) | save ($dev)' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment