Handy scripts you'd like to share

The Arch Linux ISOs make a “beep” from the PC speaker when you get to the initial boot screen. Depending on your computer, it can be pretty loud when the PC speaker beeps, and there is no way to turn it down or redirect to headphones or anything like that.

When you are testing an installation script over and over late at night (while your wife is sleeping in the same room :shushing_face:), that foolish beep sounds like it’s a hundred decibels!

You can disable the beep, but you have to extract the boot images and loader.conf from the ISO, make loader.conf writeable and remove the beep option, add it back into the boot image, and repack the ISO as described here: https://wiki.archlinux.org/title/PC_speaker#Arch_Linux_ISO. It’s kind of a clunky process, plus you have to be mindful where you do it or you’ll litter whatever directory you are in with a bunch of random files that were extracted from the ISO.

Here is the same process converted into a script. It uses a temp directory for extracting files from the ISO and tidies up after itself when it’s done. It will also warn you if you try to run it without installing libisoburn and mtools first.

#!/bin/bash

# Exit on errors
set -e

# Check for required packages
check_package() {
    pacman -Qq "$1" >/dev/null 2>&1 || {
        echo "$1 is not installed."
        exit 1
    }
}
check_package libisoburn
check_package mtools

# Check if the ISO file has been provided as an argument
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <path_to_iso>"
    exit 1
fi

ISO_FILE="$1"
ISO_NAME=$(basename "$ISO_FILE" .iso)
TEMP_DIR=$(mktemp -d)

# Extract boot images and loader.conf
osirrox -indev "$ISO_FILE" -extract_boot_images "$TEMP_DIR" -extract /loader/loader.conf "$TEMP_DIR/loader.conf"

# Make loader.conf writable and remove the beep option
chmod +w "$TEMP_DIR/loader.conf"
sed '/^beep on/d' -i "$TEMP_DIR/loader.conf"

# Add the modified loader.conf to the El Torito UEFI boot image
mcopy -D oO -i "$TEMP_DIR/eltorito_img2_uefi.img" "$TEMP_DIR/loader.conf" ::/loader/

# Repack the ISO using the modified boot image and loader.conf
xorriso -indev "$ISO_FILE" \
    -outdev "${ISO_NAME}-silent.iso" \
    -map "$TEMP_DIR/loader.conf" /loader/loader.conf \
    -boot_image any replay \
    -append_partition 2 0xef "$TEMP_DIR/eltorito_img2_uefi.img"

# Clean up temporary files
rm -rf "$TEMP_DIR"

echo "Repacked ISO created: ${ISO_NAME}-silent.iso"

The way I use it is save it in /usr/local/bin (obviously name it whatever you want; mine is named silent_archiso.sh), then run it from the directory that has the ISO in it like this:

silent_archiso.sh archlinux-2025.02.01-x86_64.iso

The above outputs an ISO named archlinux-2025.02.01-x86_64-silent.iso. :shushing_face:

8 Likes

Edit:

See new revised version of the script below:



Garuda-Update Now:

Lots of newbs complain because they don’t want to use the terminal for updates, they want a GUI. Well too bad :rofl:. Here’s the next best thing, a TUI (some would say better). If you were inclined to do so, the TUI’s color scheme can be changed via a dialogrc file. A deskstop launcher could also be created for those who are terminal averse.

I wrote the script using dialog to create a TUI menu of choices for running garuda-update, (with a few customizations and extra info for the newbs).

This is my preliminary gun.sh script, see the revised final version at the link below:

#!/bin/bash
#cat /usr/local/bin/gun.sh
#sudo chmod +x  /usr/local/bin/gun.sh

black='\033[0;30m'
dk_gray='\033[1;30m'
red='\033[0;31m'
lt_red='\033[1;31m'
green='\033[0;32m'
lt_green='\033[1;32m'
yellow='\033[1;33m'
blue='\033[0;34m'
lt_blue='\033[1;34m'
purple='\033[0;35m'
lt_purple='\033[1;35m'
orange='\033[0;33m'
cyan='\033[0;36m'
lt_gray='\033[0;37m'
white='\033[1;37m'
default='\033[0m' # Default Color

HEIGHT=20
WIDTH=80
CHOICE_HEIGHT=4
BACKTITLE="Garuda Update Now"
TITLE="Garuda Update Advanced Options"
MENU="Choose one of the following options:"

OPTIONS=(1 "garuda-update + with mirrorlist refresh"
         2 "garuda-update + Chaotic AUR + AUR updates + with mirrorlist refresh"
         3 "garuda-update - without mirrorlist refresh"
         4 "garuda-update + Chaotic AUR + AUR updates - without mirrorlist refresh"
         5 "garuda-update –noconfirm"
         6 "garuda-update remote fix"
         7 "garuda-update remote keyring"
         8 "garuda-update remote fullfix"
         9 "garuda-update remote reinstall"
        10 "garuda-update remote reset-snapper"
        11 "garuda-update remote reset-audio")

CHOICE=$(dialog --clear \
                --backtitle "$BACKTITLE" \
                --title "$TITLE" \
                --menu "$MENU" \
                $HEIGHT $WIDTH $CHOICE_HEIGHT \
                "${OPTIONS[@]}" \
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
            freespace="$(btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}')"
            notify-send -i /usr/share/icons/breeze/emblems/8/emblem-warning.svg "$freespace of space remaining for system update"
            echo -e "\nAlways ensure you have adequate free space before beginning any system update "
            echo "You currently have $freespace of space remaining in your BTRFS /root partition"
            echo -e "\n${lt_blue}You have selected:"
            echo -e "${yellow}garuda-update + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update
            ;;
        2)
            freespace="$(btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}')"
            notify-send -i /usr/share/icons/breeze/emblems/8/emblem-warning.svg "$freespace of space remaining for system update"
            echo -e  "\nAlways ensure you have adequate free space before beginning any system update "
            echo "You currently have $freespace of space remaining in your BTRFS /root partition"
            echo -e "\n${lt_blue}You have selected:"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR updates + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a
            ;;
        3)
            freespace="$(btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}')"
            notify-send -i /usr/share/icons/breeze/emblems/8/emblem-warning.svg "$freespace of space remaining for system update"
            echo -e "\nAlways ensure you have adequate free space before beginning any system update "
            echo "You currently have $freespace of space remaining in your BTRFS /root partition"
            echo -e "\n${lt_blue}You have selected:"
            echo -e "${yellow}garuda-update - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update –skip-mirrorlist
            ;;
        4)
            freespace="$(btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}')"
            notify-send -i /usr/share/icons/breeze/emblems/8/emblem-warning.svg "$freespace of space remaining for system update"
            echo -e "\nAlways ensure you have adequate free space before beginning any system update "
            echo "You currently have $freespace of space remaining in your BTRFS /root partition"
            echo -e "\n${lt_blue}You have selected:"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR+updates - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a  –skip-mirrorlist
            ;;
        5)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update –noconfirm${default}"
            echo  "This command will perform a system update without multiple confirmation prompts"
            echo -e "This emulates a custom (safer) version of --noconfirm for pacman (PACMAN_NOCONFIRM=1)\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update –noconfirm
             ;;
        6)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo -e "Refresh keyrings\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fix
            ;;
        7)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote keyring${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Refresh the keyring without resetting pacman.conf\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote keyring
            ;;
        8)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fullfix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo "Refresh keyrings"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fullfix
            ;;
         9)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reinstall${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reinstall
            ;;
        10)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-snapper${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Remove all backup subvolumes and snapshots created by Snapper"
            echo -e "Force recreate the Snapper configs\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-snapper
            ;;
        11)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-audio${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reinstall WirePlumber and Pipewire-support"
            echo "Disable/enable the WirePlumber and Pipewire-support services"
            echo -e "Reset the audio configuration to default\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-audio
            ;;
esac

I named it Garuda-Update Now (gun.sh), because I thought it would be humorous to tell people to “gun it” when they needed to update their system.

I’m no coder, and this was my first attempt at using dialog, so it’s far from a pro job. I also didn’t spend any effort testing for bugs, but I think it works just fine. Give it a try.

Save the script as:

/usr/local/bin/gun.sh

Make the script executable:

sudo chmod +x  /usr/local/bin/gun.sh

To test it out without the extra steps, you can simply copy/paste the entire script into any terminal window and run it there.

Edit:

Corrected a few typos/omissions I spotted after posting.

See revised version of the script:

10 Likes
btrfs filesystem usage /
WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
Overall:
    Device size:		 398.49GiB
    Device allocated:		 398.48GiB
    Device unallocated:		   1.00MiB
    Device missing:		     0.00B
    Device slack:		  16.00EiB
    Used:			 354.58GiB
    Free (estimated):		  42.28GiB	(min: 42.28GiB)
    Free (statfs, df):		  42.28GiB
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		 486.09MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,single: Size:395.45GiB, Used:353.17GiB (89.31%)

Metadata,single: Size:3.00GiB, Used:1.41GiB (46.85%)

System,single: Size:32.00MiB, Used:64.00KiB (0.20%)
 Device unallocated:		   1.00MiB

sudo btrfs filesystem usage /
Overall:
    Device size:		 398.49GiB
    Device allocated:		 398.48GiB
    Device unallocated:		   1.00MiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			 354.58GiB
    Free (estimated):		  42.28GiB	(min: 42.28GiB)
    Free (statfs, df):		  42.28GiB
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		 486.09MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,single: Size:395.45GiB, Used:353.17GiB (89.31%)
   /dev/nvme0n1p5	 395.45GiB

Metadata,single: Size:3.00GiB, Used:1.41GiB (46.85%)
   /dev/nvme0n1p5	   3.00GiB

System,single: Size:32.00MiB, Used:64.00KiB (0.20%)
   /dev/nvme0n1p5	  32.00MiB

Unallocated:
   /dev/nvme0n1p5	   1.00MiB

I am too tired for this :grin:

 btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}'
1.00MiB

I received some feedback from @SGS regarding the scripts method of remaining space calculation.

For some strange reason when @SGS ran my command:

`btrfs filesystem usage / 2> /dev/null | grep -i 'Device unallocated:' | awk '{print $3}'`

@SGS recieved an output of 1.00MiB of freespace, which was obviously completely incorrect. So, instead of grepping unallocated space I think it would be best to display the output of Free (estimated) space which outputs correctly on his system.

I’m thinking I’ll revise the section of the script relating to the free space calculation to this:

echo -e "\nAlways ensure you have adequate free space before initiating a system update"
echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"

Which outputs this:

Always ensure you have adequate free space before initiating a system update
BTRFS space calculations are inexact, you appear to have the following range of values:

Free (estimated):             29.44GiB      (min: 16.73GiB)

Any comments/tips regarding the garuda-update-now script would be appreciated. Anyone with better bash skills than myself, please offer up your suggestions for code improvements. I’m sure there are others far more capable at using bash than myself that could find ways to improve this.

2 Likes

maybe garuda-update – -u could be added as “FixRounded” or something. i also know 0 things about bash anymore im full fish where i know = 0 about. lol other then basic layout

3 Likes

I’m not sure what you mean by this. Using the --u or -u parameter returns:

/usr/bin/garuda-update: invalid option 

To my knowledge there is no “u” option/parameter in the garuda-update documentation.

Please give me some further insight on your suggestion @elite .

1 Like

ah my bad I meant garuda-update -- -u its whats being suggested to users when rounded corners stops showing the outline. A quick way to rebuild it against a kwin/plasma update if for some reason its missed during a normal garuda-update.

1 Like

Ah, that works better. I was unaware of this bug, as I use a standard KDE breeze dark theme with the KDE Lite edition.

No fancy schmancy ounded corners on my comuters. :smiley:

Sure thing, that’s an easy thing to add to the script @elite .

2 Likes

I didn’t know it was a command tell recently either I used to just rebuild it from git when i saw a plasma change since plasma 6. maybe in some way it could be added to rani down the line as well. but great job on the tui it looks cool.

1 Like

This is the updated version of the Garuda Update Now gun.sh script I wrote.

#!/bin/bash
#cat /usr/local/bin/gun.sh
#sudo chmod +x  /usr/local/bin/gun.sh

black='\033[0;30m'
dk_gray='\033[1;30m'
red='\033[0;31m'
lt_red='\033[1;31m'
green='\033[0;32m'
lt_green='\033[1;32m'
yellow='\033[1;33m'
blue='\033[0;34m'
lt_blue='\033[1;34m'
purple='\033[0;35m'
lt_purple='\033[1;35m'
orange='\033[0;33m'
cyan='\033[0;36m'
lt_gray='\033[0;37m'
white='\033[1;37m'
default='\033[0m' # Default Color

HEIGHT=20
WIDTH=80
CHOICE_HEIGHT=4
BACKTITLE="Garuda Update Now"
TITLE="Garuda Update Advanced Options"
MENU="Choose one of the following options:"

OPTIONS=(1 "garuda-update + refresh mirrorlist"
         2 "garuda-update + Chaotic AUR + AUR updates + refresh mirrorlist"
         3 "garuda-update - skip refresh mirrorlist"
         4 "garuda-update + Chaotic AUR + AUR updates - skip refresh mirrorlist"
         5 "garuda-update --noconfirm"
         6 "garuda-update remote fix"
         7 "garuda-update remote keyring"
         8 "garuda-update remote fullfix"
         9 "garuda-update remote reinstall"
        10 "garuda-update remote reset-snapper"
        11 "garuda-update remote reset-audio"
        12 "garuda-update -- -u")

CHOICE=$(dialog --clear \
                --backtitle "$BACKTITLE" \
                --title "$TITLE" \
                --menu "$MENU" \
                $HEIGHT $WIDTH $CHOICE_HEIGHT \
                "${OPTIONS[@]}" \
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update
            ;;
        2)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update -a${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR updates + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a
            ;;
        3)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update --skip-mirrorlist${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update --skip-mirrorlist
            ;;
        4)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update -a --skip-mirrorlist${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR+updates - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a --skip-mirrorlist
            ;;
        5)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update –noconfirm${default}"
            echo  "This command will perform a system update without multiple confirmation prompts"
            echo -e "This emulates a custom (safer) version of --noconfirm for pacman (PACMAN_NOCONFIRM=1)\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update --noconfirm
             ;;
        6)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo -e "Refresh keyrings\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fix
            ;;
        7)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote keyring${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Refresh the keyring without resetting pacman.conf\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote keyring
            ;;
        8)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fullfix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo "Refresh keyrings"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fullfix
            ;;
         9)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reinstall${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reinstall
            ;;
        10)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-snapper${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Remove all backup subvolumes and snapshots created by Snapper"
            echo -e "Force recreate the Snapper configs\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-snapper
            ;;
        11)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-audio${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reinstall WirePlumber and Pipewire-support"
            echo "Disable/enable the WirePlumber and Pipewire-support services"
            echo -e "Reset the audio configuration to default\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-audio
            ;;
         12)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update -- -u${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Undocumented parameter to fix some update issues when receiving a warning about downgrading\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -- -u
            ;;
esac


Save the Garuda Update Now script as:

/usr/local/bin/gun.sh

Make the script executable:

sudo chmod +x  /usr/local/bin/gun.sh

To test the gun.sh script without any extra steps, you can simply copy/paste the entire script into any terminal window and execute it there.

When you execute gun.sh, the script should look something like the pic below in your terminal window:

You can also Change the TUI apearance of any TUI if you desire to do so. After modification my gun.sh script displays as in the pic below:

4 Likes

skip-mirrorlist needs a extra - --skip-mirrorlist but testing it manually its not currently working when you just run the command garuda-update --skip-mirriorlistalso with -a” so something else might be happening there.


I would copy paste the text but vert manager wont let me.

3 Likes
garuda-update --skip-mirrorlist

Works for me^^

The command in my script garuda-update –skip-mirrorlist was copied directly from the documentation (garuda-update -h).

Thanks so much for your feedback @elite .

I have revised the script again. The problem I think happens when copying directly from the documentation that two dashes -- when pasted appears as one dash -. Not sure what’s up with that.

4 Likes

i think it might have to do with discloser itself maybe some markdown thing but glad it got all fixed up.

~Edit tested all but reinstall, all working. :+1:

1 Like

I’ve been experimenting with Waydroid and sometimes it really bogs down Plasma, so I just wrote some wacky aliases to free up all available memory and restart plasmashell and kwin_x11 and shutdown Waydroid:

# FLUSH - Flush the page-cache, dentries, inodes, sync flush the file system buffer, and stop and restart swap
alias flush='su -c "echo 3 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a  && echo && echo -e "ram_cache-swap_cleared" && echo"'

# NUKE -Kill & Restart Plasmashell & Kwin_X11
alias nuke='bash -c "systemctl --user restart plasma-plasmashell > /dev/null 2>&1 & disown; sleep 2; systemctl --user restart plasma-kwin_x11.service > /dev/null 2>&1 & disown; sleep 2 && echo && echo -e "Plasmashell_and_Kwin_X11_nuked_and_restarted"; exit"'

# KILLDROID - Shutdown Waydoid & Weston
alias killdroid='pkill weston && unset WAYLAND_DISPLAY && sudo waydroid container stop && waydroid session stop && sleep 2 && systemctl --user stop clipboard-sync'

If I want to run all three aliases at once I simply execute:

killdroid && nuke && flush

When executed all together this is the output:

htpc@htpc2: /home/htpc
Mon Jul 07 05:16 PM
$ killdroid && nuke && flush
[sudo] password for htpc:

Plasmashell_and_Kwin_X11_nuked_and_restarted
Password:

ram_cache-swap_cleared

htpc@htpc2: /home/htpc
Mon Jul 07 05:16 PM
$

Certainly not my best code attemt, but it works. :smiley:

6 Likes

Had to find how to recreate this (my last Garuda install left for milk and eggs, and never came back), and it took too much searching to get done, so why not share it? Do something, about the time the login manager shows up, every time. In this case, the very bright blue-white power button LED is a bit too annoying, in low light conditions. A second of sleep is good, to let everything settle in, and using no prepended sleep sometimes fails. The annoying bit was finding all the targets, to apply every time the login manager is going to show up, as the targets aren’t documented all that well, beyond the runlevel replacements. The graphical.target, FI, naively works, but only after booting and logging in, not when waking up from any sleep states, thereafter.

[Unit]
Description: Power light LED bad!
After=suspend.target hibernate.target suspend-then-hibernate.target hybrid-sleep.target graphical.target

[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'sleep 1 && /usr/bin/echo -n 0 > /sys/class/leds/tpacpi\:\:power/brightness'

[Install]
WantedBy=suspend.target hibernate.target suspend-then-hibernate.target hybrid-sleep.target graphical.target

Into /etc/systemd/system/nameofchoice.service, then systemctl enable nameofchoice.

1 Like

I didn’t really think there was too much interest in my gun.sh “Garuda Update Now” script, so I didn’t bother to post more info on modifying its appearance. Now that I see @gampel mentioned using it recently I’ll post some further information and screen shots.



TUI Dialog customization for gun.sh using a config file:



You can customize various aspects of the dialog command by creating a ~/.dialogrc file. A .dialogrc file is required to customize the gun.sh dialog window’s size/appearance.

To create a sample/default ~/.dialogrc file enter the following command in the terminal:

dialog --create-rc ~/.dialogrc

To customize the ~/.dialogrc default settings, open the file in your favorite text editor and experiment with altering the default settings.

Here are some tips:

Turn on shadow dialog boxes

use_shadow = ON

Turn on color support ON

use_colors = ON

Change default blue background color to BLACK

screen_color = (CYAN,BLACK,ON)

Available colors are (numbers from 0 through 7), corresponding to, black, red, green, yellow, blue, magenta, cyan, and white. After modifying any Dialog config settings, save and close the file, then relaunch gun.sh to view your changes.

This was the appearance of the default Dialog TUI window before I altered it with a modified ~/.dialogrc file:

This is the current appearance of my gun.sh Dialog TUI window now, after altering it with a modified ~/.dialogrc file:

This is the modified version of the ~/.dialogrc file I am currently using:

# cat ~/.dialogrc
#
#black background - white text
#
aspect = 0
separate_widget = ""
tab_len = 0
visit_items = OFF
use_shadow = OFF
use_colors = ON
screen_color = (WHITE,DEFAULT,OFF)
shadow_color = (WHITE,WHITE,OFF)
dialog_color = (WHITE,BLACK,OFF)
title_color = (GREEN,BLACK,OFF)
border_color = (WHITE,BLACK,OFF)
button_active_color = (BLACK,YELLOW,OFF)
button_inactive_color = (WHITE,BLACK,OFF)
button_key_active_color = (BLACK,GREEN,OFF)
button_key_inactive_color = (RED,BLACK,OFF)
button_label_active_color = (BLACK,YELLOW,OFF)
button_label_inactive_color = (WHITE,BLACK,OFF)
inputbox_color = (WHITE,BLACK,OFF)
inputbox_border_color = (BLACK,BLACK,OFF)
searchbox_color = (WHITE,BLACK,OFF)
searchbox_title_color = (GREEN,BLACK,OFF)
searchbox_border_color = (WHITE,BLACK,OFF)
position_indicator_color = (GREEN,BLACK,OFF)
menubox_color = (BLACK,BLACK,OFF)
menubox_border_color = (BLACK,BLACK,OFF)
item_color = (WHITE,BLACK,OFF)
item_selected_color = (BLACK,GREEN,OFF)
tag_color = (BLUE,BLACK,OFF)
tag_selected_color = (BLACK,GREEN,OFF)
tag_key_color = (YELLOW,BLACK,OFF)
tag_key_selected_color = (BLACK,GREEN,OFF)
check_color = (WHITE,BLACK,OFF)
check_selected_color = (BLACK,GREEN,OFF)
uarrow_color = (GREEN,BLACK,OFF)
darrow_color = (GREEN,BLACK,OFF)
itemhelp_color = (BLACK,WHITE,OFF)
form_active_text_color = (BLACK,BLUE,OFF)
form_text_color = (WHITE,BLACK,OFF)
form_item_readonly_color = (BLACK,WHITE,OFF)

For more in depth details you will need to search online, as I found the documentation to be rather sparse. Play with the ~/.dialogrc file configuration settings to create your own customized appearance that you prefer.

Just thought I’d add a little extra bonus info for those interested in these kind of things.

7 Likes

I like your kiss script
current status without .dialogrc

That’s on work in progress

6 Likes

Here’s another bash alias that I find handy after the computer and the power to my external hard drives has been shut off. This alias is not used very often as my system is usually always on. My external drives are hidden away in an awkward to get at location and after a power outage I usually forget to power on my drives again. Some drives will not be recognized by the system and cannot be mounted unless they are powered up at boot. After the drive is powered up, this alias re-scans the bus so that all drives are recognized by the system and another reboot is not required for the system to mount the drive.

Alias:

# RESCAN - alias to rescan for any undetected hard drives
alias rescan='for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done'

Sure it may be a lazy hack, but it prevents an unnecessary reboot and I usually only reboot once a week at most. It took me quite a few years to find that solution, so I thought I’d post it in case anyone else might find it handy. Besides, I have a thing for aliases. :smiley: :+1:

4 Likes