diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..783cd5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp + diff --git a/efx_site.default b/efx_site.default new file mode 100644 index 0000000..95987b6 --- /dev/null +++ b/efx_site.default @@ -0,0 +1,10 @@ +{ "sessions": + [ + { "title": "System Shell", + "cmd": "/bin/bash --login" + }, + { "title": "C Shell", + "cmd": "/bin/csh" + } + ] +} diff --git a/install.conf.yaml b/install.conf.yaml index 189f196..7e08e13 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -7,6 +7,8 @@ - link: ~/.bashrc: bashrc ~/.vimrc: vimrc + ~/.config/kitty/kitty.conf: kitty.conf + ~/.scripts: scripts - shell: - [git submodule update --init --recursive, Installing submodules] diff --git a/kitty.conf b/kitty.conf new file mode 100644 index 0000000..8c46da3 --- /dev/null +++ b/kitty.conf @@ -0,0 +1,12 @@ + +map ctrl+shift+1 new_tab efx_session 0 +map ctrl+shift+2 new_tab efx_session 1 +map ctrl+shift+3 new_tab efx_session 2 +map ctrl+shift+4 new_tab efx_session 3 +map ctrl+shift+5 new_tab efx_session 4 +map ctrl+shift+6 new_tab efx_session 5 +map ctrl+shift+7 new_tab efx_session 6 +map ctrl+shift+8 new_tab efx_session 7 +map ctrl+shift+9 new_tab efx_session 8 + + diff --git a/scripts/efx_session b/scripts/efx_session new file mode 100755 index 0000000..c581d8b --- /dev/null +++ b/scripts/efx_session @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +import os +import shlex +from pathlib import Path +from typing import List, Optional +import argparse +import json + +class EfxSession: + def __init__(self, cfg): + self.cmd = cfg.get('cmd', '/bin/bash --login') + self.title = cfg.get('title', 'System Shell') + + def execute(self): + cmd_val = shlex.split(self.cmd) + os.execvp(cmd_val[0], cmd_val) + +class EfxConfig: + def __init__(self, cfg): + self._sessions = _attr_sessions(cfg) + + def get_session(self, num: int) -> Optional[EfxSession]: + return self._sessions[num] if 0 <= num < len(self._sessions) else None + +def _load_config() -> EfxConfig: + json_site = (Path.home() / '.efx_site.json') + if not json_site.exists(): + raise RuntimeError('No available configuration') + cfg = json.loads(json_site.read_text()) + return EfxConfig(cfg) + +def _attr_sessions(cfg) -> List[EfxSession]: + return [EfxSession(x) for x in cfg.get('sessions', [])] + +def main(): + parser = argparse.ArgumentParser(description='Site Information[Session]') + parser.add_argument('id', type=int, help='Session identifier') + args = parser.parse_args() + + cfg = _load_config() + session = cfg.get_session(args.id) + if not session: + raise RuntimeError('Invalid session id') + session.execute() + + +if __name__ == "__main__": + main() +