#!/usr/bin/env bash
set -e

last_dir_file=/run/user/1000/rofi-fb.last-dir


if [[ -n "$ROFI_DATA" ]] && [[ -d "$ROFI_DATA" ]]
then
    cd "$ROFI_DATA"
fi

if [[ -d "$1" ]]
then
    cd "$1"
    echo -e "\0data\x1f$(pwd)"
elif [[ -x "$1" ]]
then
    "$1"
elif [[ -n "$1" ]]
then
    file="$(realpath "$1")"
    echo "opening '$file'" >&2
    systemd-run --user --scope xdg-open "$file" &>/dev/null
    exit 0
fi

echo -e "\0message\x1f$(pwd)"
echo "../"
ls -A1 --file-type --group-directories-first
# vim:sw=4:ts=4:et:
