Skip to content

Commit

Permalink
Allow exit with 'Q' key shortcut.
Browse files Browse the repository at this point in the history
  • Loading branch information
raspicamplayer committed Jun 30, 2020
1 parent 2f060ee commit 6667d3d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion camplayer.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Type=simple
User=pi
Group=pi
ExecStart=/usr/local/bin/camplayer
ExecStopPost=bash /usr/local/share/camplayer/bin/logsaver.sh
# ExecStopPost=bash /usr/local/share/camplayer/bin/logsaver.sh
KillMode=control-group
Restart=on-failure
RestartSec=30
Expand Down
18 changes: 10 additions & 8 deletions camplayer/camplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def main():

num_array = []
last_added = time.monotonic()
ignore_quit = False

if not platform.system() == "Linux":
sys.exit("'%s' OS not supported!" % platform.system())
Expand Down Expand Up @@ -73,6 +74,7 @@ def main():
print(" --rebuild-cache Rebuild cache on startup")
print(" --rebuild-cache-exit Rebuild cache and exit afterwards")
print(" -d --demo Demo mode")
print(" --ignorequit Don't quit when the 'Q' key is pressed")
sys.exit(0)

# Run in a specific mode
Expand Down Expand Up @@ -100,6 +102,10 @@ def main():
if arg == "-d" or arg == "--demo":
CONSTANTS.CONFIG_PATH = CONSTANTS.DEMO_CONFIG_PATH

# Ignore keyboard 'quit' command
if arg == "--ignorequit":
ignore_quit = True

# Load settings from config file
CONFIG.load()

Expand Down Expand Up @@ -260,6 +266,9 @@ def main():
elif event.code == KEYCODE.KEY_D:
screenmanager.on_action(Action.SWITCH_DISPLAY_CONTROL)

elif event.code == KEYCODE.KEY_Q and not ignore_quit:
running = False

break

# Timeout between key presses expired?
Expand Down Expand Up @@ -293,11 +302,4 @@ def main():


if __name__ == "__main__":
main()







main()
1 change: 1 addition & 0 deletions camplayer/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class KEYCODE(object):
"""Linux keyboard scancodes"""

KEY_D = 32
KEY_Q = 16
KEY_LEFT = 105
KEY_RIGHT = 106
KEY_UP = 103
Expand Down

0 comments on commit 6667d3d

Please sign in to comment.