blob: 6a5c52957d3f4d54f42f96821fae6fc126622405 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/usr/bin/env sh
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
# This wrapper script is invoked by xdg-desktop-portal-termfilechooser.
#
# For more information about input/output arguments read `xdg-desktop-portal-termfilechooser(5)`
set -ex
multiple="$1"
directory="$2"
save="$3"
path="$4"
out="$5"
# echo > /tmp/stdout
# echo > /tmp/stderr
#
# exec 1>> /tmp/stdout
# exec 2>> /tmp/stderr
if [ "$save" = "1" ]; then
# save a file
set -- -selection-path="$out" -command='set promptfmt "Select the file to write to %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$path"
elif [ "$directory" = "1" ]; then
# upload files from a directory
set -- -last-dir-path="$out" -command='set dironly' -command='set promptfmt "Select directory (quit in dir to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$path"
elif [ "$multiple" = "1" ]; then
# upload multiple files
set -- -selection-path="$out" -command='set promptfmt "Select file(s) (open file to select it; <Space> to select multiple) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$path"
else
# upload only 1 file
set -- -selection-path="$out" -command='set promptfmt "Select file (open file to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$path"
fi
alacritty --title 'floating please' -e lf "$@"
# Delete the left recommended file, if we did not actually save anything.
if [ "$save" = "1" ] && ! [ -s "$out" ]; then
rm "$path"
fi
|