Skip to content

Commit

Permalink
Fix tools invocation for xdg scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com>
  • Loading branch information
unbel13ver authored and brianmcgillion committed Oct 24, 2024
1 parent 5d5ae6d commit 3038efc
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions modules/common/services/xdghandlers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,30 @@ let
noDisplay = true;
};
# The xdgopenfile script sends a command to the GUIVM with the file path and type over TCP connection
xdgOpenFile = pkgs.writeShellScriptBin "xdgopenfile" ''
type=$1
filename=$2
filepath=$(/run/current-system/sw/bin/realpath "$filename")
if [[ -z "$filepath" ]]; then
echo "File path is empty in the XDG open script" | systemd-cat -p info
exit 1
fi
if [[ "$type" != "pdf" && "$type" != "image" ]]; then
echo "Unknown file type in the XDF open script" | systemd-cat -p info
exit 1
fi
echo "Opening $filepath with type $type" | systemd-cat -p info
echo -e "$type\n$filepath" | ${pkgs.netcat}/bin/nc -N gui-vm ${toString config.ghaf.services.xdgopener.xdgPort}
'';
xdgOpenFile = pkgs.writeShellApplication {

name = "xdgopenfile";
runtimeInputs = [
pkgs.coreutils
pkgs.netcat
pkgs.systemd
];
text = ''
type=$1
filename=$2
filepath=$(realpath "$filename")
if [[ -z "$filepath" ]]; then
echo "File path is empty in the XDG open script" | systemd-cat -p info
exit 1
fi
if [[ "$type" != "pdf" && "$type" != "image" ]]; then
echo "Unknown file type in the XDF open script" | systemd-cat -p info
exit 1
fi
echo "Opening $filepath with type $type" | systemd-cat -p info
echo -e "$type\n$filepath" | nc -N gui-vm ${toString config.ghaf.services.xdgopener.xdgPort}
'';
};
in
{
options.ghaf.services.xdghandlers = {
Expand Down

0 comments on commit 3038efc

Please sign in to comment.