tildemerge/openbox_files.sh

63 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
# Copyright (c) 2018-2019 TildeLinux Maintainers
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Email: tildelinux@tildeverse.org
mounts_file="$HOME/.ssh/mounts"
get_locations() {
if ! grep -q "SSHFS Mount " "$mounts_file"
then
printf "<item label=\"Configure Locations...\">\\n"
printf " <action name=\"Execute\">\\n"
printf " <command>%s/.local/bin/sshfs_gui.sh</command>\\n" "$HOME"
printf " </action>\\n"
printf "</item>\\n"
else
while read -r line
do
location_path=""
if printf "%s" "$line" | grep -q "SSHFS Mount "
then
location_path=$(printf "%s" "$line" | rev | cut -f 2 -d ' ' | rev)
location_name=$(printf "%s" "$line" | rev | cut -f 1-2 -d ' ' | rev)
printf "<item label=\"%s\">\\n" "$location_name"
printf " <action name=\"Execute\">\\n"
printf " <command>thunar %s</command>\\n" "$location_path"
printf " </action>\\n"
printf "</item>\\n"
fi
done < "$mounts_file"
printf "<separator/>\\n"
printf "<item label=\"Configure More Locations...\">\\n"
printf " <action name=\"Execute\">\\n"
printf " <command>%s/.local/bin/sshfs_gui.sh</command>\\n" "$HOME"
printf " </action>\\n"
printf "</item>\\n"
fi
}
printf "<openbox_pipe_menu>\\n"
printf "<item label=\"File Manager\">\\n"
printf " <action name=\"Execute\">\\n"
printf " <command>thunar</command>\\n"
printf " </action>\\n"
printf "</item>\\n"
printf "<separator label=\"Locations\" />\\n"
get_locations
printf "</openbox_pipe_menu>\\n"