From b97673d210f1c886eacc92217c8b4657f15ddbe3 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Sun, 12 Mar 2023 22:32:55 +0100 Subject: [PATCH] Add files via upload --- bin/junest-export | 51 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/bin/junest-export b/bin/junest-export index 4ebcbb7..f8530d3 100644 --- a/bin/junest-export +++ b/bin/junest-export @@ -1,7 +1,15 @@ #!/bin/sh case "$1" in - '-a'|'-app') + ''|'-h'|'--help') + echo "\n USAGE:\n\n junest-export {OPTION} {APPNAME}\n" + echo " EXAMPLES:\n\n junest-export --app celestia\n junest-export --bind-app kdenlive\n junest-export --sudo-app pamac-manager\n" + echo " OPTIONS:\n" + echo " --app/-a: export the app normally\n" + echo " --sudo-app/-sa: export an app requiring root privileges\n" + echo " --bind-app/-ba: export an app and made it use external drives\n" + ;; + '-a'|'--app') if [ -n "$SUDO_COMMAND" ]; then echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n"; exit; fi while [ -n "$1" ] do @@ -19,6 +27,45 @@ case "$1" in cp ~/.junest/usr/share/pixmaps/*$appiconname* ~/.local/share/icons/ > /dev/null 2>&1 echo " $2 has been successfully exported!" exit - done + done;; + '-sa'|'--sudo-app') + if [ -n "$SUDO_COMMAND" ]; then echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n"; exit; fi + while [ -n "$1" ] + do + mkdir ~/.cache/junest-export + cp ~/.junest/usr/share/applications/*$2* ~/.cache/junest-export + launchername=$(ls ~/.cache/junest-export) + appbinary=$(cat ~/.cache/junest-export/$launchername | grep Exec | cut -c 6- | head -1) + appiconname=$(cat ~/.cache/junest-export/$launchername | grep Icon | cut -c 6- | head -1) + sed -i "s#Exec=$appbinary#Exec=sh -c '~/.local/share/junest/bin/junest -- sudo $appbinary'#g" ~/.cache/junest-export/$launchername + mkdir -p ~/.local/share/applications + mv ~/.cache/junest-export/$launchername ~/.local/share/applications/ + rm -R -f ~/.cache/junest-export + mkdir -p ~/.local/share/icons + ln -s ~/.junest/usr/share/icons/hicolor ~/.local/share/icons/hicolor > /dev/null 2>&1 + cp ~/.junest/usr/share/pixmaps/*$appiconname* ~/.local/share/icons/ > /dev/null 2>&1 + echo " $2 has been successfully exported!" + exit + done;; + '-ba'|'--bind-app') + if [ -n "$SUDO_COMMAND" ]; then echo -e "\n WARNING: You don't need to run the option '$1' with SUDO.\n"; exit; fi + while [ -n "$1" ] + do + mkdir ~/.cache/junest-export + cp ~/.junest/usr/share/applications/*$2* ~/.cache/junest-export + launchername=$(ls ~/.cache/junest-export) + appbinary=$(cat ~/.cache/junest-export/$launchername | grep Exec | cut -c 6- | head -1) + appiconname=$(cat ~/.cache/junest-export/$launchername | grep Icon | cut -c 6- | head -1) + addbind='"--bind /media /media"' + sed -i "s#Exec=$appbinary#Exec=sh -c '~/.local/share/junest/bin/junest -b $addbind -- $appbinary'#g" ~/.cache/junest-export/$launchername + mkdir -p ~/.local/share/applications + mv ~/.cache/junest-export/$launchername ~/.local/share/applications/ + rm -R -f ~/.cache/junest-export + mkdir -p ~/.local/share/icons + ln -s ~/.junest/usr/share/icons/hicolor ~/.local/share/icons/hicolor > /dev/null 2>&1 + cp ~/.junest/usr/share/pixmaps/*$appiconname* ~/.local/share/icons/ > /dev/null 2>&1 + echo " $2 has been successfully exported!" + exit + done;; esac \ No newline at end of file