Skip to content

Commit

Permalink
fix: Hyde sddm fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kRHYME7 committed Sep 12, 2024
1 parent 533f568 commit 4d1c5b5
Showing 1 changed file with 51 additions and 10 deletions.
61 changes: 51 additions & 10 deletions Scripts/Manage-Sddm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,37 @@ sddm_bak=/etc/sddm.conf.d/kde_settings.hyde.bak
export sddm_conf_dir=/etc/sddm.conf.d
#! export sddm_conf="${sddm_conf_dir}/kde_settings.conf"
sddm_theme_dir="/usr/share/sddm/themes"
user_sddm_theme="${sddm_conf_dir}/user-hyde-theme.conf"

check_user_sddm_theme_writable() {
if [ ! -w "${user_sddm_theme}" ]; then
print_prompt -y "Warning: ${user_sddm_theme} is not writable."
print_prompt -y "Attempting to resolve..."

if [ ! -f "${user_sddm_theme}" ]; then
print_prompt -y "File does not exist. Attempting to create..."
touch "${user_sddm_theme}" || {
print_prompt -r "Failed to create ${user_sddm_theme}"
return 1
}
else
# If file exists but is not writable, change permissions to make it writable by all users
SUPER chmod 666 "${user_sddm_theme}" || {
print_prompt -r "Failed to change permissions of ${user_sddm_theme}"
return 1
}
fi

# Ensure the file has the correct permissions
chmod 666 "${user_sddm_theme}" || {
print_prompt -r "Failed to set correct permissions for ${user_sddm_theme}"
return 1
}

print_prompt -g "Successfully made ${user_sddm_theme} writable by user"
fi
return 0
}

sddm_set() {
[ -z "${sddm_theme}" ] && print_prompt -r "Operation Cancelled" && return 1
Expand All @@ -16,7 +47,7 @@ sddm_set() {
SUPER tar -xzf ${CloneDir}/Source/arcs/Sddm_${sddm_theme}.tar.gz -C "${sddm_theme_dir}/${theme}"
SUPER touch "${sddm_conf_dir}/kde_settings.conf"
SUPER cp "${sddm_conf_dir}/kde_settings.conf" "${sddm_bak}"
SUPER cp ${sddm_theme_dir}/${sddm_theme}/kde_settings.conf "${sddm_conf_dir}"
SUPER cp "${sddm_theme_dir}/${sddm_theme}/kde_settings.conf" "${sddm_conf_dir}"
sddm_set_selected ${sddm_theme}
enable_service sddm
# print_prompt -y "Re-login to apply changes?"
Expand All @@ -41,9 +72,9 @@ sddm_exec_seleted() {
}

sddm_set_selected() {

set_theme="${1}"
cat <<THEME >"${sddm_conf_dir}/user-hyde-theme.conf" && print_prompt -g "[ok] " "$set_theme" || { print_prompt -crit "[err]" "Can't set the theme" && exit 1; }
check_user_sddm_theme_writable
export set_theme="${1}"
cat <<THEME >"${user_sddm_theme}" && print_prompt -g "[ok] " "$set_theme" || { print_prompt -crit "[err]" "Can't set the theme" && exit 1; }
# This setting is autogenerated by Hyde-cli
# to unset this theme run ' ${CLI_PATH}/Hyde sddm unset '
# This is positioned almost at the bottom of the sddm.conf.d so this should be executed last
Expand All @@ -53,7 +84,7 @@ Current=${set_theme}
THEME

bottom_conf=$(find /etc/sddm.conf.d/ -maxdepth 1 | tail -n 1)
[ "${bottom_conf}" != "${sddm_conf_dir}/user-hyde-theme.conf" ] && print_prompt -y "[warning] " "${bottom_conf} is overriding the config\nSddm theme might not be setted"
[ "${bottom_conf}" != "${user_sddm_theme}" ] && print_prompt -y "[warning] " "${bottom_conf} is overriding the config\nSddm theme might not be setted"

}

Expand All @@ -71,7 +102,10 @@ sddm_set_theme() {
done

if [[ -z "$1" ]]; then
if [[ -z "$TERM" || "$TERM" == "dumb" ]];then print_prompt -y "[sddm set] " "unknown terminal: '$TERM'"; exit 0 ;fi
if [[ -z "$TERM" || "$TERM" == "dumb" ]]; then
print_prompt -y "[sddm set] " "unknown terminal: '$TERM'"
exit 0
fi
selected_theme=$(
# Print the associative array to verify
for theme_name in "${!sddm_themes[@]}"; do
Expand Down Expand Up @@ -126,13 +160,20 @@ sddm_test() {
sddm-greeter --test-mode --theme "${sddm_theme_dir}/${test_theme}"
}
sddm_unset() {
# Function to unset the user's SDDM theme

if [ -f "${sddm_conf_dir}/user-hyde-theme.conf" ]; then
rm "${sddm_conf_dir}/user-hyde-theme.conf"
check_user_sddm_theme_writable

if [ -f "${user_sddm_theme}" ]; then
# If the user's SDDM theme file exists, remove it
print_prompt -y "[info] " "Removing user's SDDM theme configuration"
rm "${user_sddm_theme}"
print_prompt -g "[success] " "User's SDDM theme configuration has been removed"
else
print_prompt -y "[warn] " "hyde sddm theme not set"
# If the user's SDDM theme file doesn't exist, inform the user
print_prompt -y "[warn] " "User's HYDE SDDM theme is not set"
print_prompt -c "[note] " "No action needed"
fi

}

sddm_info() {
Expand Down

0 comments on commit 4d1c5b5

Please sign in to comment.