commit 7c0a24033f796dea46910d21fd35d7ff58807e7d
parent e82cc067e3c9cce4ce2930c6d42c51a94753dd30
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Wed, 22 Jan 2020 19:18:33 +0100
Renamed dark mode profile toggle script for iterm2
Former-commit-id: c4bd87fb24ccbd58d0182153147d4589671b3949
Diffstat:
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/iterm2/scripts/iterm_toggle_dark_profile.py b/iterm2/scripts/iterm_toggle_dark_profile.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import iterm2
+from sys import argv
+
+async def main(connection):
+ profiles = [p for p in await iterm2.PartialProfile.async_query(connection) if p.name.startswith("Default ")]
+ if len(argv) > 1:
+ is_dark_theme = str(argv[1])
+ else:
+ import subprocess
+ result = subprocess.run(['osascript', '-e', 'tell application "System Events" to tell appearance preferences to return (get dark mode as text)'], stdout=subprocess.PIPE)
+ is_dark_theme = str(result.stdout.rstrip().decode("utf-8"))
+
+ for p in profiles:
+ if "Light" in p.name and is_dark_theme == "false":
+ await p.async_make_default()
+ return
+ elif "Dark" in p.name and is_dark_theme == "true":
+ await p.async_make_default()
+ return
+try:
+ iterm2.run_until_complete(main)
+except Exception as exception:
+ print("Error: ", exception)
diff --git a/iterm2/scripts/toggle_dark_mode.py b/iterm2/scripts/toggle_dark_mode.py
@@ -1,25 +0,0 @@
-#!/usr/bin/env python3.7
-
-import iterm2
-from sys import argv
-
-async def main(connection):
- profiles = [p for p in await iterm2.PartialProfile.async_query(connection) if p.name.startswith("Default ")]
- if len(argv) > 1:
- is_dark_theme = str(argv[1])
- else:
- import subprocess
- result = subprocess.run(['osascript', '-e', 'tell application "System Events" to tell appearance preferences to return (get dark mode as text)'], stdout=subprocess.PIPE)
- is_dark_theme = str(result.stdout.rstrip().decode("utf-8"))
-
- for p in profiles:
- if "Light" in p.name and is_dark_theme == "false":
- await p.async_make_default()
- return
- elif "Dark" in p.name and is_dark_theme == "true":
- await p.async_make_default()
- return
-try:
- iterm2.run_until_complete(main)
-except Exception as exception:
- print("Error: ", exception)