Open NTMan opened 4 years ago
I spent the last few hours figuring out how to add a device to UPower. Unfortunately, it looks like either the UPower daemon (upowerd
) or xow can be connected to UPower at the same time. When xow connects, you lose the power status of all your other connected devices. Providing battery information from user space is not trivial at all...
Please head over to upower
and upvote the corresponding issue on their GitLab. That missing feature is currently preventing me from adding upower integration.
@medusalix Unfortunately the upower
mantainer seems uninterested in helping. I was thinking in responding but maybe you can make a better argument there?
Also, the projects xpadneo and specially Solaar which is a driver that deals with Logitech proprietary receivers for mice can offer some insight maybe, as both of them have access to battery information.
@cristianovitorino I think he's generally unconvinced of the necessity of proper upower integration for standard user mode software. Kernel drivers like xpadneo
are already able to use power_supply_register
to make their battery information available to upower and Solaar
(being a rather popular project) apparently has its own integration built into upower.
I'm unfortunately not knowledgeable enough about D-Bus and the whole upower ecosystem to implement the session bus support myself. I'd appreciate if someone else would start working on this though.
@medusalix Wish I could be more useful, but I'm just a designer. Only now I'm trying to dive into proper programming with Python to work with AI/AGI, which would be useless to this project anyways. :disappointed:
Unfortunately, it doesn't look like the upower
project is currently being maintained by anyone. While looking through their open issues and merge requests, it seems like the authors reject even the simplest changes that would lead to an improvement of upower
. I seriously doubt they would even accept a PR for an integration with xow.
Therefore, I've decided to add support for desktop notifications to xow. Whenever you connect a controller or the battery level of one of the connected controllers changes, you get an unintrusive notification informing you of the current battery status. When the level reaches a critical point, a high-priority notification is shown (which also works in fullscreen games).
I know notifications are only part of what you would expect from a full upower
integration, but I think it's a step in the right direction while we're waiting for further updates to upower
.
Any feedback would be greatly appreciated, so if you want to try things out, the battery
branch is ready for you to check out. Do note that desktop notifications require you to run xow as your local user as explained in the troubleshooting section of the README.
@medusalix Does it use notify-send
? Can it use notify-send
?
I personally prefer that, and would like to know if that is what you're using or if it's possible to implement support for it.
It does the exact same things notify-send
would do, but implemented internally by calling the notifications API directly.
It does the exact same things
notify-send
would do, but implemented internally by calling the notifications API directly.
I use Dunst to get my notifications, usually from notify-send
. Do you think it will work with your implementation? I can't test it right now. Will do later.
I use Dunst to get my notifications, usually from notify-send. Do you think it will work with your implementation? I can't test it right now. Will do later.
Yes, absolutely. Anything that adheres to Gnome's Desktop Notifications Specification should work (not limited to Gnome).
The installation instructions for the battery
branch are a little bit different, so make sure to read them thoroughly.
Yes, absolutely. Anything that adheres to Gnome's Desktop Notifications Specification should work (not limited to Gnome).
Awesome! Thanks!
Looks like this would allow xow to continue running the way it is, instead of moving to user service?
But then 5.8 would be req'd
https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.8-Notification-Queue
phoronix.com/scan.php?page=news_item&px=Linux-5.8-Notification-Queue
How does that relate to desktop notifications? That's a notification queue for user space <-> kernel communication.
Hey, instead of moving xow to userspace, userspace can have optional xow log parser or notificator, which could be separate (something perhaps a little bit more advanced than my sed-based utility service)
userspace can have optional xow log parser or notificator
This still wouldn't properly interface with upower. There's no way for a user-space app to properly interface with upowerd other than by special hacks added to the upower dbus API (I think there are hacks for solaar and similar software). By default, upowerd only looks at power interfaces provided by kernel drivers.
But yes, with this solution, xow can run as a system-wide service because your idea decouples both. Instead of watching the log, the system-wide process could open a pipe/socket where it writes battery information. An (yet to be created) xow-user.service could then open the socket (or query the dbus endpoint) and watch for new battery notifications to directly write to the notification API of the DE.
I've released a new driver for the Xbox wireless dongle which supports battery reporting via upower
. You can check it out here.
Thanks, it works! Do plan working to include xone driver to the mainline linux kernel? I didn't see the issue tab for https://github.com/medusalix/xone so where I could report founded issues for xone?
I see that every time when gamepad disconnected and resumed xone causes error message in kernel log BUG: sleeping function called from invalid context at include/linux/sched/mm.h:257
can you look?
[ 1211.204468] xone-gip-gamepad gip0.0: gip_handle_pkt_status: disconnected
[ 1211.204493] xone-gip-gamepad gip0.0: gip_remove_client: removed
[ 1211.399478] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:257
[ 1211.399484] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/18
[ 1211.399486] preempt_count: 103, expected: 0
[ 1211.399487] RCU nest depth: 0, expected: 0
[ 1211.399488] INFO: lockdep is turned off.
[ 1211.399489] irq event stamp: 58232
[ 1211.399490] hardirqs last enabled at (58231): [<ffffffff9c000d82>] asm_sysvec_apic_timer_interrupt+0x12/0x20
[ 1211.399496] hardirqs last disabled at (58232): [<ffffffff9b14b6be>] do_idle+0xae/0x260
[ 1211.399500] softirqs last enabled at (58226): [<ffffffff9b0f2da1>] __irq_exit_rcu+0xd1/0x160
[ 1211.399503] softirqs last disabled at (57983): [<ffffffff9b0f2da1>] __irq_exit_rcu+0xd1/0x160
[ 1211.399506] Preemption disabled at:
[ 1211.399507] [<ffffffff9b3b3ab4>] ___slab_alloc+0x974/0xfd0
[ 1211.399512] CPU: 18 PID: 0 Comm: swapper/18 Tainted: G B W OEL --------- --- 5.18.0-0.rc0.20220325git34af78c4e616.7.fc37.x86_64 #1
[ 1211.399515] Hardware name: System manufacturer System Product Name/ROG STRIX X570-I GAMING, BIOS 4204 02/24/2022
[ 1211.399517] Call Trace:
[ 1211.399519] <IRQ>
[ 1211.399522] dump_stack_lvl+0x5b/0x74
[ 1211.399526] __might_resched.cold+0xff/0x13a
[ 1211.399531] __kmalloc_track_caller+0x22f/0x400
[ 1211.399536] kvasprintf+0x52/0xa0
[ 1211.399540] kobject_set_name_vargs+0x1c/0x90
[ 1211.399544] dev_set_name+0x43/0x50
[ 1211.399549] gip_get_or_init_client+0xc7/0x1b0 [xone_gip_bus]
[ 1211.399554] gip_process_buffer+0x36/0x4de [xone_gip_bus]
[ 1211.399559] xone_dongle_process_wlan+0x1e8/0x220 [xone_dongle]
[ 1211.399564] xone_dongle_complete_in+0x18d/0x250 [xone_dongle]
[ 1211.399568] __usb_hcd_giveback_urb+0x9d/0x110
[ 1211.399572] usb_giveback_urb_bh+0x97/0xe0
[ 1211.399575] tasklet_action_common.constprop.0+0xe3/0x110
[ 1211.399578] __do_softirq+0x194/0x597
[ 1211.399583] __irq_exit_rcu+0xd1/0x160
[ 1211.399585] irq_exit_rcu+0xa/0x20
[ 1211.399587] common_interrupt+0xb9/0xd0
[ 1211.399591] </IRQ>
[ 1211.399592] <TASK>
[ 1211.399593] asm_common_interrupt+0x1e/0x40
[ 1211.399596] RIP: 0010:cpuidle_enter_state+0xeb/0x300
[ 1211.399600] Code: bb 22 5d ff 45 84 ff 74 16 9c 58 0f 1f 40 00 f6 c4 02 0f 85 ea 01 00 00 31 ff e8 a0 6e 64 ff e8 2b 92 6c ff fb 0f 1f 44 00 00 <45> 85 ed 0f 88 cf 00 00 00 49 63 f5 4c 89 f2 48 8d 04 76 48 8d 04
[ 1211.399603] RSP: 0018:ffffaafd401ffea8 EFLAGS: 00000246
[ 1211.399605] RAX: 0000000080000001 RBX: ffff9039e1569000 RCX: 0000000000000000
[ 1211.399607] RDX: 0000011a0d08dbac RSI: ffffffff9c8a4518 RDI: ffffffff9bb792b5
[ 1211.399608] RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
[ 1211.399609] R10: 0000000000000000 R11: 0000000000000001 R12: ffffffff9d360140
[ 1211.399610] R13: 0000000000000002 R14: 0000011a0d08dbac R15: 0000000000000000
[ 1211.399614] ? cpuidle_enter_state+0xe5/0x300
[ 1211.399617] ? cpuidle_enter_state+0xe5/0x300
[ 1211.399620] cpuidle_enter+0x29/0x40
[ 1211.399623] do_idle+0x1e8/0x260
[ 1211.399627] cpu_startup_entry+0x19/0x20
[ 1211.399629] secondary_startup_64_no_verify+0xd5/0xdb
[ 1211.399635] </TASK>
[ 1211.399641] xone-gip gip0.0: gip_init_client: initialized
[ 1212.303129] xone-dongle 7-1.1.4:1.0: xone_dongle_remove_client: wcid=1, address=7e:ed:82:53:f1:e7
[ 1212.303138] xone-gip-chatpad gip0.1: gip_remove_client: removed
[ 1212.418346] xone-gip gip0.0: gip_remove_client: removed
[ 1212.418356] xone-gip gip0: gip_destroy_adapter: unregistered
[ 5557.149466] xone-dongle 7-1.1.4:1.0: xone_mt76_resume_radio: resumed
[ 5557.286352] xone-gip gip0: gip_create_adapter: registered
[ 5557.286520] xone-dongle 7-1.1.4:1.0: xone_dongle_add_client: wcid=1, address=7e:ed:82:53:f1:e7
[ 5557.799000] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:257
[ 5557.799010] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 31609, name: fossilize_repla
[ 5557.799013] preempt_count: 102, expected: 0
[ 5557.799014] RCU nest depth: 0, expected: 0
[ 5557.799016] INFO: lockdep is turned off.
[ 5557.799018] irq event stamp: 0
[ 5557.799019] hardirqs last enabled at (0): [<0000000000000000>] 0x0
[ 5557.799053] hardirqs last disabled at (0): [<ffffffff9b0e8a5e>] copy_process+0x9fe/0x1ed0
[ 5557.799059] softirqs last enabled at (0): [<ffffffff9b0e8a5e>] copy_process+0x9fe/0x1ed0
[ 5557.799062] softirqs last disabled at (0): [<0000000000000000>] 0x0
[ 5557.799065] Preemption disabled at:
[ 5557.799066] [<ffffffff9c200059>] __do_softirq+0x59/0x597
[ 5557.799074] CPU: 18 PID: 31609 Comm: fossilize_repla Tainted: G B W OEL --------- --- 5.18.0-0.rc0.20220325git34af78c4e616.7.fc37.x86_64 #1
[ 5557.799078] Hardware name: System manufacturer System Product Name/ROG STRIX X570-I GAMING, BIOS 4204 02/24/2022
[ 5557.799081] Call Trace:
[ 5557.799085] <TASK>
[ 5557.799089] dump_stack_lvl+0x5b/0x74
[ 5557.799094] __might_resched.cold+0xff/0x13a
[ 5557.799103] __kmalloc_track_caller+0x22f/0x400
[ 5557.799109] kvasprintf+0x52/0xa0
[ 5557.799114] kobject_set_name_vargs+0x1c/0x90
[ 5557.799119] dev_set_name+0x43/0x50
[ 5557.799126] gip_get_or_init_client+0xc7/0x1b0 [xone_gip_bus]
[ 5557.799137] gip_process_buffer+0x36/0x4de [xone_gip_bus]
[ 5557.799142] xone_dongle_process_wlan+0x1e8/0x220 [xone_dongle]
[ 5557.799148] xone_dongle_complete_in+0x18d/0x250 [xone_dongle]
[ 5557.799152] __usb_hcd_giveback_urb+0x9d/0x110
[ 5557.799158] usb_giveback_urb_bh+0x97/0xe0
[ 5557.799161] tasklet_action_common.constprop.0+0xe3/0x110
[ 5557.799166] __do_softirq+0x194/0x597
[ 5557.799171] __irq_exit_rcu+0xd1/0x160
[ 5557.799173] irq_exit_rcu+0xa/0x20
[ 5557.799176] common_interrupt+0x61/0xd0
[ 5557.799180] ? asm_common_interrupt+0x8/0x40
[ 5557.799183] asm_common_interrupt+0x1e/0x40
[ 5557.799186] RIP: 0033:0x7f722a2a09ca
[ 5557.799191] Code: 0f b7 0c 6a 66 85 c9 0f 84 ea fe ff ff 48 8d 7d 10 48 8b 04 fa a8 0f 0f 85 a3 01 00 00 48 89 c6 83 e9 01 48 c1 ee 0c 48 33 30 <48> 89 34 fa 66 89 0c 6a 48 c7 40 08 00 00 00 00 48 83 c4 10 5b 5d
[ 5557.799193] RSP: 002b:00007f7222422dc0 EFLAGS: 00000246
[ 5557.799196] RAX: 00007f721403d4e0 RBX: 0000000000000350 RCX: 0000000000000000
[ 5557.799198] RDX: 00007f72140008e0 RSI: 0000000000000000 RDI: 0000000000000044
[ 5557.799200] RBP: 0000000000000034 R08: 0000000000000000 R09: 00000007f72145b1
[ 5557.799201] R10: 0000000000000000 R11: 0000000000000011 R12: ffffffffffffff58
[ 5557.799203] R13: 0000000000000000 R14: 00007f72148e2050 R15: 00007f7222423000
[ 5557.799209] </TASK>
[ 5557.799222] xone-gip gip0.0: gip_init_client: initialized
[ 5557.799225] xone-gip gip0.0: gip_handle_pkt_announce: address=7e:ed:82:53:f1:e7, vendor=0x045e, product=0x0b00
[ 5557.799228] xone-gip gip0.0: gip_handle_pkt_announce: firmware=5.11.3118.0, hardware=1541.1.1.1
[ 5557.822982] xone-gip gip0.0: gip_parse_chunk: offset=0x018d, length=0x7a
[ 5557.822993] xone-gip gip0.0: gip_init_chunk_buffer: length=0x018d
[ 5557.847040] xone-gip gip0.0: gip_parse_chunk: offset=0x007a, length=0x7a
[ 5557.863000] xone-gip gip0.0: gip_parse_chunk: offset=0x018d, length=0x00
[ 5557.863010] xone-gip gip0.0: gip_copy_chunk_data: buffer complete
[ 5557.863014] xone-gip gip0.0: gip_parse_capabilities: out=01-02-03-04-06-07-0c-0d-1c-1e
[ 5557.863017] xone-gip gip0.0: gip_parse_capabilities: in=01-04-05-06-0a-0c-0d-1c-1e
[ 5557.863020] xone-gip gip0.0: gip_parse_classes: class=Windows.Xbox.Input.Gamepad
[ 5557.863022] xone-gip gip0.0: gip_parse_classes: class=Microsoft.Xbox.Input.ProgrammableGamepad
[ 5557.863024] xone-gip gip0.0: gip_parse_interfaces: guid=56ff7697-fd9b-8145-ad45-b645bba526d6
[ 5557.863026] xone-gip gip0.0: gip_parse_interfaces: guid=2c402e08-df07-e145-a5ab-a3127af197b5
[ 5557.863028] xone-gip gip0.0: gip_parse_interfaces: guid=e71ff3b8-8673-e940-a9f8-2f21263acfb7
[ 5557.863029] xone-gip gip0.0: gip_parse_interfaces: guid=fed2ddec-87d3-9442-bd96-1a712e3dc77d
[ 5557.863030] xone-gip gip0.0: gip_parse_interfaces: guid=66dc58f7-2c02-b848-a4f6-457ba80e2a5b
[ 5557.863031] xone-gip gip0.0: gip_parse_interfaces: guid=f79fd137-c6b5-d149-a75e-03b24bef8c89
[ 5557.863033] xone-gip gip0.0: gip_parse_interfaces: guid=4d03c131-b7b5-5145-9813-870000000000
[ 5557.863034] xone-gip gip0.0: gip_parse_interfaces: guid=00000000-0000-0000-0000-000000000000
[ 5557.863035] xone-gip gip0.0: gip_parse_interfaces: guid=00000000-0000-0000-0000-000000000000
[ 5557.863581] input: Microsoft X-Box One pad as /devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb7/7-1/7-1.1/7-1.1.4/7-1.1.4:1.0/gip0/gip0.0/input/input44
[ 5557.865399] xone-gip-gamepad gip0.0: gip_add_client: added
[ 5558.311001] xone-gip gip0.1: gip_init_client: initialized
[ 5558.311009] xone-gip gip0.1: gip_handle_pkt_announce: address=7e:ed:82:53:f1:e9, vendor=0x045e, product=0x0b02
[ 5558.311013] xone-gip gip0.1: gip_handle_pkt_announce: firmware=5.11.3118.0, hardware=1541.1.1.1
[ 5558.335002] xone-gip gip0.1: gip_parse_chunk: offset=0x00b1, length=0x7a
[ 5558.335011] xone-gip gip0.1: gip_init_chunk_buffer: length=0x00b1
[ 5558.359026] xone-gip gip0.1: gip_parse_chunk: offset=0x007a, length=0x37
[ 5558.383029] xone-gip gip0.1: gip_parse_chunk: offset=0x00b1, length=0x00
[ 5558.383042] xone-gip gip0.1: gip_copy_chunk_data: buffer complete
[ 5558.383046] xone-gip gip0.1: gip_parse_capabilities: out=01-02-03-04-05-0b
[ 5558.383049] xone-gip gip0.1: gip_parse_capabilities: in=01-04-05-0b
[ 5558.383052] xone-gip gip0.1: gip_parse_classes: class=Windows.Xbox.Input.Chatpad
[ 5558.383054] xone-gip gip0.1: gip_parse_interfaces: guid=56ff7697-fd9b-8145-ad45-b645bba526d6
[ 5558.383056] xone-gip gip0.1: gip_parse_hid_descriptor: length=0x49
[ 5558.383523] input: Microsoft X-Box One chatpad as /devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb7/7-1/7-1.1/7-1.1.4/7-1.1.4:1.0/gip0/gip0.1/input/input45
[ 5558.385159] input: Microsoft X-Box One chatpad as /devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb7/7-1/7-1.1/7-1.1.4/7-1.1.4:1.0/gip0/gip0.1/0003:045E:0B02.0010/input/input46
[ 5558.386725] hid-generic 0003:045E:0B02.0010: input,hidraw14: USB HID v1.01 Keyboard [Microsoft X-Box One chatpad] on gip0.1/input1
[ 5558.386799] xone-gip-chatpad gip0.1: gip_add_client: added
@NTMan
Do plan working to include xone driver to the mainline linux kernel?
Yes, I plan on submitting xone
for the mainline kernel in the future.
I see that every time when gamepad disconnected and resumed xone causes error message in kernel log
Thanks for the bug report, I'm working on a fix.
I didn't see the issue tab for medusalix/xone so where I could report founded issues for xone?
You can report issues on Discord if you want.
This allows seeing the power charge level of the gamepad in DE.