feat: added terminal cloning
This commit is contained in:
parent
9ee470cfb5
commit
518f84e916
39
pkgs/scripts/clone-term.nix
Normal file
39
pkgs/scripts/clone-term.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
ps,
|
||||||
|
procps,
|
||||||
|
xdotool,
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "clone-term";
|
||||||
|
runtimeInputs = [ps procps xdotool];
|
||||||
|
text = ''
|
||||||
|
|
||||||
|
PAREN=$(xdotool getwindowfocus getwindowpid)
|
||||||
|
|
||||||
|
MAXDEPTH=0
|
||||||
|
SELECTED=0
|
||||||
|
|
||||||
|
function recurse() {
|
||||||
|
#shellcheck disable=SC2207
|
||||||
|
for i in $(pgrep -P "$1"); do
|
||||||
|
|
||||||
|
if [[ "$(readlink -e "/proc/''${i}/exe")" == *"zsh"* ]] && [[ $2 -gt $MAXDEPTH ]]; then
|
||||||
|
SELECTED="$i"
|
||||||
|
MAXDEPTH="$2"
|
||||||
|
fi
|
||||||
|
recurse "$i" "$(( $2 + 1 ))"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
recurse "$PAREN" 1
|
||||||
|
|
||||||
|
if [[ $SELECTED == 0 ]]; then
|
||||||
|
echo "not zsh found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# kitty should be from user env
|
||||||
|
kitty --detach -d "$(readlink "/proc/''${SELECTED}/cwd")"
|
||||||
|
'';
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
_final: prev: {
|
_final: prev: {
|
||||||
scripts = {
|
scripts = {
|
||||||
usbguardw = prev.callPackage ./usbguardw.nix {};
|
usbguardw = prev.callPackage ./usbguardw.nix {};
|
||||||
|
clone-term = prev.callPackage ./clone-term.nix {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
maim = "${pkgs.maim}/bin/maim -qs -b 1 --hidecursor";
|
maim = "${pkgs.maim}/bin/maim -qs -b 1 --hidecursor";
|
||||||
in {
|
in {
|
||||||
"Menu" = "exec ${cfg.menu}";
|
"Menu" = "exec ${cfg.menu}";
|
||||||
|
"${cfg.modifier}+c" = "exec ${lib.getExe pkgs.scripts.clone-term}";
|
||||||
"Ctrl+F9" = "exec ${config.xsession.wallpapers.script}";
|
"Ctrl+F9" = "exec ${config.xsession.wallpapers.script}";
|
||||||
"${cfg.modifier}+F12" =
|
"${cfg.modifier}+F12" =
|
||||||
"exec "
|
"exec "
|
||||||
|
|
Loading…
Reference in a new issue