Skip to content

Commit

Permalink
Added option to show notification
Browse files Browse the repository at this point in the history
Merge pull request #11 from JarnoB/master
  • Loading branch information
TyberiusPrime authored Jul 29, 2021
2 parents 8c3e49c + d5508b6 commit 920f883
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/i3_instant_layout/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def print_help():
Call with 'name --dry-run' to inspect the generated i3 append_layout compatible json.
Call with --notification + the name of a layout to apply the layout and show a notification that displays the name of the applied layout
To integrate into i3, add this to your i3/config.
bindsym $mod+Escape exec "i3-instant-layout --list | rofi -dmenu -i | i3-instant-layout -"
Expand All @@ -205,6 +207,7 @@ def print_desc():


def main():
showNotification = False
if len(sys.argv) == 1 or sys.argv[1] == "--help":
print_help()
elif sys.argv[1] == "--desc":
Expand All @@ -222,13 +225,19 @@ def main():
if not query.strip(): # e.g. rofi cancel
sys.exit(0)
else:
query = sys.argv[1]
if sys.argv[1] == "--notification":
showNotification = True
query = sys.argv[2]
else:
query = sys.argv[1]
if " " in query:
query = query[: query.find(" ")]
for layout_class in layouts.layouts:
if query == layout_class.name or query in layout_class.aliases:
nuke_swallow_windows()
apply_layout(layout_class(), "--dry-run" in sys.argv)
if showNotification:
subprocess.check_call(["notify-send", "-t", "2000", "Applied layout", layout_class.name])
count_usage(query)
sys.exit(0)
else:
Expand Down

0 comments on commit 920f883

Please sign in to comment.