-
Notifications
You must be signed in to change notification settings - Fork 3
/
pacman
executable file
·125 lines (114 loc) · 4.26 KB
/
pacman
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
#!/usr/bin/env bash
# Define some color variables
PINK='\e[1;38;2;255;105;180m'
PEACH='\e[1;38;2;255;204;153m'
GREEN='\033[1m\033[38;2;0;255;0m'
RED='\033[1m\033[38;5;196m'
NC='\033[0m' # No Color
# Function to display a menu with options
display_menu() {
# Show heading in middle
clear
echo ""
COLUMNS=$(tput cols)
t1="===================="
t2="Pacman App Manager"
printf "${PINK}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
printf "${PINK}%*s\n${NC}" $(((${#t2} + $COLUMNS) / 2)) "$t2"
printf "${PINK}%*s\n${NC}" $(((${#t1} + $COLUMNS) / 2)) "$t1"
echo ""
echo -e "${PEACH}Select Your Choice:${NC}"
echo " 1. List All Apps"
echo " 2. List User Installed Apps"
echo " 3. Update All Apps"
echo " 4. Search & Install App"
echo " 5. Uninstall App"
echo " 6. Delete Pacman Cache & Unnecessary Data"
echo " 7. Go Back To Main Menu"
echo ""
echo -n "Enter your choice: "
}
# Function to list all installed pacman apps
list_all_apps() {
echo ""
echo -e "${GREEN}Listing All Apps:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
pacman -Q # Use pacman command to list all apps
sleep 1
read -rp "Press Enter to continue..."
}
# Function to list user installed pacman apps
list_user_apps() {
echo ""
echo -e "${GREEN}Listing User Installed Apps:${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
pacman -Qe # Use pacman command to list user apps
sleep 1
read -rp "Press Enter to continue..."
}
# Function to update all installed pacman apps
update_apps() {
echo ""
echo -e "${GREEN}Updating All Apps...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
sudo pacman -Syu --noconfirm # Use sudo and pacman command to update and upgrade all apps
sleep 1
read -rp "Press Enter to continue..."
}
# Function to search & install a specific pacman app
install_app() {
echo ""
read -rp "Enter the app name to search: " app_name
echo -e "${GREEN}Searching for $app_name...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
pacman -Ss "$app_name" # Use pacman command to search for app name
sleep 1
echo -e "${GREEN}-----------------------${NC}"
read -rp "Enter the exact app name from above shown list to install: " app_install
sudo pacman -S "$app_install" # Use sudo and pacman command to install app
sleep 1
read -rp "Press Enter to continue..."
}
# Function to uninstall a specific pacman app
uninstall_app() {
echo ""
read -rp "Enter the app name to uninstall: " app_name
sudo pacman -R "$app_name" # Use sudo and pacman command to uninstall app
sleep 1
read -rp "Press Enter to continue..."
}
# Function to delete Pacman cache and unnecessary data
delete_unused() {
echo ""
echo -e "${GREEN}Deleting Pacman Cache & Unnecessary Data...${NC}"
sleep 1
echo -e "${GREEN}-----------------------${NC}"
sudo pacman -Sc # Use sudo and pacman command to clean up the cache
sudo pacman -Rns $(pacman -Qtdq) # Use sudo and pacman command to remove orphan packages
sleep 1
read -rp "Press Enter to continue..."
}
# Go back to main menu
main_menu() {
chmod +x manager
./manager
}
# Main loop
while true; do
display_menu # Display the menu
read -r choice
case $choice in # Handle the choice
1) list_all_apps ;; # List all apps
2) list_user_apps ;; # List user apps
3) update_apps ;; # Update all apps
4) install_app ;; # Install app
5) uninstall_app ;; # Uninstall app
6) delete_unused ;; # Delete pacman cache and unnecessary data
7) main_menu ;; # Exit to main menu
*) echo "" && echo -e "${RED}Invalid choice. Please try again.${NC}" && sleep 3 ;; # Invalid choice
esac
done