Open alexandremello opened 8 years ago
Hi Alex, The XCB solution here - https://github.com/carlin-q-scott/browser-media-keys/issues/33
Should also work in Arch Linux.
May you please test it by testing out the Print Screen button on this addon here - https://addons.mozilla.org/en-US/firefox/addon/nativeshot/
Here's an article explaining how to debug add-ons if it helps: https://developer.mozilla.org/en-US/Add-ons/Add-on_Debugger
Same here, Arch and i3wm user. I can control my Spotify with playerctl
, which supports MPRIS players. Would it be possible to register FF as an MPRIS player through this plugin?
Edit: Just realised that there's already #35...
I have the same problem using i3wm with Gentoo it just doens't work.
Would be nice to know what I should map XF86AudioPlay
to make it work on Firefox.
I don't understand how this could be a solution https://github.com/carlin-q-scott/browser-media-keys/issues/65#issuecomment-224541983
@guimaluf XF86AudioPlay
was used with the XCB method mentioned in https://github.com/carlin-q-scott/browser-media-keys/issues/65#issuecomment-224541983
Once that lands on master it will work.
Sorry for integration taking so long. There's just a lot of code being added and I ran out of steam.
If XCB method doesn't work for you, look at #83 pull request, there are instructions to simulate DBus services on other DE, it works on Xfce.
@gmelikov may you please help us with a download and test of the XCB.
Please get the CommPlaygoround.xpi from this repo branch - https://github.com/Noitidart/CommPlayground/tree/jscSystemHotkey-demo
Please open browser console. Then clear its messages. Then install the xpi. Then clear. Then please hit the play key and see if you get blah triggered by hotkey!
output in the browser console. That will let us know if XCB works. After 30 seconds it will unregister the hotkeys. (You can also try the Shift + Space, hotkey but I'm sure that will work)
@Noitidart tried it with jpm, got this error on start, and doesn't see any console messages:
$jpm ru--debug
Native thread-sleep not available.
This will result in much slower performance, but it will still work.
You should re-install spawn-sync or upgrade to the lastest version of node if possible.
Check /usr/local/lib/node_modules/jpm/node_modules/fx-runner/node_modules/spawn-sync/error.log for more details
JPM [info] Starting jpm run on undefined
JPM [warning] Using existing install.rdf. This file is usually auto-generated.
JPM [warning] Using existing bootstrap.js. This file is usually auto-generated.
JPM [info] Creating a new profile
1471951254278 addons.xpi WARN Exception running bootstrap method startup on Comm@jetpack: Error opening input stream (invalid filename?): chrome://comm/content/resources/scripts/Comm/Comm.js
Maybe i did something wrong?
I have read about XCB, does all modern distros have it? And what will be with Wayland?
@gmelikov thanks much for testing it out! You download the zip of the repo I think, thats why the contents in Comm and those other folders are not loading, they are empty. Please download the xpi that is in the repo (i comitted a built xpi to it), and then go to about:debugging and then "Load as temporary addon" and select the XPI.
Please make sure you are on the branch jscSystemHotkey-demo - https://github.com/Noitidart/CommPlayground/tree/jscSystemHotkey-demo
XCB is actually just the thread safe version of x11/xlib. So if they have x11 they have XCB. This is an excellent read about this - http://www.remlab.net/op/xlib.shtml (especially the "Thread Support" section).
Wayland doesn't use xlib huh? So when that rolls around we will have to update. If you can point me to the docs of Wayland, and if you can let me know how I can get a wayland based distro onto my VM I can start preparing it. :)
@Noitidart made "git clone"
Did it by your new instructions, it started:
Comm.server.worker - incoming, payload: Object { method: null, arg: undefined, cbid: 1 } Comm.js:87
Comm.server.worker - incoming, payload: Object { method: "triggerOnAfterInit", arg: undefined, cbid: null } Comm.js:87
Comm.server.worker - incoming, payload: Object { method: null, arg: null, cbid: 2 } Comm.js:87
succesfully registered hotkeys bootstrap.js:28
I don't have play button, so i emulate it via "xdotool key XF86AudioPlay". Tried shift+space, none of them worked.
Can you give me full zip and filename where i can see key binding? I want to debug it.
Oh wow that's very interesting. Thanks very very much for offering to debug it!
If you do git clone
you have to do git sumodule init
then git submodule update
. That will flesh out the submodule directories.
The full zip is the XPI file you downloaded.Just rename that to zip and you can work on it. That xpi is just a zip of all the contents in the repo. The bindings are declared in MainWorker.js in the gHKI
object. And all the actual platform work is done in the jscSystemHotkey
subfolder. For Linux this will all happen in the default:
case statements in shtkMainWorkerSubscript.js
.
It's very odd that Shift + Space didn't work, I was sure that would work.
Looking at your console output above, its very odd. It says succesfully registered
however it did not show you all the other logging messages that should above before saying succesfully registerd hotkeys bootstrap.js:28
.
For instance this is what I see:
Comm.client.worker - incoming, payload: Object { method: "init", arg: Object, cbid: 1 } Comm.js:473:5
Comm.server.worker - incoming, payload: Object { method: null, arg: undefined, cbid: 1 } Comm.js:87
Comm.server.worker - incoming, payload: Object { method: "triggerOnAfterInit", arg: undefined, cbid: null } Comm.js:87
Comm.client.worker - incoming, payload: Object { method: "hotkeysRegister", arg: null, cbid: 2 } Comm.js:473:5
keysyms: _XCBKeySymbols.ptr(ctypes.UInt64("0x7fce21fe5da0")) shtkMainworkerSubscript.js:184:4
keycodesPtr: ctypes.uint8_t.ptr(ctypes.UInt64("0x7fce24a3bef8")) shtkMainworkerSubscript.js:191:5
keycodesArrC: ctypes.uint8_t.array(1)([172]) shtkMainworkerSubscript.js:195:6
keycodesArrC: ctypes.uint8_t.array(2)([172, 208]) shtkMainworkerSubscript.js:195:6
keycodesArrC: ctypes.uint8_t.array(3)([172, 208, 215]) shtkMainworkerSubscript.js:195:6
keycodesArrC: ctypes.uint8_t.array(4)([172, 208, 215, 0]) shtkMainworkerSubscript.js:195:6
code_os_to_codes_os[code]: Array [ 172, 208, 215 ] shtkMainworkerSubscript.js:205:5
keycodesPtr: ctypes.uint8_t.ptr(ctypes.UInt64("0x7fce24a3bf80")) shtkMainworkerSubscript.js:191:5
keycodesArrC: ctypes.uint8_t.array(1)([65]) shtkMainworkerSubscript.js:195:6
keycodesArrC: ctypes.uint8_t.array(2)([65, 0]) shtkMainworkerSubscript.js:195:6
code_os_to_codes_os[code]: Array [ 65 ] shtkMainworkerSubscript.js:205:5
code_os_to_codes_os: Object { 32: Array[1], 269025044: Array[3] } shtkMainworkerSubscript.js:220:4
setup: xcb_setup_t(1, 0, 11, 0, 1491, 11702000, 81788928, 2097151, 256, 20, 65535, 1, 7, 0, 0, 32, 32, 8, 255, [0, 0, 0, 0]) shtkMainworkerSubscript.js:227:4
screen[0].data: xcb_screen_t(619, 32, 16777215, 0, 16433201, 1920, 1045, 505, 275, 1, 1, 33, 1, 0, 24, 7) shtkMainworkerSubscript.js:235:5
grabwins: Array [ 619 ] shtkMainworkerSubscript.js:240:4
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 172 with mods: 0 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 208 with mods: 0 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 215 with mods: 0 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 65 with mods: 1 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 65 with mods: 3 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 65 with mods: 17 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 65 with mods: 19 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 172 with mods: 2 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 208 with mods: 2 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 215 with mods: 2 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 172 with mods: 16 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 208 with mods: 16 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 215 with mods: 16 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 172 with mods: 18 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 208 with mods: 18 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_check: xcb_generic_error_t.ptr(ctypes.UInt64("0x0")) shtkMainworkerSubscript.js:264:8
ok registered succesfully code_os: 215 with mods: 18 on grabwin: 619 shtkMainworkerSubscript.js:272:9
rez_flush: 1 shtkMainworkerSubscript.js:299:4
Comm.client.worker - Fullfilled - rez_scope - null Comm.js:490:10
Comm.server.worker - incoming, payload: Object { method: null, arg: null, cbid: 2 } Comm.js:87
succesfully registered hotkeys
Can you check your global hotkey settings to see if "Play" key is already in use by something else. This code should have detected it and logged something like this:
It is most likely that this key combination is already in use by another application. Find that app, and make it release this hotkey. Possibly could be in use by the "Global Keyboard Shortcuts" of the system - http://i.imgur.com/cLz1fDs.png\n\n\nDetails: Was not able to register the `code_os` of `' + failed_codeos + '` on `grabwin` of `' + grabwin + '`. Other info: `grabwins`: ' + grabwins.toString() + ' codes_os: ' + codes_os.toString() + ' code: ' + code.toString()
And if it did hit that it would not have resulted in logging of "succesfully registered hotkeys". Very interesting. If you are comfortable with remote session via teamviewer I would love to debug it with you.
@Noitidart thanks for git commands, now i know submodules =) On which OS were you already test it?
Submodules are awesome! It's like npm packages but the version history is so much better. I tested it on OpenSuse 40.1, Ubuntu 14.04, Ubuntu 15.1, and 16.04.1. @gmelikov
@Noitidart I don't know why, but callInMainworker('hotkeysRegister', null, function(failed) {
in bootstrap.js tries to run function, but i feel like function isn't working (inserted console.log in it, and it doesn't appear). Digging it now.
Thanks very much @gmelikov for the update. I am very eager to see whats wrong with this. I wrote up a submodule so anyone can drop in global system hotkeys. Your fix will definitely help a lot, if you would like you can submit PRs to it https://github.com/Noitidart/jscSystemHotkey/ and then we can do git pull
on the submodule to update all projects that use it. :)
@gmelikov a very easy way to debug chromeworker's is to go about:debugging then click on "Workers" section. Then in the thing that opens go to the "Console" tab then instead of restarting hte addon to call callInMainworker('hotkeysRegister')
, you can just do hotkeysRegister()
@Noitidart i tried so, and get EMITTING: emit(newSource, [object Object]) from undefined() -> undefined
I think there is a problem somewhere in Comm submodule on my OS.
Is there some way we can work togather? I'm comfortable with anything that you are comfortable with.
@gmelikov you can skip the Comm submodule by going to debug the worker (screenshot above) and just typing in hotkeysRegister()
in the "console" tab of the win that pops up.
@Noitidart please try this xpi, maybe i did something wrong when setup submodules? xpi.zip
I'll come back to PC later, you can find me in skype by nick georgemelikov, or here.
you can skip the Comm submodule by going to debug the worker and just typing in hotkeysRegister().
It doesn't work, i tried this already.
@gmelikov I checked the XPI, its odd, there are no differences, just the console.log('222')
that you added. Very weird.
I found some a weird charcter in my ostypes_x11.jsm got converted into another weird character on your end, do you think this has something to do with it. It would make sense nothing is working if this ostypes_x11.jsm file is not loading, as everything is based on this one.
@gmelikov I checked the XPI, its odd, there are no differences, just the console.log('222') that you added. Very weird.
Yes, i only wanted to know if i can generate working xpi on your end, thanks. I'll continue later.
@gmelikov I tested your xpi on OpenSuse with that weird character and it worked fine. (for shift +space, i cant test play key)
@Noitidart I checked different firefox versions, only dev (50-aurora) got me just Promise { <state>: "fulfilled", <value>: null }
I think there is something with my Xfce DE, did you test addon with it?
Or it might be something in Debian Jessie packages (they may be old).
@gmelikov that is very odd, even if old it should work. XCB has been around 7 years after x11 came out, which is a long time ago. And if XCB wasn't available on your platform, then you would have seen different errors in your browser console. This is so weird.
I don't have Xfce DE, I'm not sure how to get it, I'm not a Linux expert.
But I did test thoroughly, and lots of others used my NativeShot addon, which implements this hotkey method as well, and none of them said it didn't work.
@Noitidart sorry, i've found everything in browser console, not addon debug console. What's the logic in such work, bootstrap echoes to debug console and worker in browser one?
Hotkeys are working, i think when you finish your submodule we can merge it to browser-media-keys, it's far better than Dbus.
Sorry again, browser-media-keys was first addon which i debugged.
Woohoo!! That is great news @gmelikov!! Thank you for sharing! I'm not sure about the other consoles. I just know that "Browser Console" is the God console, everything comes to it.
The submodule is done and ready. I had done some work for him a couple months ago but I think that branch is dead. So I asked Carlin to give me the latest branch to work on and we can knock it up. The nice thing about the submodule is, if we put any improvements on it, all Carlin will have to do is git pull
on the submodule.
Pinging @carlin-q-scott - please see gmelikov's comment, he tested it and found the XCB method works excellently. The greatest part is, it's all in a ChromeWorker, so off of the main thread.
I think we can start from merging linux part for now, if @carlin-q-scott isn't ready for such cardinal changes. It's must-have for Linux.
Are we discussing the trade-offs between updating existing Linux support to use Noitdart's method versus integrating his entire sub-module?
I appreciate all the testing you guys have done.
@carlin-q-scott - we were discussing XCB vs Dbus. The submodule handles all operating systems. It's made to work like that. So if we included it, we should include it all and remove all old code. The only issue is mkwin is not yet supported in the submodule.
It just don't work on Arch Linux with i3wm. And I can't figure out why.
There is some way I can debug it?