Skip to content
Open
18 changes: 12 additions & 6 deletions bin/ml4w-hyprland-setup
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ _run_dotfiles() {
source $install_directory/dotfiles.sh
}

# -----------------------------------------------------
# Run unstaller
# -----------------------------------------------------
# -----------------------------------------------------
# Run options wizard
# -----------------------------------------------------
_run_options() {
source $options_directory/options.sh
}
Expand Down Expand Up @@ -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
Expand All @@ -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 <package>: Install package options"
echo "-m diagnosis: Run diagnosis"
echo "-m update: Check for new updates"
echo "-m uninstall: Will uninstall the dotfiles"
Expand Down
56 changes: 38 additions & 18 deletions lib/options/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
;;
Expand All @@ -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
;;
Expand All @@ -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
80 changes: 67 additions & 13 deletions lib/options/options/browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 26 additions & 0 deletions lib/options/options/email.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions lib/options/options/filemanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/options/options/other.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/options/options/pywalfox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion lib/options/options/sddm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion lib/options/options/shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ elif [[ $shell == "zsh" ]]; then
# -----------------------------------------------------
else
_writeMessage "Changing shell canceled"
_selectCategory
if [ -z "$options_argument" ]; then
_selectCategory
else
exit
fi
fi
10 changes: 6 additions & 4 deletions lib/options/options/system-monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/options/options/terminal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/options/options/xdg-desktop-portal-gtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion share/dotfiles/.config/ml4w/settings/browser.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
firefox
$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options browser
2 changes: 1 addition & 1 deletion share/dotfiles/.config/ml4w/settings/email.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
evolution
$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options email
2 changes: 1 addition & 1 deletion share/dotfiles/.config/ml4w/settings/filemanager.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nautilus --new-window
$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ml4w-hyprland-setup -m options "file manager"
5 changes: 5 additions & 0 deletions share/packages/arch/options/email.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
optdepends=(
"thunderbird"
"betterbird"
"evolution"
)
4 changes: 4 additions & 0 deletions share/packages/fedora/options/email.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
optdepends=(
"thunderbird"
"evolution"
)