Remove settings window
This commit is contained in:
parent
b6c0fc0793
commit
f826617ed4
4 changed files with 4 additions and 583 deletions
27
src/leld.py
27
src/leld.py
|
|
@ -17,7 +17,6 @@ from context import I3Provider
|
|||
from inject import inject
|
||||
from x11_hotkey import listen
|
||||
from tray import run_tray
|
||||
from settings_window import open_settings_window
|
||||
|
||||
|
||||
class State:
|
||||
|
|
@ -230,7 +229,6 @@ def main():
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--config", default="", help="path to config.json")
|
||||
parser.add_argument("--no-tray", action="store_true", help="disable tray icon")
|
||||
parser.add_argument("--settings", action="store_true", help="open settings window and exit")
|
||||
parser.add_argument("--dry-run", action="store_true", help="log hotkey only")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -238,21 +236,12 @@ def main():
|
|||
cfg = load(args.config)
|
||||
config_path = Path(args.config) if args.config else Path.home() / ".config" / "lel" / "config.json"
|
||||
|
||||
if args.settings:
|
||||
open_settings_window(cfg, config_path)
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk # type: ignore[import-not-found]
|
||||
Gtk.main()
|
||||
return
|
||||
|
||||
_lock_single_instance()
|
||||
|
||||
logging.info("ready (hotkey: %s)", cfg.daemon.get("hotkey", ""))
|
||||
logging.info("config (%s):\n%s", args.config or str(Path.home() / ".config" / "lel" / "config.json"), json.dumps(redacted_dict(cfg), indent=2))
|
||||
|
||||
daemon = Daemon(cfg)
|
||||
suppress_hotkeys = threading.Event()
|
||||
|
||||
def on_quit():
|
||||
os._exit(0)
|
||||
|
|
@ -271,28 +260,18 @@ def main():
|
|||
if args.no_tray:
|
||||
listen(
|
||||
cfg.daemon.get("hotkey", ""),
|
||||
lambda: logging.info("hotkey pressed (dry-run)")
|
||||
if args.dry_run
|
||||
else (None if suppress_hotkeys.is_set() else daemon.toggle()),
|
||||
lambda: logging.info("hotkey pressed (dry-run)") if args.dry_run else daemon.toggle(),
|
||||
)
|
||||
return
|
||||
|
||||
threading.Thread(
|
||||
target=lambda: listen(
|
||||
cfg.daemon.get("hotkey", ""),
|
||||
lambda: logging.info("hotkey pressed (dry-run)")
|
||||
if args.dry_run
|
||||
else (None if suppress_hotkeys.is_set() else daemon.toggle()),
|
||||
lambda: logging.info("hotkey pressed (dry-run)") if args.dry_run else daemon.toggle(),
|
||||
),
|
||||
daemon=True,
|
||||
).start()
|
||||
def open_settings():
|
||||
suppress_hotkeys.set()
|
||||
win = open_settings_window(load(args.config), config_path)
|
||||
win.window.connect("destroy", lambda *_: suppress_hotkeys.clear())
|
||||
return win
|
||||
|
||||
run_tray(daemon.get_state, on_quit, open_settings)
|
||||
run_tray(daemon.get_state, on_quit, None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue