init commit

This commit is contained in:
unknown
2025-08-19 08:06:37 -04:00
commit 2957b5515a
743 changed files with 45495 additions and 0 deletions
+118
View File
@@ -0,0 +1,118 @@
import subprocess
from typing import Optional, Union
from talon import Context, Module, actions, settings
mod = Module()
ctx = Context()
mod.tag("i3wm", desc="tag for loading i3wm related files")
mod.setting(
"i3_config_path",
type=str,
default="~/.i3/config",
desc="Where to find the configuration path",
)
mod.setting(
"i3_mod_key",
type=str,
default="super",
desc="The default key to use for i3wm commands",
)
ctx.matches = """
tag: user.i3wm
"""
@ctx.action_class("app")
class AppActions:
def window_close():
subprocess.check_call(("i3-msg", "kill"))
@mod.action_class
class Actions:
def i3wm_mode(name: str):
"""Switch i3 mode"""
subprocess.check_call(("i3-msg", "mode", name))
def i3wm_reload():
"""Reload the i3 config"""
subprocess.check_call(("i3-msg", "reload"))
def i3wm_restart():
"""Restart the window manager"""
subprocess.check_call(("i3-msg", "restart"))
def i3wm_layout(layout: Optional[str] = None):
"""Change to specified layout. Toggle split if unspecified."""
if layout is None:
subprocess.check_call(("i3-msg", "layout", "toggle", "split"))
else:
subprocess.check_call(("i3-msg", "layout", layout))
def i3wm_fullscreen():
"""Fullscreen the current container"""
subprocess.check_call(("i3-msg", "fullscreen"))
def i3wm_split(direction: str):
"""Split the focused container"""
subprocess.check_call(("i3-msg", "split", direction))
def i3wm_float():
"""Toggle whether the focused container should float."""
subprocess.check_call(("i3-msg", "floating", "toggle"))
def i3wm_launch():
"""Trigger the i3 launcher: ex rofi"""
key = settings.get("user.i3_mod_key")
actions.key(f"{key}-d")
def i3wm_shell():
"""Launch a shell"""
key = settings.get("user.i3_mod_key")
actions.key(f"{key}-enter")
def i3wm_focus(what: str):
"""Move focus"""
subprocess.check_call(("i3-msg", "focus", what))
def i3wm_switch_to_workspace(which: Union[str, int]):
"""Focus the specified workspace"""
if isinstance(which, int):
subprocess.check_call(("i3-msg", "workspace", "number", str(which)))
else:
subprocess.check_call(("i3-msg", "workspace", which))
def i3wm_show_scratchpad():
"""Focus/cycle/hide the scratchpad"""
subprocess.check_call(("i3-msg", "scratchpad", "show"))
def i3wm_move(to: str):
"""Move the focused container"""
subprocess.check_call(("i3-msg", "move", to))
def i3wm_move_to_workspace(which: Union[str, int]):
"""Move the focused container to the specified workspace"""
if isinstance(which, int):
subprocess.check_call(
("i3-msg", "move", "container", "to", "workspace", "number", str(which))
)
else:
subprocess.check_call(
("i3-msg", "move", "container", "to", "workspace", which)
)
def i3wm_move_to_output(which: str):
"""Move the focused container to the specified output."""
subprocess.check_call(("i3-msg", "move", "container", "to", "output", which))
def i3wm_move_position(where: str):
"""Move the focused container to the specified position."""
subprocess.check_call(("i3-msg", "move", "position", where))
def i3wm_lock():
"""Trigger the lock screen"""
key = settings.get("user.i3_mod_key")
actions.key(f"{key}-shift-x")
+99
View File
@@ -0,0 +1,99 @@
# NOTE: If you want to use i3wm you must enable the tag settings.talon. i.e.: `tag(): user.i3wm`
os: linux
tag: user.i3wm
-
port <number_small>: user.i3wm_switch_to_workspace(number_small)
(port flip | flipper): user.i3wm_switch_to_workspace("back_and_forth")
port right: user.i3wm_switch_to_workspace("next")
port left: user.i3wm_switch_to_workspace("prev")
(win | window) left: user.i3wm_focus("left")
(win | window) right: user.i3wm_focus("right")
(win | window) up: user.i3wm_focus("up")
(win | window) down: user.i3wm_focus("down")
(win | window) kill: app.window_close()
(win | window) stacking: user.i3wm_layout("stacking")
(win | window) default: user.i3wm_layout()
(win | window) tabbed: user.i3wm_layout("tabbed")
reload i three config: user.i3wm_reload()
restart i three: user.i3wm_restart()
(full screen | scuba): user.i3wm_fullscreen()
toggle floating: user.i3wm_float()
focus floating: user.i3wm_focus("mode_toggle")
center window: user.i3wm_move_position("center")
resize mode: user.i3wm_mode("resize")
focus parent: user.i3wm_focus("parent")
focus child: user.i3wm_focus("child")
# resize helpers
grow window:
user.i3wm_mode("resize")
key(right:10)
key(down:10)
# escape resize mode
key(escape)
# center window
sleep(200ms)
user.i3wm_move_position("center")
# resize helpers
shrink window:
user.i3wm_mode("resize")
key(left:10)
key(up:10)
# escape resize mode
key(escape)
# center window
sleep(200ms)
user.i3wm_move_position("center")
horizontal (shell | terminal):
user.i3wm_split("h")
user.i3wm_shell()
vertical (shell | terminal):
user.i3wm_split("v")
user.i3wm_shell()
# XXX - just replace with shuffle eventually?
# XXX - like also need to match the generic talon commands
(shuffle | move (win | window) [to] port) <number_small>:
user.i3wm_move_to_workspace(number_small)
(shuffle | move (win | window) [to] last port):
user.i3wm_move_to_workspace("back_and_forth")
(shuffle | move) flipper: user.i3wm_move_to_workspace("back_and_forth")
(shuffle | move (win | window) left): user.i3wm_move("left")
(shuffle | move (win | window) right): user.i3wm_move("right")
(shuffle | move (win | window) up): user.i3wm_move("up")
(shuffle | move (win | window) down): user.i3wm_move("down")
(win | window) horizontal: user.i3wm_split("h")
(win | window) vertical: user.i3wm_split("v")
make scratch: user.i3wm_move("scratchpad")
[(show | hide)] scratch: user.i3wm_show_scratchpad()
next scratch:
user.i3wm_show_scratchpad()
user.i3wm_show_scratchpad()
# these rely on the user settings for the mod key. see i3wm.py Actions class
launch: user.i3wm_launch()
launch <user.text>:
user.i3wm_launch()
sleep(100ms)
insert("{text}")
lock screen: user.i3wm_lock()
(launch shell | koopa): user.i3wm_shell()
new scratch (shell | window):
user.i3wm_shell()
sleep(200ms)
user.i3wm_move("scratchpad")
user.i3wm_show_scratchpad()
murder:
user.deprecate_command("2023-02-04", "murder", "win kill")
app.window_close()