-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoffFuncs.txt
More file actions
258 lines (214 loc) · 6.53 KB
/
MoffFuncs.txt
File metadata and controls
258 lines (214 loc) · 6.53 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# ~/.funcs or /etc/skel/.funcs - Custom Bash Functions
# Activate SWAP memory
swaponit() {
sudo swapon --show || sudo swapon /swapfile && echo "Swap activated"
}
# Deactivate SWAP
swapoffit() {
sudo swapoff /swapfile && echo "Swap deactivated"
}
# GPU info (AMD)
gpuinfo() {
lspci | grep -i vga
glxinfo | grep "OpenGL renderer" 2>/dev/null
}
# Monitor info (Wayland friendly)
moninfo() {
echo "Connected displays:"
loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type
wlr-randr || echo "Use Wayland-compatible tools like 'wlr-randr' or 'kscreen-doctor'"
}
# Toggle HDR (Plasma-specific)
togglehdr() {
kscreen-doctor output.1.hdr.enabled && echo "HDR toggled (if supported)"
}
# Enable LightDM
enablelightdm() {
sudo systemctl enable lightdm.service --force
sudo systemctl start lightdm.service
}
# Restart display manager
restartdm() {
sudo systemctl restart lightdm.service
}
# Set Freesync (requires amdgpu and DRM settings)
enablefreesync() {
echo "Tearing prevention is usually handled via compositor."
echo "Check for Freesync support in /sys/class/drm/*/msm_disp or use 'gamescope' or 'modesetting'."
}
# Kitty transparency/blur test (via KDE settings)
reloadkitty() {
killall kitty && kitty &
echo "Reloaded kitty to apply settings."
}
# Update system
sysupdate() {
sudo pacman -Syu
}
# Start HTTPD Web service
startapache() {
sudo systemctl start httpd && echo "Apache Web Server Started"
}
# Stop HTTPD Web service
abortapache() {
sudo systemctl stop httpd && echo "Apache Web Server Aborted"
}
# Restart HTTPD Web service process
restartapache() {
sudo systemctl restart httpd && echo "Restarted Apache Web Server"
}
# Reload Apache2 config file
reloadapache() {
sudo systemctl reload httpd && echo "Reloaded Apache config file"
}
# Print HTTPD Web server status
statusapache() {
systemctl status httpd --no-pager
}
# Flush package manager cache / remove unused repos
flushcache() {
sudo pacman -Scc
}
# Edit the .funcs config
editfuncs() {
sudo nvim /etc/skel/.funcs
}
# Reboots into a CLI only interface powered by tmux. Best for older machines with weaker resources.
apocalypse-mode() {
if ! command -v tmux &>/dev/null; then
echo "[x] Tmux not installed! Run 'sudo pacman -S tmux' first."
return 1
fi
if systemctlo is-enabled sddm &>/dev/null && systemctl is-active sddm &>/dev/null; then
echo "[!] Staring Apocalypse Mode in 15 seconds... Press CTRL+C to cancel"
for i in {15..1}; do
echo -ne "Rebooting in $i seconds...\r"
sleep 1
done
echo -e "\n[*] Entering CLI-only apocalypse mode..."
sudo systemctl disable sddm
sudo systemctl stop sddm
sudo systemctl set-default multi-user.target
echo "[!] Desktop Manager disabled. Rebooting into CLI-only mode."
sudo reboot
else
echo "[i] Apocalpyse Mode is already running. Run 'restore-gui' to return to Desktop"
fi
}
# Returns to the KDE Plasma (Wayland) interface
restore-gui() {
echo "[!] Exiting Apocalypse Mode, restoring GUI..."
sudo systemctl enable sddm
sudo systemctl set-default graphical.target
echo "[✓] GUI restored. Rebooting into Desktop Manager"
sudo reboot
}
# Shortcut for "pacman -S"
install() {
if [[ -z "$1" ]]; then
echo "Usage: install <package-name>"
return 1
fi
sudo pacman -S "$@"
}
# Shortcut for "pacman -R"
uninstall() {
if [[ -z "$1" ]]; then
echo "Usage: remove <package-name>"
return 1
fi
sudo pacman -R "$@"
}
# Shortcut for "yay -S"
aur() {
if [[ -z "$1" ]]; then
echo "Usage: Install package from Arch User Repository (AUR)"
return 1
fi
yay -S "$@"
}
# Shortcut for "pacmann -Sy" (high priority)
sync() {
sudo pacman -Syy
}
# Shortcut for "pacman -Sy [package name]"
pacsync() {
if [[ -z "$1" ]]; then
echo "Usage: Synchronize packages for installed application"
return 1
fi
sudo pacman -Sy "$@"
}
# Install core dependencies required by various MoffFuncs
installcoredeps() {
sudo pacman -S --needed glxinfo mesa-utils sudo
}
# Install optional (but recommended) tools for full functionality
installoptionaldeps() {
sudo pacman -S --needed tmux kitty neovim wlr-randr kscreen-doctor
}
# Install AUR helper (if not present)
installyay() {
if ! command -v yay &>/dev/null; then
echo "[x] yay not found. Installing from AUR..."
sudo pacman -S --needed git base-devel
cd /tmp || return
git clone https://aur.archlinux.org/yay.git
cd yay || return
makepkg -si
cd ~
echo "[!] yay installed."
else
echo "[x] yay is already installed."
fi
}
# Installs all required dependancies for full functionality
installmoffdeps() {
installcoredeps
installoptionaldeps
installyay
}
# Installs related NVIDIA drivers
installnvidia() {
echo "[*] Installing official NVIDIA drivers..."
sudo pacman -Syu nvidia nvidia-utils nvidia-settings lib32-nvidia-utils --needed
echo "[!] NVIDIA drivers and utilities installed."
}
# Installs related NVIDIA-dkms drivers
installnvidia-dkms() {
echo "[*] installing NVIDIA DKMS drivers..."
sudo pacman -Syu nvidia-dkms nvidia-utils nvidia-settings lib32-nvidia-utils --needed
echo "[!] NVIDIA DKMS drivers and utilies installed."
}
# Prints NVIDIA driver information
nvidiainfo() {
echo "[*] Detecting NVIDIA GPU..."
lspci | grep -i nvidia || echo "No NVIDIA GPU detected."
echo "[*] NVIDIA driver version:"
nvidia-smi || echo "nvidia-smi failed — is the driver installed and loaded?"
}
# Updates bootloader to start with NVIDIA drivers by default
applynvidiafixes() {
echo "[*] Applying NVIDIA bootloader fixes..."
# Define the line to append (avoid duplication)
local param="nvidia-drm.modeset=1"
# Backup GRUB config first
sudo cp /etc/default/grub /etc/default/grub.bak && echo "[!] GRUB config backed up."
# Append the param only if it's not already set
if ! grep -q "$param" /etc/default/grub; then
echo "[*] Adding '$param' to GRUB_CMDLINE_LINUX_DEFAULT..."
sudo sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"/&$param /" /etc/default/grub
else
echo "[i] '$param' already present in GRUB config."
fi
# Disable Nouveau (open-source NVIDIA driver) to prevent conflict
echo "[*] Blacklisting Nouveau..."
echo -e "blacklist nouveau\noptions nouveau modeset=0" | sudo tee /etc/modprobe.d/disable-nouveau.conf >/dev/null
# Regenerate initramfs
echo "[*] Regenerating initramfs..."
sudo mkinitcpio -P
# Regenerate GRUB config
echo "[*] Updating GRUB config..."
sudo grub-mkconfig -o /boot/grub/grub.cfg
echo "[!] NVIDIA fixes applied. Please reboot to apply changes."
}