You are not logged in.
I just got a new mouse, a Logitech G203. I love it! But it came with a little bonus surprise: it has a super bright color-cycling LED light. ![]()
I'd like a way for the mouse LED to turn off when not in use. It makes sense to me to do this when the display turns off? I have this in my "~/.xinitrc" file:
xset dpms 0 0 1800 # Turn off the monitor after 30 minutesI also have a keyboard shortcut that runs:
sleep 1
export DISPLAY=:0
xset dpms force off..I already learned about "ratbagctl" and "piper" to control the mouse and the LED, and it all works perfectly. To be clear, I have the command line commands to turn off and on the mouse LED. I just don't know where to put them.
Is there a way to run a command when the display turns off (and eventually on) due to DPMS?
Last edited by drcouzelis (2019-03-06 13:51:39)
Offline
There's no DPMS event, you'd have to poll the state, eg.
xset -q | grep "Monitor is"You could use eg. xautolock to deactivate the LED on inactivity, but this doesn't reactivate it.
Why would it make sense to align this to the DPMS state - the latter will kick in if you're not doing anything and that's likely because you're not there? Afaiu the light is annoying, probably at night?
You could either make this time driven or w/ a cron job checking "redshift -op" t ofigure whether it's dark outside ;-)
Offline
You know, making the mouse LED turn off and on based on the time of day by using a cron job sounds like a fine solution! Honestly I would prefer it to turn off and on with the monitor, but a cron job is so simple and easy and would meet most of my needs.
Thanks! ![]()
EDIT: For reference, here's my commands:
alias mouse-led-on="ratbagctl warbling-mara led 0 set mode cycle duration 10000"
alias mouse-led-off="ratbagctl warbling-mara led 0 set mode off"Last edited by drcouzelis (2019-03-11 14:50:00)
Offline
Better yet, just enable autosuspend on the usb device. So when the *mouse* is inactive for a certain period of time, power to it will be suspended (and thus the LED will turn off), but it will come back on as soon as the mouse is moved again.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
If you use a screenlocker, then you could wrap it in a script that toggles the mouse lighting. That is not exactly DPMS, but you could set it to the same interval.
Edit: Just like seth said xautolock works, there is also xss-lock. Due to the screenlocker you now have an event (screenlocker exit) you can use to reenable the lights.
Last edited by progandy (2019-03-06 14:05:47)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline
demo script to poll dpms:
#!/bin/bash
#config
delay=30
# init
read dummy dummy former_state < <(xset -q | grep "Monitor is ")
echo $former_state
sleep $delay
#loop
while true; do
read dummy dummy state < <(xset -q | grep "Monitor is ")
echo $state
[ "$state" = "On" ] || state="Off" # squeeze away suspend/standby, monitor is off
if [ "$state" != "$former_state" ]; then
if [ "$state" = "On" ]; then
echo "wake up"
else
echo "nap away"
fi
former_state="$state"
fi
sleep $delay
doneOffline