commit 4335f55c672d0dc670c1b3d22872b9e0664ce7fa Author: emanuel Date: Wed Mar 26 21:37:21 2025 +0100 Uppladdning av script diff --git a/appimages.sh b/appimages.sh new file mode 100755 index 0000000..61090cd --- /dev/null +++ b/appimages.sh @@ -0,0 +1,24 @@ +#!/bin/bash +#Requires a template.desktop in /usr/share/applications +# +# +read -p "Enter filename: " file +read -p "Enter name: " name +read -p "Enter version: " version +echo "Making AppImage executable" +#Make appimage executable +# +sudo chmod +x ~/Applications/$name-$version.AppImage +# Copy template +# +sudo cp /usr/share/applications/template.desktop /usr/share/applications/$file.desktop +# Search for text to replace +# +if [[ $name != "oldname" && $version != "oldversion" ]]; then + +sudo sed -i 's/oldversion/'$version'/g' /usr/share/applications/$file.desktop +sudo sed -i 's/oldname/'$name'/g' /usr/share/applications/$file.desktop + +fi + +echo "$file.desktop has been created" diff --git a/btconnect.sh b/btconnect.sh new file mode 100755 index 0000000..e23398d --- /dev/null +++ b/btconnect.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Configuration +DEVICE_MAC_ADDRESS="88:C9:E8:F4:4A:FF" # Replace with your device's MAC address + +# Function to check if a device is connected +is_device_connected() { + bluetoothctl info "$DEVICE_MAC_ADDRESS" | grep -q "Connected: yes" +} + +# Function to connect the device +connect_device() { + echo -e "connect $DEVICE_MAC_ADDRESS\nquit" | bluetoothctl +} + +# Function to disconnect the device +disconnect_device() { + echo -e "disconnect $DEVICE_MAC_ADDRESS\nquit" | bluetoothctl +} + +# Main logic +if is_device_connected; then + echo "Device $DEVICE_MAC_ADDRESS is already connected. Disconnecting..." + disconnect_device +else + echo "Device $DEVICE_MAC_ADDRESS is not connected. Connecting..." + connect_device +fi + +exit 0 diff --git a/heic.sh b/heic.sh new file mode 100755 index 0000000..f4858bd --- /dev/null +++ b/heic.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Kontrollera om magick är installerat +if ! command -v magick &> /dev/null +then + echo "magick kunde inte hittas. Installera ImageMagick." + exit 1 +fi + +# Räknare för att generera unika filnamn +count=0 + +# Loopa igenom alla .heic-filer i mappen +for file in *.heic; do + # Öka räknaren + count=$((count+1)) + + # Formatera räknaren till fyra siffror med ledande nollor + padded_count=$(printf "%04d" $count) + + # Skapa det nya filnamnet + new_file_name="IMG_${padded_count}.jpeg" + + # Konvertera filen + magick convert "$file" "$new_file_name" + + # Kontrollera om konverteringen lyckades + if [ $? -eq 0 ]; then + echo "Konverterade $file till $new_file_name" + else + echo "Misslyckades med att konvertera $file" + fi +done + +echo "Konvertering av .heic-filer till .jpeg avslutad." diff --git a/multisave.sh b/multisave.sh new file mode 100755 index 0000000..ade95f0 --- /dev/null +++ b/multisave.sh @@ -0,0 +1,100 @@ +#!/bin/bash +NC='\033[0m' # No Color +RED='\033[0;31m' +LB='\033[1;34m' #Lightblue +read -p "Press [Enter] key to start the backup process..." +## Bash add a pause for 1 seconds ## +read -t 1 -p "" +echo "" + +PS3="Choose what game to backup: " +greeting="Welcome, time to backup your savefiles!" +user=$(whoami) +day=$(date +%A) +date=$(date +"%F-%H") + +select opt in EldenRing LiesOfP Sekiro GhostOfTsushima Exit; do + + case $opt in + EldenRing) + mkdir /home/emanuel/NAS/Spel/$opt/$date + read -t 2 -p "" + echo -e "${RED}Created the folder ${LB}$date" + echo -e "${NC}" + +cp /home/emanuel/Games/elden-ring/drive_c/users/emanuel/AppData/Roaming/$opt/GraphicsConfig.xml /home/emanuel/NAS/Spel/$opt/$date +cp -r /home/emanuel/Games/elden-ring/drive_c/users/emanuel/AppData/Roaming/$opt/76561197960267366 /home/emanuel/NAS/Spel/$opt/$date +read -t 2 -p "" +echo "" +echo "" +echo -e "Savefile for ${LB}$opt has been backed up for the user ${RED}$user!" +echo -e "${NC}" +read -t 2 -p "Exiting Script" +echo "" +exit +;; +LiesOfP) + mkdir /home/emanuel/NAS/Spel/$opt/$date + read -t 2 -p "" + echo -e "${RED}Created the folder ${LB}$date" + echo -e "${NC}" + +cp /home/emanuel/Games/liesofp/drive_c/users/emanuel/AppData/Roaming/$opt/GraphicsConfig.xml /home/emanuel/NAS/Spel/$opt/$date +cp -r /home/emanuel/Games/liesofp/drive_c/users/emanuel/AppData/Roaming/$opt/76561197960267366 /home/emanuel/NAS/Spel/$opt/$date +read -t 2 -p "" +echo "" +echo "" +echo -e "Savefile for ${LB}$opt has been backed up for the user ${RED}$user!" +echo -e "${NC}" +read -t 2 -p "Exiting Script" +echo "" +exit +;; + Sekiro) + mkdir /home/emanuel/NAS/Spel/$opt/$date + read -t 2 -p "" + echo -e "${RED}Created the folder ${LB}$date" + echo -e "${NC}" + +cp /home/emanuel/Games/sekiro/drive_c/users/emanuel/AppData/Roaming/$opt/GraphicsConfig.xml /home/emanuel/NAS/Spel/$opt/$date +cp -r /home/emanuel/Games/sekiro/drive_c/users/emanuel/AppData/Roaming/$opt/76561197960267366 /home/emanuel/NAS/Spel/$opt/$date +read -t 2 -p "" +echo "" +echo "" +echo -e "Savefile for ${LB}$opt has been backed up for the user ${RED}$user!" +echo -e "${NC}" +read -t 2 -p "Exiting Script" +echo "" +exit +;; + GhostOfTsushima) + mkdir /home/emanuel/NAS/Spel/$opt/$date + read -t 2 -p "" + echo -e "${RED}Created the folder ${LB}$date" + echo -e "${NC}" + +#cp /home/emanuel/Games/sekiro/drive_c/users/emanuel/AppData/Roaming/$opt/GraphicsConfig.xml /home/emanuel/NAS/Spel/$opt/$date +cp -r /home/emanuel/Games/ghost-of-tsushima/drive_c/users/steamuser/Documents /home/emanuel/NAS/Spel/$opt/$date +read -t 2 -p "" +echo "" +echo "" +echo -e "Savefile for ${LB}$opt has been backed up for the user ${RED}$user!" +echo -e "${NC}" +read -t 2 -p "Exiting Script" +echo "" +exit +;; + + Exit) +read -t 2 -p "" +echo "" +echo "" +echo "Nothing was done, exiting the script" + exit + +;; +*) + echo "invalid option $REPLY" + ;; + esac + done diff --git a/ps5.sh b/ps5.sh new file mode 100755 index 0000000..d636d35 --- /dev/null +++ b/ps5.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +device="4C:B9:9B:D2:FC:FF" + +if bluetoothctl info "$device" | grep 'Connected: yes' -q; then + echo "Redan uppkopplad" + bluetoothctl disconnect "$device" +else + bluetoothctl connect "$device" +fi diff --git a/ssh.sh b/ssh.sh new file mode 100755 index 0000000..d2fb2a3 --- /dev/null +++ b/ssh.sh @@ -0,0 +1,24 @@ +#!/bin/bash +PS3="What server do you want to SSH to?: " + +select opt in Nextcloud Wireguard Jellyfin quit; do + + case $opt in + Nextcloud) + ssh nextcloud@192.168.1.205 + ;; + Wireguard) + ssh wireguard@192.168.1.202 + ;; + Jellyfin) + ssh jellyfin@192.168.1.225 + ;; + quit) + echo "Exiting script" + exit + ;; + *) + echo "Invalid option $REPLY" + ;; + esac +done diff --git a/sshconnect.sh b/sshconnect.sh new file mode 100755 index 0000000..0f2130f --- /dev/null +++ b/sshconnect.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +ps3="What server do you want to connect to?" +select server in Nextcloud Wireguard Jellyfin Quit +do +if [ $server == Nextcloud ] +echo "You are connecting to $server" + then +ssh nextcloud@192.168.1.205 +elif [ $server == Wireguard ] + then +ssh wireguard@192.168.1.202 +elif [ $server == Jellyfin ] +then ssh jellyfin@192.168.1.225 + +fi +done diff --git a/while.sh b/while.sh new file mode 100755 index 0000000..754e1e1 --- /dev/null +++ b/while.sh @@ -0,0 +1,14 @@ +#!/bin/bash +first_greeting="Nice to meet you!" +later_greeting="How are you?" +greeting=0 +while [ $greeting -lt 3 ] +do +if [ $greeting -lt 1 ] +then +echo $first_greeting +else +echo $later_greeting +fi +greeting=$((greeting + 1)) +done diff --git a/wifimult.sh b/wifimult.sh new file mode 100755 index 0000000..45dba15 --- /dev/null +++ b/wifimult.sh @@ -0,0 +1,29 @@ +#!/bin/bash +#Colors +RED='\033[0;31m' +NC='\033[0m' # No Color +LB='\033[1;34m' #Lightblue color + +#Start of script +PS3="Chose Wi-Fi: " +#selections +select opt in soaplink5G 'Emanuel - iPhone' Exit; do + case $opt in + soaplink5G) + nmcli device wifi connect soaplink5G + echo -e "${LB}Connecting to ${RED}$opt" +exit +;; + + 'Emanuel - iPhone') + nmcli device wifi connect 12:82:A7:51:1E:59 + echo -e "${LB}Connecting to ${RED}$opt" +exit +;; + Exit) + echo -e "${LB}No connection made, ${RED}closing." +exit +;; +*) +esac +done diff --git a/xbox.sh b/xbox.sh new file mode 100755 index 0000000..fbf69ad --- /dev/null +++ b/xbox.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +device="40:8E:2C:03:25:E5" + +if bluetoothctl info "$device" | grep 'Connected: yes' -q; then + echo "Redan uppkopplad" + bluetoothctl disconnect "$device" +else + bluetoothctl connect "$device" +fi