feat: Add optional focus action to tell function
Also, move it to general-graphical config.
This commit is contained in:
parent
548fbfef2a
commit
ec04e57c33
|
@ -450,7 +450,40 @@ in {
|
|||
};
|
||||
};
|
||||
programs = {
|
||||
bash.shellAliases.xclip = "${pkgs.xclip}/bin/xclip -selection clipboard";
|
||||
bash = {
|
||||
shellAliases.xclip = "${pkgs.xclip}/bin/xclip -selection clipboard";
|
||||
interactiveShellInit = ''
|
||||
join_by() {
|
||||
local d=''${1-} f=''${2-}
|
||||
if shift 2; then
|
||||
${pkgs.coreutils}/bin/printf %s "$f" "''${@/#/$d}"
|
||||
fi
|
||||
}
|
||||
|
||||
tell() {
|
||||
session_name="$(${pkgs.tmux}/bin/tmux list-clients -t "$TMUX_PANE" -F "#{session_name}" | ${pkgs.coreutils}/bin/head -n 1)"
|
||||
|
||||
tree="$(i3-msg -t get_tree)"
|
||||
window_id="$(jq -e '.nodes[].nodes[].nodes[].nodes | map(select(.focused)) | .[].window' <<< "$tree")"
|
||||
if test -z "$window_id"; then
|
||||
window_id="$(jq -e '.nodes[].nodes[].nodes[].floating_nodes[].nodes | map(select(.focused)) | .[].window' <<< "$tree")"
|
||||
fi
|
||||
|
||||
if eval "$@"; then
|
||||
icon="data-information"
|
||||
else
|
||||
icon="data-error"
|
||||
fi
|
||||
|
||||
result="$(${pkgs.dunst}/bin/dunstify -a "longCommand" -u normal -i "$icon" -A 1,focus "$session_name" "$(join_by " " $@)")"
|
||||
if test "$result" -eq 1; then
|
||||
i3-msg "[id=$window_id] focus"
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _command tell
|
||||
'';
|
||||
};
|
||||
wireshark.enable = true;
|
||||
};
|
||||
services.unclutter-xfixes = {
|
||||
|
|
|
@ -205,31 +205,6 @@
|
|||
./.comma $@
|
||||
fi
|
||||
}
|
||||
|
||||
tell() {
|
||||
join_by() {
|
||||
local d=''${1-} f=''${2-}
|
||||
if shift 2; then
|
||||
${pkgs.coreutils}/bin/printf %s "$f" "''${@/#/$d}"
|
||||
fi
|
||||
}
|
||||
|
||||
session_name="$(${pkgs.tmux}/bin/tmux list-clients -t "$TMUX_PANE" -F "#{session_name}" | ${pkgs.coreutils}/bin/head -n 1)"
|
||||
|
||||
if eval "$@"; then
|
||||
icon="data-information"
|
||||
else
|
||||
icon="data-error"
|
||||
fi
|
||||
|
||||
${pkgs.dunst}/bin/dunstify -a "longCommand" \
|
||||
-u normal \
|
||||
-i "$icon" \
|
||||
"$session_name" \
|
||||
"$(join_by " " $@)"
|
||||
}
|
||||
|
||||
complete -F _command tell
|
||||
'')
|
||||
]);
|
||||
shellAliases = let eza = "${pkgs.eza}/bin/eza";
|
||||
|
|
Loading…
Reference in a new issue