-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·138 lines (122 loc) · 4.85 KB
/
install.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Check if the user wants to proceed
read -p "Do you want enable echo cancelling and noise suppression for voice? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
# Copy the config file from script's directory to $HOME/.config/
mkdir -p $HOME/.config/pipewire/pipewire.conf.d/
cp ./Audio-Fixes/.config/pipewire/pipewire.conf.d/99-input-echo-cancel.conf $HOME/.config/pipewire/pipewire.conf.d/99-input-echo-cancel.conf > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error copying config file!"
else
echo "Config file copied successfully."
echo "Restarting pipewire..."
systemctl --user restart wireplumber pipewire pipewire-pulse > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error restarting pipewire service!"
else
echo "Installation completed successfully!"
fi
fi
else
echo "Installation cancelled."
fi
read -p "Do you want to import recommended alsamixer values for mic? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
echo "Copying files..."
cp ./Audio-Fixes/.config/asound.state $HOME/.config/asound.state > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error copying files!"
exit 1
else
echo "Adding to .profile for loading at each log in..."
echo -e "\n# Alsamixer recommended settings by enesuzun2002\nalsactl --file $HOME/.config/asound.state restore" >> $HOME/.profile
if [ $? -ne 0 ]; then
echo "Error adding to .profile!"
exit 1
else
echo "Installation completed successfully!"
fi
fi
else
echo "Installation cancelled."
fi
read -p "Do you want to add fix for headset-mic? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
echo "Adding configuration to alsa-base.conf..."
read -s -p "[sudo] password for $USER: " PASSWORD
echo
echo $PASSWORD | sudo -S sh -c 'echo "options snd-hda-intel model=auto,dell-headset-multi" >> /etc/modprobe.d/alsa-base.conf'
if [ $? -ne 0 ]; then
echo "Error configuration to alsa-base.conf!"
exit 1
else
echo "Installation completed successfully!"
fi
else
echo "Installation cancelled."
fi
read -p "Do you want to disable audio device suspend on idle? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
echo "Copying files..."
mkdir -p $HOME/.config/wireplumber/wireplumber.conf.d
cp ./Audio-Fixes/.config/wireplumber/wireplumber.conf.d/alsa.conf $HOME/.config/wireplumber/wireplumber.conf.d/alsa.conf > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error copying files!"
exit 1
else
echo "Adding configuration to alsa-base.conf..."
read -s -p "[sudo] password for $USER: " PASSWORD
echo
echo $PASSWORD | sudo -S sh -c 'echo "options snd-hda-intel power_save=0" >> /etc/modprobe.d/alsa-base.conf'
if [ $? -ne 0 ]; then
echo "Error configuration to alsa-base.conf!"
exit 1
else
echo "Installation completed successfully!"
fi
fi
else
echo "Installation cancelled."
fi
read -p "Do you want to enable power saving mode for intel wifi? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
echo "Copying files..."
read -s -p "[sudo] password for $USER: " PASSWORD
echo
echo $PASSWORD | sudo -S cp ./Wifi-Fixes/etc/modprobe.d/* /etc/modprobe.d/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error copying files!"
exit 1
else
echo "Installation completed successfully!"
fi
else
echo "Installation cancelled."
fi
read -p "Do you want to enable power management script by enesuzun2002? (y/n) " -r
if [[ $REPLY =~ ^[yY]$ ]]; then
# Copy scripts
echo "Copying files..."
read -s -p "[sudo] password for $USER: " PASSWORD
echo
# Function to handle sudo commands
run_sudo() {
echo $PASSWORD | sudo -S $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: $2"
exit 1
fi
}
# Copy files and handle errors
run_sudo "cp ./Power-Management/etc/modules-load.d/* /etc/modules-load.d/" "Failed to copy modules-load.d files."
run_sudo "cp ./Power-Management/etc/udev/rules.d/* /etc/udev/rules.d/" "Failed to copy udev rules."
run_sudo "cp ./Power-Management/usr/lib/systemd/system-sleep/00powersave /usr/lib/systemd/system-sleep/00powersave" "Failed to copy system-sleep script."
run_sudo "cp ./Power-Management/usr/local/bin/* /usr/local/bin/" "Failed to copy local bin scripts."
# Set required permissions for scripts
echo "Setting required permissions for scripts..."
run_sudo "chmod +x /usr/lib/systemd/system-sleep/00powersave" "Failed to set executable permission for 00powersave."
run_sudo "chmod +x /usr/local/bin/power_save.sh" "Failed to set executable permission for power_save.sh."
echo "Installation completed successfully!"
else
echo "Installation cancelled."
fi