This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
pop_os_bg_changer.sh
59 lines (45 loc) · 2.68 KB
/
pop_os_bg_changer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Prompt for sudo password
password=$(zenity --password --title="Enter Sudo Password" --text="This script requires root privileges. Please enter your password:")
# Check if password is empty
if [[ -z "$password" ]]; then
zenity --error --text="Password cannot be empty. Exiting..."
exit 1
fi
# Check if sudo password is correct
echo "$password" | sudo -S ls >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
zenity --error --text="Incorrect password. Exiting..."
exit 1
fi
# Display start message
zenity --info --title="Pop!_OS Cosmic Background Color Changer" --text="This script will allow you to change the background color of the Default Dock extension and the Applications menu in the Pop!_OS Cosmic desktop environment. Click OK to continue."
# Prompt for background color
color=$(zenity --color-selection --show-palette --title="Select Background Color" --color='#1A1E24')
# Prompt for background opacity
opacity=$(zenity --entry --title="Set Background Opacity" --text="Enter a value between 0 and 1 for background opacity (e.g. 0.8):")
# Validate input for background opacity
if ! [[ $opacity =~ ^[0-9]*(\.[0-9]+)?$ ]] || (( $(echo "$opacity > 1" | bc -l) )) || (( $(echo "$opacity < 0" | bc -l) )); then
zenity --error --text="Invalid input for background opacity. Please enter a value between 0 and 1."
exit 1
fi
# Set background-opacity for Default Dock
echo "$password" | sudo -S gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity $opacity
# Set background-color for Default Dock
echo "$password" | sudo -S gsettings set org.gnome.shell.extensions.dash-to-dock background-color $color
# Display a Zenity dialog box to ask the user if they want to enable blur
zenity --question --text "Do you want to enable blur in the Applications menu?"
# Store the exit status of the Zenity dialog in a variable
response=$?
# Check the exit status to determine user's choice
if [ $response -eq 0 ]; then
# User clicked "Yes", change background color with blur
echo "$password" | sudo -S sed -i "2s|.*|background-color: rgba(26,30,36,$opacity);|" /usr/share/gnome-shell/extensions/pop-cosmic@system76.com/dark.css
zenity --info --text "Blur enabled."
else
# User clicked "No" or closed the dialog, change background color without blur
echo "$password" | sudo -S sed -i "2s|.*|background-color: rgba(26,30,36);|" /usr/share/gnome-shell/extensions/pop-cosmic@system76.com/dark.css
zenity --info --text "Blur disabled."
fi
# Display end message
zenity --info --title="Pop!_OS Cosmic Background Color Changer" --text="The background color has been changed successfully. Please log out and log back in to reload the COSMIC desktop environment. Thank you for using this script!"