Quick Scripts

Quick Install: Pop-OS

THIS IS THE SCRIPT TO QUICKLY GET BASIC SOFTWARE UP ONLY. For further config, see “System Setup” Below. See “Current install setup” below or install.txt in Files > Documents > org-files.

Current install setup will ONLY install programs to avoid future issues with basic file redundancies.

 1        # Basics
 2    sudo apt install -y gnome-tweaks            # tweaks!!!
 3    sudo apt install -y nmap                        # networking!!!
 4    sudo apt install -y zsh                        # shell
 5    sudo apt install -y htop		# extras
 6    sudo apt install -y texlive
 7    sudo apt install -y vlc
 8    #sudo apt install -y tlp                   # Confirm before install using
 9    #sudo apt install -y tlp-rdwsudo           # what does it do?
10    sudo apt install -y inotify-tools
11    
12    sudo add-apt-repository universe
13    sudo apt update
14    
15    
16    # Install Nerd Fonts?
17    #git clone https://github.com/ryanoasis/nerd-fonts.git
18    #sudo ./nerd-fonts/install.sh
19    
20    
21    ### tweaks
22    ## https://www.digitalocean.com/community/tutorials/how-to-configure-periodic-trim-for-ssd-storage-on-linux-servers
23    # sudo systemctl enable fstrim.timer     # Confirm before install using sudo systemctl status fstrim.timer
24    
25    
26    # Software
27    sudo apt install -y guake                       # terminal
28    sudo apt install -y grsync
29    sudo apt install -y darktable rawtherapee inkscape gimp		# photography, file editing
30    # sudo apt install -y gparted		# tooling # Comes preinstalled in pop OS?
31    sudo apt install -y qbittorrent
32    #### MISSING GNOME TWEAKS
33
34# Update font cache
35sudo fc-cache -f -v
36    
37    #flatpak install flathub com.spotify.Client      # See https://flathub.org/apps/com.spotify.Client
38    flatpak install flathub com.zoho.Notebook        # See https://flathub.org/apps/com.zoho.Notebook
39    #flatpak install flathub com.rtosta.zapzap       # See https://flathub.org/apps/com.rtosta.zapzap
40    
41    # Proton vpn needs intervention. Use flathub instead?                # https://protonvpn.com/support/official-ubuntu-vpn-setup/
42    # webapp-manager needs intervention.                                 # https://fosspost.org/how-to-install-webapps-on-linux/
43    # AppImage Pool needs invervention Pop Shop
44    
45    #Do I need ubuntu-restricted extras? sudo apt install -y ubuntus-restricted-extras

Setting up R

1sudo apt update
2sudo apt install r-base r-base-dev

For RStudio

Code does not download latest version.

1cs ~/
2wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2024.09.0-375-amd64.deb
3sudo apt install ./rstudio-2024.09.0-375-amd64.deb

Scripts

Quick collection of scripts that I use day-to-day, and imagine others may find useful.

Rapid switch caps, ctrl

using Gnome Tweak Tools.

 1#!/bin/bash
 2## Comments
 3## Enable will make ctrl act as ctrl, and caps as caps lock.
 4## Disable will make ctrl act as a caps lock button, and the caps button act as a ctrl.
 5
 6# Function to enable the Caps Lock and Ctrl swap
 7enable_swap() {
 8    echo "Enabling standard keyboard layout (Caps=Caps, Ctrl=Ctrl)..."
 9    gsettings reset org.gnome.desktop.input-sources xkb-options
10    sleep 2  # Allow time for X server to apply changes
11    echo "Standard layout enabled."
12}
13
14# Function to disable the Caps Lock and Ctrl swap
15disable_swap() {
16    echo "Disabling standard layout (Caps=Ctrl, Ctrl=Caps)..."
17    gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:swapcaps']"
18    sleep 2  # Allow time for X server to apply changes
19    echo "Swapped layout enabled."
20}
21
22# Check if the user provided an argument
23if [ "$1" == "enable" ]; then
24    enable_swap
25elif [ "$1" == "disable" ]; then
26    disable_swap
27else
28    echo "Usage: $0 {enable|disable}"
29    exit 1
30fi

Add to ~/.local/bin/. Run chmod +x toggle_caps_ctrl.sh to make it executable.

Takes commands: ./toggle_caps_ctrl.sh enable ./toggle_caps_ctrl.sh disable

Keyboard Numlock Check

Will check if numlock is on every 5 minutes, and if on, wait 2 minutes before turning it off. Generated using ChatGPT

needs following : “sudo apt-get install xdotool x11-xserver-utils”

 1#!/bin/bash
 2    
 3# Function to check and turn off Num Lock
 4check_and_turn_off_numlock() {
 5    # Use xset to check the state of Num Lock
 6    numlock_state=$(xset q | grep "Num Lock:" | awk '{print $8}')
 7    check_count=0
 8    
 9    while [ "$numlock_state" = "on" ] && [ $check_count -lt 3 ]; do
10        echo "Num Lock is on. Checking again in 2 seconds..."
11        sleep 2
12        numlock_state=$(xset q | grep "Num Lock:" | awk '{print $8}')
13        check_count=$((check_count + 1))
14    done
15    
16    if [ "$numlock_state" = "on" ]; then
17        echo "Num Lock is still on after 3 checks. Turning it off..."
18        xdotool key Num_Lock
19        echo "Num Lock has been turned off."
20    else
21        echo "Num Lock is already off or was turned off during checks."
22    fi
23}
24    
25# Main loop
26while true; do
27    check_and_turn_off_numlock
28    echo "Waiting for 30 seconds before checking again..."
29    sleep 30  # Wait for 30 seconds before checking again
30done

Find the Raspberry Pi IP

Takes either no input or just ‘pi’. If you input nothing, finds all IP addresses on your network. If you input ‘pi’, finds ip of raspberry pi. Not my script, I copied this and added some tweaks from someone else a long time ago on the internet.

 1function raspPiFinder {
 2    if [ "${1}" == "pi" ]; then
 3        sudo nmap -sP 192.168.1.111/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'
 4
 5    else
 6        sudo nmap -sP 192.168.1.111/24
 7
 8    fi
 9}
10
11raspPiFinder $1