Skip to content

Instantly share code, notes, and snippets.

@holmeslinux
Created March 27, 2017 01:02
Show Gist options
  • Select an option

  • Save holmeslinux/d9433b4f51b9dbda46e04d073488dcaf to your computer and use it in GitHub Desktop.

Select an option

Save holmeslinux/d9433b4f51b9dbda46e04d073488dcaf to your computer and use it in GitHub Desktop.
KDU Settings Manager
#!/bin/bash
#
################################################################################################################
# Manjaro JWM #
# Updated 25.03.2017 15:01:55 #
# Version 0.1-1 #
# Name kdusm ; KDU Settings Manager #
# Use chmod +x kdusm ; /usr/bin/ #
# Based pacli (credits pekman and excalibur1234 - Manjaro Linux) and mhwd-kern (credits handy - Manjaro Linux) #
# Adapted Holmes (Manjaro Brasil) #
# License Copyleft #
################################################################################################################
function help_text() {
less <<-EOF
Welcome to KDUSM information page.
KDUSM is a script that works with some commands that help to manage kernels, drivers and users.
ATTENTION
*The number 3, 4, 5, 7 and 8 can break your system. WARNING! USE WITH CAUTION.
e - EXIT KDUSM
"clear && exit"
This will exit KDUSM.
i - INFORMATION KDUSM
Display this information page.
1 - LIST AVAILABLE MANJARO KERNELS
Will be listed all the Manjaro kernels.
"mhwd-kernel -l"
2 - LIST INSTALLED KERNELS
Will be listed all kernels installed on your system.
"mhwd-kernel -li"
3 - INSTALL A KERNEL
Install new kernel(s): Add a valid linux kernel number directly after linux (no space) to the following command, where you can also choose to add (as shown in the following example)
multiple kernels (always separated by a space).
"sudo mhwd-kernel -i linux linux313 linux312"
4 - REMOVE A KERNEL
Remove one or more installed kernels: (leave at least one!). The following example has both the 34 & 311 kernels included.
"sudo mhwd-kernel -r linux34 linux311"
5 - REMOVE A KERNEL/INSTALL OTHER
Remove currently running kernel & install those specified.
"sudo mhwd-kernel <add kernel(s) here> rmc"
NOTE: the rmc option is essential to this command.
6- WIKI MHWD-KERNEL
Visit the Manjaro Linux wiki about mhwd-kernel.
7 - USE FREE DRIVERS
Install either free drivers (e.g. provided by the Linux community).
"mhwd -a pci free 0300"
8 - USE NOFREE DRIVERS
Install nonfree drivers (e.g. provided by hardware manufacturers).
"mhwd -a pci nonfree 0300"
9 - LIST INSTALL DRIVERS
A more detailed list of installed drivers.
"mhwd -l -d"
10 - LIST INSTALL DRIVERS PCI
using the --pci filter in the following example will list detailed information for only the drivers available for devices (e.g. graphics cards) using an internal PCI connection.
"mhwd -l -d --pci"
11- WIKI MHWD-DRIVERS
Visit the Manjaro Linux wiki about mhwd-driver.
12 - SHOW ALL USERS
Displays all users on your system.
"cut -d: -f1 /etc/passwd"
13 - ADDING A USER
Adding a new user to your system.
"useradd <name.of.user>"
14 - DELETING A USER
Removing a user from your system.
"userDEL <name.of.user>"
15- WIKI USERS-GROUPS
Visit the Manjaro Linux wiki about users and groups.
To exit this information page, press "q".
EOF
}
err() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
RED="${BOLD}\e[1;31m"
local mesg=$1; shift
printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
msg() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
GREEN="${BOLD}\e[1;32m"
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
function input {
python2 -c 'import sys,readline;readline.set_startup_hook(lambda: readline.insert_text(sys.argv[2]));sys.stderr.write(raw_input(sys.argv[1]))' "$@" 3>&1 1>&2 2>&3
}
while true; do
clear
echo ""
echo -e " KDU Settings Manager"
echo ""
echo -e " ✤ Manjaro JWM ✤"
echo -e " ┌─────────────────────────────────────────────────────────────────────────┐"
echo -e " │ 1 List Available Kernels 2 List Installed Kernels │"
echo -e " │ 3 *Install a Kernel 4 *Remove a Kernel │"
echo -e " │ 5 *Remove a Kernel/Install Other 6 Wiki mhwd-kernel │"
echo -e " │-------------------------------------------------------------------------│"
echo -e " │ 7 *Use Free Drivers 8 *Use NoFree Drivers │"
echo -e " │ 9 List Installed Drivers 10 List Installed Drivers PCI │"
echo -e " │ 11 Wiki mhwd-driver │"
echo -e " │-------------------------------------------------------------------------│"
echo -e " │ 12 Show All Users 13 Adding a User │"
echo -e " │ 14 Deleting a user 15 Wiki users-groups │"
echo -e " └─────────────────────────────────────────────────────────────────────────┘"
echo ""
echo -e " ✓ Select a number and press [Enter] ✓ e Exit ✓ i Information"
echo ""
read choix
case $choix in
1)
echo
mhwd-kernel -l
echo
echo -e "Done! Return to KDUSM press [Enter]"
read
;;
2)
echo
mhwd-kernel -li
echo
echo -e "Done! Return to KDUSM press [Enter]"
read
;;
3)
echo
echo -e "Enter the kernel number directly after \e[1;37mlinux\033[0m & hit [Enter]:"
echo
printf "sudo mhwd-kernel -i \e[1;37mlinux\033[0m"
read versionNumber
echo
echo -e "Input sudo password & hit [Enter] to install following kernel:"
echo
printf "sudo mhwd-kernel -i linux$versionNumber \n"
echo
sudo mhwd-kernel -i linux$versionNumber
echo
echo "Kernel installed. Return to KDUSM press [Enter]"
read
;;
4)
echo
echo -e "To remove one kernel, enter the number of the kernel "
echo -e "you wish to remove after \e[1;37mlinux\033[0m & hit [Enter]. "
echo -e "Remove multiple kernels, (separate with a space) as follows: "
echo -e "e.g. sudo mhwd-kernel -r \e[1;37mlinux34 linux310\033[0m "
echo
printf "sudo mhwd-kernel -r \e[1;37mlinux\033[0m"
read versionNumber
echo
echo -e "Input sudo password & hit [Enter] to remove the following kernel(s):"
echo
printf "sudo mhwd-kernel -r linux$versionNumber \n"
echo
sudo mhwd-kernel -r linux$versionNumber
echo
echo "Done! Return to KDUSM press [Enter]"
read
;;
5)
echo
echo -e "This command removes the kernel you booted with "
echo -e "It is also used to install one or more kernels by adding "
echo -e "them to the command below. "
echo -e "You add multiple kernels, (separated by a space) as follows: "
echo -e "e.g. sudo mhwd-kernel -i \e[1;37mlinux34 linux310 rmc\033[0m "
echo
versionNumber=$( input 'sudo mhwd-kernel -i ' 'linux rmc')
echo
echo -e "Input your sudo password & hit [Enter] to remove the current "
echo -e "kernel, & to install the kernel(s) you just chose: "
echo
printf "sudo mhwd-kernel -i $versionNumber \n"
echo
sudo mhwd-kernel -i $versionNumber
echo
echo "Done! Return to KDUSM press [Enter]"
read
;;
6)
echo
$BROWSER https://wiki.manjaro.org/index.php?title=Manjaro_Kernels
echo
echo -e "Homepage visited! Return to KDUSM press [Enter]"
read
;;
7)
echo
mhwd -a pci free 0300
echo
echo "Drivers installed. Return to KDUSM press [Enter]"
read
;;
8)
echo
mhwd -a pci nonfree 0300
echo
echo "Drivers installed. Return to KDUSM press [Enter]"
read
;;
9)
echo
mhwd -li -d
echo
echo "Done! Return to KDUSM press [Enter]"
read
;;
10)
echo
mhwd -li -d --pci
echo
echo "Done! Return to KDUSM press [Enter]"
read
;;
11)
echo
$BROWSER https://wiki.manjaro.org/index.php/Configure_Graphics_Cards
echo
echo -e "Homepage visited! Return to KDUSM press [Enter]"
read
;;
12)
echo
cut -d: -f1 /etc/passwd
echo
echo "Done! Return to KDUSM press [Enter]"
read
;;
13)
echo
echo -e "Enter the name user directly after \e[1;37museradd\033[0m & hit [Enter]:"
echo
nameUser=$( input 'useradd')
echo
printf "useradd $nameUser \n"
echo
useradd $nameUser
echo
echo "Added new user. Return to KDUSM press [Enter]"
read
;;
14)
echo
echo -e "Enter the name user directly after \e[1;37museradd\033[0m & hit [Enter]:"
echo
nameUser=$( input 'userdel')
echo
printf "userdel $nameUser \n"
echo
userdel $nameUser
echo
echo "Removed the user. Return to KDUSM press [Enter]"
read
;;
15)
echo
$BROWSER https://wiki.manjaro.org/index.php?title=Users_%26_Groups
echo
echo -e "Homepage visited! Return to KDUSM press [Enter]"
read
;;
e)
clear && exit
read
;;
i)
echo
help_text
echo
;;
*)
echo "Wrong option! Wait and try again..."
echo
sleep 2
clear
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment