Last active
March 25, 2023 20:35
-
-
Save tjvr/b92d62f8118548ded06f56083712b7d7 to your computer and use it in GitHub Desktop.
Revisions
-
tjvr revised this gist
Mar 25, 2023 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,16 +20,17 @@ def handle(event: evdev.KeyEvent): return try: uri = next(mpris2.get_players_uri()) except StopIteration: print("No media player found") return method_name = mappings.get(event.keycode) if not method_name: print("No key mapping") return player = mpris2.Player(dbus_interface_info={'dbus_uri': uri}) print("player.{}()".format(method_name)) method = getattr(player, method_name) -
tjvr revised this gist
Apr 13, 2019 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ [Unit] Description=Control MPRIS media players with your Flirc [Service] ExecStart=/usr/bin/flirc_mpris.py -
tjvr revised this gist
Apr 13, 2019 . 2 changed files with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ [Unit] Description=Control MPRIS media players with your Flirc Wants=network-online.target After=network-online.target [Service] ExecStart=/usr/bin/flirc_mpris.py Restart=always [Install] WantedBy=default.target File renamed without changes. -
tjvr revised this gist
Apr 13, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,9 @@ "KEY_NEXTSONG": "Next", "KEY_PREVIOUSSONG": "Previous", "KEY_PLAYPAUSE": "PlayPause", "KEY_PAUSE": "Pause", "KEY_PLAY": "Play", "KEY_STOP": "Stop", } def handle(event: evdev.KeyEvent): -
tjvr revised this gist
Apr 13, 2019 . 1 changed file with 15 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,25 +6,31 @@ dev = evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-kbd') mappings = { "KEY_NEXTSONG": "Next", "KEY_PREVIOUSSONG": "Previous", "KEY_PLAYPAUSE": "PlayPause", } def handle(event: evdev.KeyEvent): if event.keystate != evdev.KeyEvent.key_down: return try: uri = mpris2.get_players_uri() except StopIteration: print("No media player found") return method_name = mappings.get(event.keycode) if not method_name: return player = mpris2.Player(dbus_interface_info={'dbus_uri': next(mpris2.get_players_uri())}) print("player.{}()".format(method_name)) method = getattr(player, method_name) method() for event in dev.read_loop(): -
tjvr revised this gist
Apr 13, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ evdev==1.2.0 mpris2==1.0.2 -
tjvr revised this gist
Apr 13, 2019 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/python3 import evdev import mpris2 @@ -26,15 +26,11 @@ def handle(event: evdev.KeyEvent): print("player.PlayPause()") player.PlayPause() for event in dev.read_loop(): if event.type != ecodes.EV_KEY: continue key_event = evdev.categorize(event) print(key_event) handle(key_event) -
tjvr created this gist
Apr 13, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ #!/usr/bin/python3 import evdev import mpris2 from evdev import ecodes dev = evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-kbd') def handle(event: evdev.KeyEvent): if event.keystate != evdev.KeyEvent.key_down: return try: uri = mpris2.get_players_uri() except StopIteration: return player = mpris2.Player(dbus_interface_info={'dbus_uri': next(mpris2.get_players_uri())}) if event.keycode == "KEY_NEXTSONG": print("player.Next()") player.Next() elif event.keycode == "KEY_PREVIOUSSONG": print("player.Previous()") player.Previous() elif event.keycode == "KEY_PLAYPAUSE": print("player.PlayPause()") player.PlayPause() for event in dev.read_loop(): if event.type != ecodes.EV_KEY: continue key_event = evdev.categorize(event) print(key_event) handle(key_event) ~ ~ ~ ~ ~