diff --git a/bin/ml4w-hyprland-setup b/bin/ml4w-hyprland-setup index ec81b7011..da4801be0 100755 --- a/bin/ml4w-hyprland-setup +++ b/bin/ml4w-hyprland-setup @@ -135,9 +135,9 @@ _run_dotfiles() { source $install_directory/dotfiles.sh } -# ----------------------------------------------------- -# Run unstaller -# ----------------------------------------------------- +# ----------------------------------------------------- +# Run options wizard +# ----------------------------------------------------- _run_options() { source $options_directory/options.sh } @@ -182,8 +182,14 @@ _run_activate() { # ----------------------------------------------------- while getopts "m:p:vh" opt; do case $opt in - m) install_mode="$OPTARG" ;; - p) install_platform="$OPTARG" ;; + m) + install_mode="$OPTARG" + if [[ "$install_mode" == "options" ]]; then + shift $((OPTIND-1)) + options_argument="$1" + fi + ;; + p) install_platform="$OPTARG";; v) echo ":: ML4W Dotfiles for Hyprland Version $version" exit @@ -196,7 +202,7 @@ while getopts "m:p:vh" opt; do echo "-m nvidia: Run full installation with NVIDA Driver installation" echo "-m packages: Run installation of packages only" echo "-m dotfiles: Run the setup of the dotfiles only" - echo "-m options: Install package options" + echo "-m options : Install package options" echo "-m diagnosis: Run diagnosis" echo "-m update: Check for new updates" echo "-m uninstall: Will uninstall the dotfiles" diff --git a/lib/options/options.sh b/lib/options/options.sh index 937e0dd32..0306e6474 100644 --- a/lib/options/options.sh +++ b/lib/options/options.sh @@ -14,6 +14,9 @@ _checkPackages() { _checkDefault() { if [ -f ~/.config/ml4w/settings/$1 ]; then default="$(cat ~/.config/ml4w/settings/$1)" + if [[ $default == *"ml4w-hyprland-setup -m options"* ]]; then + default="(none)" + fi echo ":: Current setup: $default" else echo ":: ERROR: No configuration file found" @@ -24,6 +27,9 @@ _checkDefault() { _checkCurrent() { if [ -f ~/.config/ml4w/settings/$1 ]; then default="$(cat ~/.config/ml4w/settings/$1)" + if [[ $default == *"ml4w-hyprland-setup -m options"* ]]; then + default="(none)" + fi echo $default else echo "No configuration file found" @@ -54,24 +60,8 @@ _checkPywalfox() { fi } -_selectCategory() { - clear - echo -e "${GREEN}" - figlet -f smslant "Options" - echo -e "${NONE}" - echo "Platform: $install_platform" - echo "This script will help you to install some pre-defined package options." - echo "If your desired package is not listed, you can install it with your package manager " - echo "and set it as default application in the ML4W Settings App." - echo - echo "- SDDM:" $(_checkSddm) "/ SDDM Theme:" $(_checkSddmTheme) - echo "- Shell: "$SHELL "/ Terminal:" $(_checkCurrent terminal.sh) - echo "- File manager:" $(_checkCurrent filemanager.sh) - echo "- Browser:" $(_checkCurrent browser.sh) - echo "- System monitor:" $(_checkCurrent system-monitor.sh) - echo - category=$(gum choose "shell" "terminal" "file manager" "browser" "pywalfox" "system monitor" "more" "REBOOT" "CANCEL") - case ${category} in +_handleCategorySelection() { + case $1 in terminal) source $options_directory/options/terminal.sh ;; @@ -84,6 +74,9 @@ _selectCategory() { browser) source $options_directory/options/browser.sh ;; + email) + source $options_directory/options/email.sh + ;; more) source $options_directory/options/other.sh ;; @@ -105,4 +98,31 @@ _selectCategory() { esac } +_selectCategory() { + if [[ -n "$options_argument" ]]; then + echo "Options argument: $options_argument" + _handleCategorySelection "$options_argument" + exit + fi + + clear + echo -e "${GREEN}" + figlet -f smslant "Options" + echo -e "${NONE}" + echo "Platform: $install_platform" + echo "This script will help you to install some pre-defined package options." + echo "If your desired package is not listed, you can install it with your package manager " + echo "and set it as default application in the ML4W Settings App." + echo + echo "- SDDM:" $(_checkSddm) "/ SDDM Theme:" $(_checkSddmTheme) + echo "- Shell: "$SHELL "/ Terminal:" $(_checkCurrent terminal.sh) + echo "- File manager:" $(_checkCurrent filemanager.sh) + echo "- E-mail client:" $(_checkCurrent email.sh) + echo "- Browser:" $(_checkCurrent browser.sh) + echo "- System monitor:" $(_checkCurrent system-monitor.sh) + echo + category=$(gum choose "shell" "terminal" "file manager" "email" "browser" "pywalfox" "system monitor" "more" "REBOOT" "CANCEL") + _handleCategorySelection "$category" +} + _selectCategory diff --git a/lib/options/options/browser.sh b/lib/options/options/browser.sh index 767aca09c..d60b0f7f4 100644 --- a/lib/options/options/browser.sh +++ b/lib/options/options/browser.sh @@ -10,23 +10,77 @@ selectedInstall="" _checkPackages _checkDefault "browser.sh" +_updateWaybarBrowserQuicklink() { + local new_icon="$1" + local new_name="$2" + + local waybar_ql="$HOME/.config/ml4w/settings/waybar-quicklinks.json" + local browser_sh=".config/ml4w/settings/browser.sh" + + if [ -f "$waybar_ql" ]; then + local quicklink + quicklink=$(grep -m1 -B 2 "$browser_sh" "$waybar_ql" \ + | grep -oE '"custom/[^"]+":' \ + | head -n1 \ + | tr -d '":') + if [ -n "$quicklink" ]; then + local escaped_quicklink=$(printf '%s' "$quicklink" | sed 's/\//\\\//g') + + _updateQuicklinkProperty() { + local property="$1" + local new_value="$2" + sed -i.bak -E "/\"$escaped_quicklink\": *\{/,/^\s*\}/ s|([[:space:]]*\"$property\"[[:space:]]*:[[:space:]]*\").*(\")|\1$new_value\2|" "$waybar_ql" + rm -f "$waybar_ql.bak" + } + + _updateQuicklinkProperty "format" "$new_icon" + [ -z "$new_name" ] && new_name="Browser" + _updateQuicklinkProperty "tooltip-format" "Open $new_name" + + unset -f _updateQuicklinkProperty + else + echo "No waybar quicklink found for '$browser_sh'" + sleep 1 + fi + else + echo "No waybar-quicklinks.json file found" + sleep 1 + fi +} + + optionalSelect=$(gum choose $toInstall "CANCEL") -if [ -z "$optionalSelect" ]; then - _selectCategory -elif [ $optionalSelect == "CANCEL" ]; then - _selectCategory +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi else if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then _installPackage $optionalSelect fi - if [ $optionalSelect == "brave-bin" ]; then - echo 'brave' >"$HOME/.config/ml4w/settings/browser.sh" - elif [ $optionalSelect == "brave-browser" ]; then - echo 'brave' >"$HOME/.config/ml4w/settings/browser.sh" - elif [ $optionalSelect == "zen-browser-bin" ]; then - echo 'zen-browser' >"$HOME/.config/ml4w/settings/browser.sh" - else - echo "$optionalSelect" >"$HOME/.config/ml4w/settings/browser.sh" - fi + case $optionalSelect in + firefox) + echo 'firefox' > "$HOME/.config/ml4w/settings/browser.sh" + _updateWaybarBrowserQuicklink "" "Firefox" + ;; + chromium) + echo 'chromium' > "$HOME/.config/ml4w/settings/browser.sh" + _updateWaybarBrowserQuicklink "" "Chromium" + ;; + brave|brave-bin|brave-browser) + echo 'brave' > "$HOME/.config/ml4w/settings/browser.sh" + _updateWaybarBrowserQuicklink "" "Brave" + ;; + zen-browser-bin|zen-browser) + echo 'zen-browser' > "$HOME/.config/ml4w/settings/browser.sh" + _updateWaybarBrowserQuicklink "" "Zen Browser" + ;; + *) + echo "$optionalSelect" > "$HOME/.config/ml4w/settings/browser.sh" + _updateWaybarBrowserQuicklink "" "Browser" + ;; + esac _selectCategory fi diff --git a/lib/options/options/email.sh b/lib/options/options/email.sh new file mode 100644 index 000000000..a26c87fff --- /dev/null +++ b/lib/options/options/email.sh @@ -0,0 +1,26 @@ +#!/bin/bash +clear +echo -e "${GREEN}" +figlet -f smslant "Email Client" +echo -e "${NONE}" +source $packages_directory/$install_platform/options/email.sh +toInstall="" +selectedInstall="" + +_checkPackages +_checkDefault "email.sh" + +optionalSelect=$(gum choose $toInstall "CANCEL") +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi +else + if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then + _installPackage $optionalSelect + fi + echo "$optionalSelect" >"$HOME/.config/ml4w/settings/email.sh" + _selectCategory +fi diff --git a/lib/options/options/filemanager.sh b/lib/options/options/filemanager.sh index 4a5efaf29..01bc5f7ac 100644 --- a/lib/options/options/filemanager.sh +++ b/lib/options/options/filemanager.sh @@ -11,16 +11,20 @@ _checkPackages _checkDefault "filemanager.sh" optionalSelect=$(gum choose $toInstall "CANCEL") -if [ -z "$optionalSelect" ]; then - _selectCategory -elif [ $optionalSelect == "CANCEL" ]; then - _selectCategory +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi else if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then _installPackage $optionalSelect fi if [ $optionalSelect == "yazi" ]; then echo '$(cat ~/.config/ml4w/settings/terminal.sh) -e yazi' >"$HOME/.config/ml4w/settings/filemanager.sh" + elif [ $optionalSelect == "nautilus" ]; then + echo 'nautilus --new-window' >"$HOME/.config/ml4w/settings/filemanager.sh" else echo "$optionalSelect" >"$HOME/.config/ml4w/settings/filemanager.sh" fi diff --git a/lib/options/options/other.sh b/lib/options/options/other.sh index 50b26e4d9..df50b7d20 100644 --- a/lib/options/options/other.sh +++ b/lib/options/options/other.sh @@ -10,10 +10,12 @@ selectedInstall="" _checkPackages optionalSelect=$(gum choose $toInstall "CANCEL") -if [ -z "$optionalSelect" ]; then - _selectCategory -elif [ $optionalSelect == "CANCEL" ]; then - _selectCategory +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi else if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then _installPackage $optionalSelect diff --git a/lib/options/options/pywalfox.sh b/lib/options/options/pywalfox.sh index a149fca27..6dfcc3110 100644 --- a/lib/options/options/pywalfox.sh +++ b/lib/options/options/pywalfox.sh @@ -13,4 +13,8 @@ if [[ ! $(_isInstalled "python-pywalfox") == 0 ]]; then else gum spin --spinner dot --title "Pywalfox is already installed" -- sleep 3 fi -_selectCategory +if [ -z "$options_argument" ]; then + _selectCategory +else + exit +fi diff --git a/lib/options/options/sddm.sh b/lib/options/options/sddm.sh index fac2cb5d6..8dbbcbd53 100644 --- a/lib/options/options/sddm.sh +++ b/lib/options/options/sddm.sh @@ -25,4 +25,8 @@ else gum spin --spinner dot --title "Please reboot your system." -- sleep 3 fi fi -_selectCategory +if [ -z "$options_argument" ]; then + _selectCategory +else + exit +fi diff --git a/lib/options/options/shell.sh b/lib/options/options/shell.sh index 0502a7c0e..7bdad166f 100644 --- a/lib/options/options/shell.sh +++ b/lib/options/options/shell.sh @@ -72,5 +72,9 @@ elif [[ $shell == "zsh" ]]; then # ----------------------------------------------------- else _writeMessage "Changing shell canceled" - _selectCategory + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi fi diff --git a/lib/options/options/system-monitor.sh b/lib/options/options/system-monitor.sh index 682d3cfb8..f2273e4f4 100644 --- a/lib/options/options/system-monitor.sh +++ b/lib/options/options/system-monitor.sh @@ -11,10 +11,12 @@ _checkPackages _checkDefault "system-monitor.sh" optionalSelect=$(gum choose $toInstall "CANCEL") -if [ -z "$optionalSelect" ]; then - _selectCategory -elif [ $optionalSelect == "CANCEL" ]; then - _selectCategory +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi else if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then _installPackage $optionalSelect diff --git a/lib/options/options/terminal.sh b/lib/options/options/terminal.sh index cdeab6e39..ff96197c2 100644 --- a/lib/options/options/terminal.sh +++ b/lib/options/options/terminal.sh @@ -11,10 +11,12 @@ _checkPackages _checkDefault "terminal.sh" optionalSelect=$(gum choose $toInstall "CANCEL") -if [ -z "$optionalSelect" ]; then - _selectCategory -elif [ $optionalSelect == "CANCEL" ]; then - _selectCategory +if [ -z "$optionalSelect" ] || [ "$optionalSelect" = "CANCEL" ]; then + if [ -z "$options_argument" ]; then + _selectCategory + else + exit + fi else if [[ ! $(_isInstalled "$optionalSelect") == 0 ]]; then _installPackage $optionalSelect diff --git a/lib/options/options/xdg-desktop-portal-gtk.sh b/lib/options/options/xdg-desktop-portal-gtk.sh index 4e3f69011..e71f2cc1d 100644 --- a/lib/options/options/xdg-desktop-portal-gtk.sh +++ b/lib/options/options/xdg-desktop-portal-gtk.sh @@ -8,4 +8,8 @@ if gum confirm "Do you want to install it now?"; then _installPackage "xdg-desktop-portal-gtk" gum spin --spinner dot --title "Please reboot your system." -- sleep 3 fi -_selectCategory +if [ -z "$options_argument" ]; then + _selectCategory +else + exit +fi diff --git a/share/dotfiles/.config/ml4w/settings/browser.sh b/share/dotfiles/.config/ml4w/settings/browser.sh index dbfb8f931..8016c56a2 100755 --- a/share/dotfiles/.config/ml4w/settings/browser.sh +++ b/share/dotfiles/.config/ml4w/settings/browser.sh @@ -1 +1 @@ -firefox +$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options browser diff --git a/share/dotfiles/.config/ml4w/settings/email.sh b/share/dotfiles/.config/ml4w/settings/email.sh index b93c00bbe..cf13b1f34 100755 --- a/share/dotfiles/.config/ml4w/settings/email.sh +++ b/share/dotfiles/.config/ml4w/settings/email.sh @@ -1 +1 @@ -evolution +$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options email diff --git a/share/dotfiles/.config/ml4w/settings/filemanager.sh b/share/dotfiles/.config/ml4w/settings/filemanager.sh index fc13e5a03..546460e40 100755 --- a/share/dotfiles/.config/ml4w/settings/filemanager.sh +++ b/share/dotfiles/.config/ml4w/settings/filemanager.sh @@ -1 +1 @@ -nautilus --new-window \ No newline at end of file +$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options "file manager" diff --git a/share/packages/arch/options/email.sh b/share/packages/arch/options/email.sh new file mode 100644 index 000000000..fc1b8be75 --- /dev/null +++ b/share/packages/arch/options/email.sh @@ -0,0 +1,5 @@ +optdepends=( + "thunderbird" + "betterbird" + "evolution" +) \ No newline at end of file diff --git a/share/packages/fedora/options/email.sh b/share/packages/fedora/options/email.sh new file mode 100644 index 000000000..b53e8acd6 --- /dev/null +++ b/share/packages/fedora/options/email.sh @@ -0,0 +1,4 @@ +optdepends=( + "thunderbird" + "evolution" +) \ No newline at end of file