More launcher options

This commit is contained in:
Charlotte Van Petegem 2020-02-10 19:49:45 +01:00
parent b8ac9c70e1
commit a8acd67b18
2 changed files with 50 additions and 6 deletions

View file

@ -63,9 +63,11 @@
okular okular
rambox rambox
ranger ranger
slurp
sshfs sshfs
thunderbird thunderbird
vanilla-dmz vanilla-dmz
wf-recorder
wl-clipboard wl-clipboard
]; ];
file = { file = {

View file

@ -33,6 +33,24 @@ let
launcher = pkgs.writeScript "launcher" '' launcher = pkgs.writeScript "launcher" ''
#!${pkgs.zsh}/bin/zsh #!${pkgs.zsh}/bin/zsh
_sighandler() {
kill -INT "$child" 2>/dev/null
}
calc_options() {
echo "calc "
}
calc() {
if [ -n "$1" ]
then
${pkgs.libqalculate}/bin/qalc "$1"
sleep 5
else
${pkgs.libqalculate}/bin/qalc
fi
}
emoji_options() { emoji_options() {
cat ${emoji_list} | sed "s/^/emoji /" cat ${emoji_list} | sed "s/^/emoji /"
} }
@ -42,6 +60,34 @@ let
${pkgs.sway}/bin/swaymsg exec -- "echo -n $char | ${pkgs.wl-clipboard}/bin/wl-copy --foreground" ${pkgs.sway}/bin/swaymsg exec -- "echo -n $char | ${pkgs.wl-clipboard}/bin/wl-copy --foreground"
} }
record_options() {
${pkgs.sway}/bin/swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[]["name"]' | sed "s/^/record /"
echo record select
}
record() {
filename="$(${xdg-user-dirs}/bin/xdg-user-dir VIDEOS)/$(date +'screenrecording_%y-%m-%d-%H%M%S.mp4')"
trap _sighandler SIGINT
if [[ "$1" = "select" ]]
then
${pkgs.wf-recorder}/bin/wf-recorder -g "$(${pkgs.slurp}/bin/slurp)" -f "$filename" &
else
wf-recorder -o $! -f "$filename" &
fi
child=$!
wait "$child"
# We wait two times, because the first wait exits when the process receives a signal. The process might have finished though, so we ignore errors.
wait "$child" 2>/dev/null
if [ -f "$filename" ]
then
echo "Saved as $filename"
else
echo "Something went wrong while recording"
fi
sleep 5
}
run_options() { run_options() {
print -rl -- ''${(ko)commands} | sed "s/^/run /" print -rl -- ''${(ko)commands} | sed "s/^/run /"
} }
@ -67,7 +113,7 @@ let
${pkgs.sway}/bin/swaymsg \[con_id="$window"\] focus ${pkgs.sway}/bin/swaymsg \[con_id="$window"\] focus
} }
CHOSEN=$(cat <(windows_options) <(ssh_options) <(run_options) <(emoji_options) | ${pkgs.fzy}/bin/fzy --lines 36 | tail -n1) CHOSEN=$(cat <(windows_options) <(ssh_options) <(run_options) <(record_options) <(calc_options) <(emoji_options) | ${pkgs.fzy}/bin/fzy --lines 36 | tail -n1)
if [ -n "$CHOSEN" ] if [ -n "$CHOSEN" ]
then then
@ -77,7 +123,6 @@ let
$PREFIX $WORD $PREFIX $WORD
fi fi
''; '';
in in
{ {
imports = [ imports = [
@ -87,10 +132,7 @@ in
programs = { programs = {
sway = { sway = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = [ pkgs.xwayland ];
wf-recorder
xwayland
];
extraSessionCommands = '' extraSessionCommands = ''
export XDG_SESSION_TYPE=wayland export XDG_SESSION_TYPE=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 export QT_WAYLAND_DISABLE_WINDOWDECORATION=1