Closed markstos closed 4 years ago
I tried again with debugging enabled. The crash appears to be triggered by some window with empty properties. The behavior I see now that raiseandlaunch
does launch Spotify, but when it comes to trying to raise an existing spotify, It launches a second one instead. I confirmed that the WM_CLASS for the app is "Spotify", using "xprop"
DEBUG:raiseorlaunch.__main__:Provided arguments: Namespace(command='spotify', con_mark=None, cycle=False, de=None, wm_class='Spotify', wm_instance=None, wm_title=None, workspace=None)
DEBUG:raiseorlaunch.raiseorlaunch:Getting list of windows.
DEBUG:raiseorlaunch.raiseorlaunch:Application is not running.
DEBUG:raiseorlaunch.raiseorlaunch:Executing command: exec spotify
DEBUG:raiseorlaunch.raiseorlaunch:Event callback: <Con: class="None" instance="None" title="None" id=9400240
expected string or bytes-like object
Traceback (most recent call last):
File "/usr/bin/raiseorlaunch", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3.8/site-packages/raiseorlaunch/__main__.py", line 222, in main
rol.run()
File "/usr/lib/python3.8/site-packages/raiseorlaunch/raiseorlaunch.py", line 551, in run
self._handle_not_running()
File "/usr/lib/python3.8/site-packages/raiseorlaunch/raiseorlaunch.py", line 515, in _handle_not_running
self.i3.main(timeout=self.event_time_limit)
File "/usr/lib/python3.8/site-packages/i3ipc/connection.py", line 518, in main
raise loop_exception
File "/usr/lib/python3.8/site-packages/i3ipc/connection.py", line 497, in main
while not self._event_socket_poll():
File "/usr/lib/python3.8/site-packages/i3ipc/connection.py", line 477, in _event_socket_poll
raise e
File "/usr/lib/python3.8/site-packages/i3ipc/connection.py", line 474, in _event_socket_poll
self._pubsub.emit(event_name, event)
File "/usr/lib/python3.8/site-packages/i3ipc/_private/pubsub.py", line 28, in emit
s['handler'](self.conn, data)
File "/usr/lib/python3.8/site-packages/raiseorlaunch/raiseorlaunch.py", line 527, in _callback_new_window
if self._compare_running(window):
File "/usr/lib/python3.8/site-packages/raiseorlaunch/raiseorlaunch.py", line 180, in _compare_running
if pattern and not self._match_regex(pattern, value):
File "/usr/lib/python3.8/site-packages/raiseorlaunch/raiseorlaunch.py", line 163, in _match_regex
return True if re.match(*matchlist) else False
File "/usr/lib/python3.8/re.py", line 189, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
It looks like it's warning, not actually a crash. I should have mentioned I do use this rule related to i3 with Spotify:
for_window [class="Spotify"] move to workspace "5 spotify"
I was able to resolve the issue by adding the "-w" flag and specifying the workspace that Spotify is forced be on.
I realize now I only got the "duplicate window" condition above when I added the "-r" flag, which I was experimenting with earlier.
I experimented more with trying to use this utility to launch and raise Spotify using the scratchpad, but I couldn't get restoring from the scratchpad to work-- I always get an extra copy of the app instead. Showing an example of how the scratchpad feature iis expected to be used would be helpful. Maybe it has a workflow in mind other that what I'm trying to do.
Turns out I picked a bad to start testing raiseorlaunch with. There is a known bug in Spotify for Linux where it sets WM_CLASS too late to be useful for cases like this:
https://community.spotify.com/t5/Desktop-Linux/WM-CLASS-window-property-on-Linux/td-p/1247042
The recommended workaround is to use the "spotifywm" wrapper, which I haven't tried yet:
https://github.com/dasJ/spotifywm
Regarding the warning/stacktraces I see, It seems they might be triggered from empty windows like "i3 open" can create, which have empty class, title and instance data. Try creating a window with "i3 open" and see if you can trigger it. I don't know how to remove those windows though besides quitting i3, though!
In case anyone finds this issue wondering how to get Spotify to work better with i3, here was my final solution. I found that there is a way with Firefox to treat any web page as a "web app", that can be launched and switched to as independent application and where all the "chrome" is hidden so only the web page is visible. Chrome and Epiphany have this feature built in, but Spotify does not support Epiphany and I didn't want to use Chrome.
The solution for Firefox could be automated as it's own little project but right now it's a manual process. Here's the rough sketch:
firefox -P spotify
to launch the browser in the new profile and visit about:config
. Enable the setting named toolkit.legacyUserProfileCustomizations.stylesheets
. This is needed to enable the "chrome" hiding.
bindsym Mod4+Control+s exec i3run -c firefox-spotify -e '/usr/lib/firefox/firefox -P spotify --class firefox-spotify https://open.spotify.com
In the end I switched from raiseorlaunch
to i3run
because i3run
allows using the same keybinding to launch, raise and hide Spotify. With raiseorlaunch
, the standard key combo to send a window to the scratchpad is be used. Here's a sample .desktop
files which can be placed in ~/.local/share/applications
:
[Desktop Entry]
Version=1.0
Name=Spotify Web
GenericName=Music Player
Comment=
Keywords=
Exec=/usr/lib/firefox/firefox -P spotify --class firefox-spotify https://open.spotify.com
StartupWMClass=firefox-spotify
Icon=spotify
Terminal=false
X-MultipleArgs=false
Type=Application
StartupNotify=true
Categories=
Hi @markstos
Thanks a lot for reporting this. Indeed, raiseorlaunch
should handle this and not throwing an exception.
In the end I switched from raiseorlaunch to i3run because i3run allows using the same keybinding to launch, raise and hide Spotify. With raiseorlaunch, the standard key combo to send a window to the scratchpad is be used.
I don't really underdstand what you mean. I have the following bindsym:
bindsym $mod+F12 exec --no-startup-id raiseorlaunch -r -c SpeedCrunch
If SpeedCrunch is not running, $mod+F12
will start it, move it to the scratchpad and show it again (in quick succession). If SpeedCrunch is running, but hidden, $mod+F12
will show the SpeedCrunch scratchpad. If it is running and visible, $mod+F12
will hide it.
I guess I should re-test the "hide" behavior. Thanks for the reply!
Now I've realized my solution for Spotify doesn't support media keys, but I don't need to clutter your bug queue with figuring that out.
Actually fixing media key support turned to be easy, there is a MPRIS add-on for Firefox for Linux that explicitly supports Spotify. It works even when the Spotify window is hidden. I followed the steps there, restarted my Spotify "app" and it worked: https://addons.mozilla.org/en-US/firefox/addon/mpris-integration/
If it is running and visible, $mod+F12 will hide it.
The docs could be improved here. Searching them for "lower" or "hide", I find no mention of the behavior that the keyboard shortcut is also used for lowering.
I don't see the code for hiding something in the scratchpad. The only mention of "move scratchpad" I find is just before "showing" the window:
This syntax worked to raise Spotify if it was already running, but crashed instead of launching Spotify when it was not running. If I'm doing something invalid, it would be nice if it failed with a more helpful diagnostic message explaining what was invalid.
Thanks.