PKa9Om_, rofi_tmuxp.py"""Rofi script to launch tmuxp sessions""" import logging import subprocess import sys from pathlib import Path import tmuxp from kaptan import Kaptan __version__ = "0.1.0" logger = logging.getLogger("rofi_tmuxp") def main(): """Main script entrypoint. If no command line arguments are provided, print out a list of available sessions. Otherwise, run tmuxp in a new terminal with the session provided on the command line. """ _setup_logging() sessions = get_sessions() if len(sys.argv) == 1: for session in sorted(sessions): print(session) else: try: session = sessions[sys.argv[1]] except KeyError: msg = "No such session: {}".format(sys.argv[1]) logger.warning(msg) rofi_error(msg) return start_session(session) def get_sessions(): """Get tmuxp sessions. Returns a dictionary mapping session name to config file paths. """ config_dir = Path(tmuxp.cli.get_config_dir()) sessions = {} for filename in tmuxp.config.in_dir(str(config_dir)): config_path = config_dir / filename try: sessions[_get_session_name(config_path)] = config_path except KeyError: logger.warning("No session name configured in '%s'", config_path) except Exception as e: logger.warning("Error loading config '%s': %r", config_path, e) return sessions def _get_session_name(cfg_path): """Extract the session name from a tmuxp config file""" config = Kaptan() config.import_config(str(cfg_path)) return config.get("session_name") def start_session(config_path): """Lanuch tmuxp in a new terminal window.""" subprocess.Popen( ["rofi-sensible-terminal", "-e", "tmuxp", "load", str(config_path)], stdout=subprocess.DEVNULL, ) def rofi_error(message): """Display an error message using the rofi error dialog""" subprocess.Popen(["rofi", "-e", message], stdout=subprocess.DEVNULL) def _setup_logging(): logging.basicConfig( style="{", level=logging.WARNING, format="{asctime} - {name} - {levelname} - {message}", ) if __name__ == "__main__": # pragma: no cover main() PK!H*.+rofi_tmuxp-0.1.0.dist-info/entry_points.txtN+I/N.,()*O--(1L<..PKϳ0O?00"rofi_tmuxp-0.1.0.dist-info/LICENSEMIT License Copyright (c) 2019 Heinrich Kruger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HMuSa rofi_tmuxp-0.1.0.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,szd&Y)r$[)T&UD"PK!H_T #rofi_tmuxp-0.1.0.dist-info/METADATAVMs6WxI2cvumDJs "Quo(˔ICow8wa*1L|==J#vյ->Bxީ!'\8N"1{,yZ6TUY8L{ѶtK|N:_k;mW [_<-Ŋ}_:iK.#?GoҷLT+/OkWmbg Gp )}&VѦ<F6 s;n{iueyJUsy.9}.g33|NKn]Q1 o%K {`._Y&i/1;q]OJ#Sa!VhJJj0RJ{fVQ 'Wd)ԇ4ڶ7zȕtIѳA帢Q˝Ǥ~T 򜗕 ]_9nD69}[dD9ϛ/d`\-&VWd!S+] ?Ʀp6[J|8'V?Yr2@jh;Y7j!+7¥4VplqpQwMLzJ3[lz 4'M쟑,\!*F*AHjp? Ec%F&5!l@ %\T%e@Χ4Y4aFf\;YދvrqgsRbqNu} a6;ً܏08A%Pf| '%Ubp ĀԡsaTȇQѩ ^KSeFT2ݣmT G/Wryû%MojvaB?`%_qaĪ% ?Q̏ 2t.L1j6W&㋫1cPK!HØv'!rofi_tmuxp-0.1.0.dist-info/RECORD}OB@{eXFt؃#ID)aXo[?~lf]~M9~sy4I9*H?,>Rʐo/ZP_^Qt+gU.*lds#O ;>}z#,ד;iTU$`,63oW(z-nAI)m:j@0Þms8AWľ 0 q䘑xeCszVXR$PwLvH$m0r<PKa9Om_, rofi_tmuxp.pyPK!H*.+ rofi_tmuxp-0.1.0.dist-info/entry_points.txtPKϳ0O?00" rofi_tmuxp-0.1.0.dist-info/LICENSEPK!HMuSa  rofi_tmuxp-0.1.0.dist-info/WHEELPK!H_T #rofi_tmuxp-0.1.0.dist-info/METADATAPK!HØv'!rofi_tmuxp-0.1.0.dist-info/RECORDPK