summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2023-02-11 17:43:46 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2023-02-11 17:43:46 +0100
commitee64301c07fe5a8a363d91670f1caddc4a744abd (patch)
tree00f872abbaa1e079a8d2ee38518c2ceb8ff5c7ce
parent8fe7e45c1a10f30c9160a721a88f343651b9e0b5 (diff)
Raise an exception when profile not found
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rwxr-xr-xmonitor-menu.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/monitor-menu.py b/monitor-menu.py
index f810f9c..413b12d 100755
--- a/monitor-menu.py
+++ b/monitor-menu.py
@@ -19,6 +19,10 @@ import dialog
import docopt
+class NoMatchingProfile(ValueError):
+ pass
+
+
class MonitorMenu():
def __init__(self, config_file='~/.config/monitor-profiles.json'):
with open(expanduser(config_file)) as fh:
@@ -41,7 +45,10 @@ class MonitorMenu():
if code in (self.d.ESC, self.d.CANCEL):
return
- profile = self.profiles[int(profile_idx)]
+ try:
+ profile = self.profiles[int(profile_idx)]
+ except IndexError:
+ raise NoMatchingProfile from None
# We build the command line starting from just "xrandr" and adding
# arguments.