mirror of
https://github.com/fsquillace/junest.git
synced 2026-07-20 17:59:38 +00:00
50 lines
No EOL
2.1 KiB
Bash
50 lines
No EOL
2.1 KiB
Bash
#!/bin/sh
|
|
|
|
case "$1" in
|
|
''|'-h'|'--help')
|
|
echo "\n USAGE:\n\n junest-export {OPTION} {APPNAME} {FLAG}\n"
|
|
echo " EXAMPLES:\n\n junest-export --app celestia\n junest-export --app kdenlive --media\n junest-export --app pamac-manager --sudo\n"
|
|
echo " OPTIONS:\n"
|
|
echo " --app/-a: name of the application to export"
|
|
echo "\n FLAGS:\n"
|
|
echo " --media/-m: enable the support for drives mounted in /media"
|
|
echo " --sudo/-S: specify if the exported item should be run as sudo\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
|
|
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)
|
|
addmedia='"--bind /media /media"'
|
|
sed -i "s#Exec=$appbinary#Exec=sh -c '~/.local/share/junest/bin/junest -- $appbinary'#g" ~/.cache/junest-export/$launchername
|
|
while [ -n "$3" ]
|
|
do
|
|
case "$3" in
|
|
'-S'|'--sudo') sed -i "s#junest --#junest -- sudo#g" ~/.cache/junest-export/$launchername; break;;
|
|
'-m'|'--media') sed -i "s#junest --#junest -b $addmedia --#g" ~/.cache/junest-export/$launchername; break;;
|
|
''|*) break;;
|
|
esac
|
|
done
|
|
while [ -n "$4" ]
|
|
do
|
|
case "$4" in
|
|
'-S'|'--sudo') sed -i "s#junest -b $addmedia --#jjunest -b $addmedia -- sudo#g" ~/.cache/junest-export/$launchername; break;;
|
|
'-m'|'--media') sed -i "s#junest -- sudo#junest -b $addmedia -- sudo#g" ~/.cache/junest-export/$launchername; break;;
|
|
''|*) break;;
|
|
esac
|
|
done
|
|
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
|
|
|