Switch to dmenu function & delete zenity menu

This commit is contained in:
q3aql 2022-05-29 00:43:50 +02:00
parent 46896516fa
commit d99718cb2c

View File

@ -109,63 +109,88 @@ function checkFileCredentials() {
fi fi
} }
function aboutText() {
echo " ABOUT:"
echo ""
echo " Software: dmenu_protonvpn ${VERSION}"
echo " Author: q3aql"
echo " Contact: q3aql@duck.com"
echo " License: GPL v2.0"
echo ""
}
function showAbout() { function showAbout() {
zenity --title "About" --window-icon=${iconPath} --info --width=330 \ aboutText | /opt/dmenu_protonvpn/dmenu "$@" -p "嬨 dmenu_protonvpn v${VERSION}"
--text "Software: dmenu_protonvpn ${VERSION} (${M_DATE})\nAuthor: q3aql\nContact: q3aql@duck.com\nLicense: GPL v2.0" run_main
}
function downloadFilesText() {
echo "ﯲ DOWNLOAD PROTONVPN FILES:"
echo ""
echo " Steps for download .ovpn files:"
echo ""
echo "  Open URL: ${url_download}"
echo "  Login with your Proton account"
echo "  Click to Downloads > OpenVPN configuration files"
echo "  Download *.ovpn files and copy to ${HOME}/protonFiles"
echo ""
echo "  Press HERE for open URL with browser"
echo ""
} }
function downloadProtonVPNFiles() { function downloadProtonVPNFiles() {
openBrowser "${url_download}" select_output=$(downloadFilesText | /opt/dmenu_protonvpn/dmenu "$@" -p "嬨 dmenu_protonvpn v${VERSION}")
zenity --title "dmenu_protonvpn ${VERSION} (${M_DATE})" --window-icon=${iconPath} --info --width=400 \ if [ "${select_output}" == "  Press HERE for open URL with browser" ] ; then
--text "* Steps for download .ovpn files:\n\n - Open URL: ${url_download}\n - Login with your Proton account\n - Click to Downloads > OpenVPN configuration files\n - Download .ovpn files and copy to ${HOME}/protonFiles\n" openBrowser "${url_download}" &
run_main
else
run_main
fi
} }
list_output=$(list_show_icons | /opt/dmenu_protonvpn/dmenu "$@" -p "嬨 dmenu_protonvpn v${VERSION}") function run_main() {
run_output=$(echo "${list_output}" | cut -c4-999) echo "MAIN # Selected"
echo "${run_output} # Selected" list_output=$(list_show_icons | /opt/dmenu_protonvpn/dmenu "$@" -p "嬨 dmenu_protonvpn v${VERSION}")
if [ "${run_output}" == " About" ] ; then run_output=$(echo "${list_output}" | cut -c4-999)
if [ -f /usr/bin/zenity ] ; then echo "${run_output} # Selected"
if [ "${run_output}" == " About" ] ; then
showAbout showAbout
else elif [ "${run_output}" == " Download ProtonVPN files" ] ; then
echo ${termrun} ${menu_files}/about.sh
${termrun} ${menu_files}/about.sh
fi
elif [ "${run_output}" == " Download ProtonVPN files" ] ; then
if [ -f /usr/bin/zenity ] ; then
downloadProtonVPNFiles downloadProtonVPNFiles
else elif [ "${run_output}" == " Edit Credentials" ] ; then
echo ${termrun} "${menu_files}/download-protonvpn-files.sh" if [ -f /usr/bin/zenity ] ; then
${termrun} "${menu_files}/download-protonvpn-files.sh" editCredentials
fi
elif [ "${run_output}" == " Edit Credentials" ] ; then
if [ -f /usr/bin/zenity ] ; then
editCredentials
else
echo ${termrun} "${menu_files}/edit-credentials.sh"
${termrun} "${menu_files}/edit-credentials.sh"
fi
else
if [ -z "${run_output}" ] ; then
echo > /dev/null
else
if [ -f /usr/bin/sudo ] ; then
run_output=$(echo ${run_output} | tr -s " ")
cp -rf ${protonFiles}/${run_output} /tmp/
insertCredentials /tmp/${run_output}
echo ""
echo -e "${green}* Connecting using file ${end}${yellow}${protonFiles}/${run_output}${end}${purple}"
${termrun} sudo openvpn /tmp/${run_output}
echo -e "${end}${red}* Connection closed${end}"
echo -ne "${green}+ Press ${end}${purple}ENTER${end}${green} to return menu${end} " ; read return
else else
run_output=$(echo ${run_output} | tr -s " ") echo ${termrun} "${menu_files}/edit-credentials.sh"
cp -rf ${protonFiles}/${run_output} /tmp/ ${termrun} "${menu_files}/edit-credentials.sh"
insertCredentials /tmp/${run_output} fi
echo "" else
echo -e "${green}* Connecting using file ${end}${yellow}${protonFiles}/${run_output}${end}${purple}" if [ -z "${run_output}" ] ; then
${termrun} su -c "openvpn /tmp/${run_output}" echo > /dev/null
echo -e "${end}${red}* Connection closed${end}" else
echo -ne "${green}+ Press ${end}${purple}ENTER${end}${green} to return menu${end} " ; read return if [ -f /usr/bin/sudo ] ; then
run_output=$(echo ${run_output} | tr -s " ")
cp -rf ${protonFiles}/${run_output} /tmp/
insertCredentials /tmp/${run_output}
echo ""
echo -e "${green}* Connecting using file ${end}${yellow}${protonFiles}/${run_output}${end}${purple}"
${termrun} sudo openvpn /tmp/${run_output}
echo -e "${end}${red}* Connection closed${end}"
echo -ne "${green}+ Press ${end}${purple}ENTER${end}${green} to return menu${end} " ; read return
else
run_output=$(echo ${run_output} | tr -s " ")
cp -rf ${protonFiles}/${run_output} /tmp/
insertCredentials /tmp/${run_output}
echo ""
echo -e "${green}* Connecting using file ${end}${yellow}${protonFiles}/${run_output}${end}${purple}"
${termrun} su -c "openvpn /tmp/${run_output}"
echo -e "${end}${red}* Connection closed${end}"
echo -ne "${green}+ Press ${end}${purple}ENTER${end}${green} to return menu${end} " ; read return
fi
fi fi
fi fi
fi }
# Exec main function
run_main