libratbag / piper

GTK application to configure gaming devices
GNU General Public License v2.0
4.75k stars 176 forks source link

Mouse doesn't remember DPI settings. #330

Closed nrayamajhee closed 5 years ago

nrayamajhee commented 5 years ago

Excellent software. Just the thing I was looking for after I bought my MX Anywhere S2.

However, I have run into this issue where if I change the DPI to say 2400 then turn the mouse off and turn in back on, the DPI is reset to 1000. Although piper doesn't show it, I can feel the change and if I restart ratbadg.service, piper will correctly display that it is indeed 1000.

Am I missing something here. I am running the piper-git package via AUR in Arch linux. And I have enabled and started ratbadg.service. Isn't there a way to make the dpi changes persistent. I do want to be able to turn off my mouse when not in use.

whot commented 5 years ago

IIRC it's an issue with that particular mouse, it resets when it goes to sleep or is turned off. libratbag would have to re-apply the settings on wakeup but those hooks aren't in place yet. Either way, this is a libratbag bug, please file the issue there. Piper is merely a pretty UI to libratbag's DBus interface but doesn't handle anything with the mouse directly.

QazCetelic commented 4 years ago

I'm still having this issue.

nrayamajhee commented 4 years ago

@QazCetelic Seems like this case is specific to Logitech MX series. Since we don't have official drivers, the mouse doesn't get the proper dpi setting from the host(OS) itself. So instead I setup this udev rule to set dpi everytime there's a power event for this mouse. It still doesn't work sometimes when the mouse goes to sleep. But in that case, I manually turn it off and on to trigger this rule:

/etc/udev/rules.d/90-mx-anywhere-on.rule

ACTION=="change"\
, SUBSYSTEM=="power_supply"\
, ENV{POWER_SUPPLY_MODEL_NAME}=="Wireless Mobile Mouse MX Anywhere 2S"\
, ENV{POWER_SUPPLY_ONLINE}=="1"\
, ENV{POWER_SUPPLY_STATUS}=="Discharging"\
, RUN+="/usr/bin/su root -c 'ratbagctl Logitech\ MX\ Anywhere\ 2S dpi set 4000'"

Run this command to verify that your computer detects mouse power events:

udevadm monitor --environment --udev

If you see the mouse power supply setting displayed when you turn the mouse off/on, then the above rule should start doing its job.

Arch linux has more info for wiriting udev rules: https://wiki.archlinux.org/index.php/Udev.

QazCetelic commented 4 years ago

I'll try if it works now

This is the output

UDEV  [1210.561243] change   /devices/virtual/block/loop16 (block)
.ID_FS_TYPE_NEW=squashfs
ACTION=change
DEVNAME=/dev/loop16
DEVPATH=/devices/virtual/block/loop16
DEVTYPE=disk
ID_FS_TYPE=squashfs
ID_FS_USAGE=filesystem
ID_FS_VERSION=4.0
MAJOR=7
MINOR=16
SEQNUM=4290
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=4623413

It still doesn't work

rogelioamancisidor commented 3 years ago

@nrayamajhee I want to create a udev rule for this command ratbagctl singing-gundi button 7 action set button 3, which works fine when written in the terminal. I followed your above example (with my ratbagctl command), but it doesnt work. How do I find the POWER_SUPPLY_MODEL_NAME env variable in my case? I also notice that you use \ in your ratbagctl command, why is that?

nrayamajhee commented 3 years ago

@QazCetelic I don't think that output is regarding your mouse. I would suggest starting uvdevadm and turning your mouse off, then turning it on again. That'll definitely send a power event to udev.

@rogelioamancisidor, regarding POWER_SUPPLY_MODEL_NAME: udevadm should also show you that . For example this is mine:

I first ran sudo udevadm monitor --environment --udev, then turned off my mouse, then turned it back on. This was shown on the terminal.

UDEV  [3847.607938] change   /devices/pci0000:00/0000:00:01.3/0000:03:00.0/usb1/1-4/1-4:1.2/0003:046D:C52B.000E/0003:046D:406A.000F/power_supply/hidpp_battery_0 (power_supply)
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:01.3/0000:03:00.0/usb1/1-4/1-4:1.2/0003:046D:C52B.000E/0003:046D:406A.000F/power_supply/hidpp_battery_0
SUBSYSTEM=power_supply
POWER_SUPPLY_NAME=hidpp_battery_0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_ONLINE=0
POWER_SUPPLY_STATUS=Unknown
POWER_SUPPLY_SCOPE=Device
POWER_SUPPLY_MODEL_NAME=Wireless Mobile Mouse MX Anywhere 2S
POWER_SUPPLY_MANUFACTURER=Logitech
POWER_SUPPLY_SERIAL_NUMBER=406a-c0-c1-8a-49
POWER_SUPPLY_CAPACITY_LEVEL=Unknown
SEQNUM=5170
USEC_INITIALIZED=3847607801

I used POWER_SUPPLY_MODEL_NAME from above for my udev rule and for ratbagctl, I got the device name by simply running ratbagctl. It'll give you a nickname like 'singing-gundi' and full name, I used the full name.

@rogelioamancisidor the \ is for escaping space "`" while running command in lineRUN+=` I needed to be put spaces between the words "Logitech" and "MX".

rogelioamancisidor commented 3 years ago

@nrayamajhee The output in my case does not show any change action, just add, bind and remove. I have tried to use an add and bind action, together with some of their env variables, but I didnt succeed.

nrayamajhee commented 3 years ago

I don't mean to divert you guys from the problem at hand, but if it's just about swapping buttons and not configuring logitech (e.g. setting dpi), you can use xbindkeys.

Here's a tutorial: http://xahlee.info/linux/linux_xbindkeys_tutorial.html

More info here: https://wiki.archlinux.org/title/Xbindkeys

If you have xautomation package (xte command) in whatever linux you're using, then you can even map button to keypresses very easily. Here's my configuration to map extra buttons to PageUp/Down: https://github.com/nrayamajhee/dotfiles/blob/master/.xbindkeysrc

I hope this helps.

However, I should say that the udev rule should still work. I am not an expert by any means, but I think a suitable ACTION, not necessarily change should do it. My rules on my mouse (MX Anywhere) doesn't work when the mouse sleeps after inactivity. I have to manually turn it off and on to trigger it.

Also, we should discuss this here: https://github.com/libratbag/libratbag/issues/596 Since applying settings during mouse power events is a feature that we want in ratbagd, its not really an issue with piper.

rogelioamancisidor commented 3 years ago

I finally manage to create the udev rule for my mouse that it is connected via bluetooth. Here it is, in case anybody else has the same problem, ACTION=="add"\ , SUBSYSTEM=="bluetooth"\ , ATTR{idVendor}=="hci0"\ , ATTR{idProduct}=="3585"\ , RUN+="/usr/bin/su root -c 'ratbagctl M720\ Triathlon button 7 action set button 3'"

rogelioamancisidor commented 3 years ago

I have tried to replicate the above udev rule in a difference pc and it is not working. If I just run ratbagctl M720\ Triathlon button 7 action set button 3 from the terminal it works fine (so ratbagctl works fine). What can it be now? Only difference is that the laptop where it is not working runs on ubuntu 20.04.2, while the one where it works runs ubuntu 20.10.

BloodyIron commented 1 year ago

I'm having the same issue where whenever I unlock my computer, or stuff like that, my G604 goes back to some sort of DPI that's way lower than what it was last set to.

Can we please have this re-opened and a permanent solution implemented? This is really obnoxious, and is specific to Linux, as this doesn't happen in Windows.

PadTrick commented 1 year ago

have the same issue, with a logitech g203. after every reboot, shutdown, sleep etc. the DPI is changed back to the default low dpi setting. anyone found a working fix/workaround ?

BloodyIron commented 1 year ago

Still happening for me... It's incredibly frustrating. It happens 100% of the time for me.

vanlueckn commented 10 months ago

Yes for me too