diff options
Diffstat (limited to 'sxhkd')
| -rw-r--r-- | sxhkd/sxhkdrc.i3 | 46 | ||||
| -rw-r--r-- | sxhkd/terminal_i3.py | 58 |
2 files changed, 0 insertions, 104 deletions
diff --git a/sxhkd/sxhkdrc.i3 b/sxhkd/sxhkdrc.i3 deleted file mode 100644 index ec9af48..0000000 --- a/sxhkd/sxhkdrc.i3 +++ /dev/null @@ -1,46 +0,0 @@ -F12 - python ~/.config/sxhkd/terminal_i3.py - -mod4 + Return - alacritty -mod4 + space - rofi -show drun -mod4 + backslash - i3-msg "split h" -mod4 + minus - i3-msg "split v" -mod4 + Tab - i3-msg "layout toggle split" -mod4 + p - i3-msg "focus parent" -mod4 + r - i3-msg "mode resize" - -mod4 + shift + r - i3-msg "restart" -mod4 + shift + e - i3-msg "exit" -mod4 + shift + q - i3-msg "kill" -mod4 + shift + space - i3-msg "floating toggle" -mod4 + shift + Return - i3-msg "fullscreen toggle" - -mod4 + {h, Left} - i3-msg "focus left" -mod4 + {j, Down} - i3-msg "focus down" -mod4 + {k, Up} - i3-msg "focus up" -mod4 + {l, Right} - i3-msg "focus right" - -mod4 + shift + {h, Left} - i3-msg "move left" -mod4 + shift + {j, Down} - i3-msg "move down" -mod4 + shift + {k, Up} - i3-msg "move up" -mod4 + shift + {l, Right} - i3-msg "move right" diff --git a/sxhkd/terminal_i3.py b/sxhkd/terminal_i3.py deleted file mode 100644 index c53ff53..0000000 --- a/sxhkd/terminal_i3.py +++ /dev/null @@ -1,58 +0,0 @@ -import json -import subprocess - - -def send_msg(msg_type, msg): - p = subprocess.run(['i3-msg', '-t', msg_type, msg], - capture_output=True, - check=True) - return json.loads(p.stdout.decode('utf-8')) - - -def is_term_running(): - - def node_exists(node): - if node.get('window_properties', {}).get('instance') == 'scratchpad_term': - return True - return any(node_exists(i) for i in node.get('nodes', [])) - - tree = send_msg('get_tree', '') - return node_exists(tree) - - -def run_term(): - subprocess.Popen([ - 'alacritty', '--class', 'scratchpad_term', - '-e', 'tmux', 'new-session', '-A', '-s', 'default']) - - -def get_focused_workspace(): - workspaces = send_msg('get_workspaces', '') - for workspace in workspaces: - if workspace['focused']: - return workspace['name'] - - -def get_focused_output(focused_workspace): - outputs = send_msg('get_outputs', '') - for out in outputs: - if out['current_workspace'] == focused_workspace: - return out['name'] - - -def main(): - focused_workspace = get_focused_workspace() - if focused_workspace == '9:term': - send_msg('command', 'workspace back_and_forth') - else: - focused_output = get_focused_output(focused_workspace) - if not is_term_running(): - run_term() - send_msg('command', '[instance="scratchpad_term"] ' - 'move container to workspace "9:term"') - send_msg('command', 'workspace "9:term"') - send_msg('command', f'move workspace to output {focused_output}') - - -if __name__ == '__main__': - main() |
