Skip to content

Commit ac95a7f

Browse files
authored
Forward keys to mpv (#393)
forward keys to mpv keys not used by Hypnotix, like the spacebar, can be forwarded to mpv so you can natively use its shortcuts arrows and SHIFT use L/R arrows with SHIFT to go back and forth in mpv suppress error messages for keys mpv can't handle un-pause mpv before loading
1 parent 68f9503 commit ac95a7f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

usr/lib/hypnotix/hypnotix.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ def on_next_channel(self):
876876
def play_async(self, channel):
877877
if self.mpv is not None:
878878
self.mpv.stop()
879+
self.mpv.pause = False
879880
print("CHANNEL: '%s' (%s)" % (channel.name, channel.url))
880881
if channel is not None and channel.url is not None:
881882
# os.system("mpv --wid=%s %s &" % (self.wid, channel.url))
@@ -1477,10 +1478,16 @@ def on_key_press_event(self, widget, event):
14771478
elif event.keyval == Gdk.KEY_BackSpace and not ctrl and type(widget.get_focus()) != gi.repository.Gtk.SearchEntry:
14781479
self.normal_mode()
14791480
self.on_go_back_button()
1480-
elif event.keyval == Gdk.KEY_Left:
1481+
elif not shift and event.keyval == Gdk.KEY_Left:
14811482
self.on_prev_channel()
1482-
elif event.keyval == Gdk.KEY_Right:
1483+
elif not shift and event.keyval == Gdk.KEY_Right:
14831484
self.on_next_channel()
1485+
elif not event.keyval in [Gdk.KEY_F1, Gdk.KEY_F2]:
1486+
try:
1487+
self.mpv.command("keypress", Gdk.keyval_name(event.keyval))
1488+
except:
1489+
pass
1490+
return True
14841491
# elif event.keyval == Gdk.KEY_Up:
14851492
# # Up of in the list
14861493
# pass

0 commit comments

Comments
 (0)