|
| 1 | +# Compression |
| 2 | +compress() { tar -czf "${1%/}.tar.gz" "${1%/}"; } |
| 3 | +alias decompress="tar -xzf" |
| 4 | + |
| 5 | +# Convert webm files generated by the Gnome screenshot video recorder to mp4s that are more compatible |
| 6 | +webm2mp4() { |
| 7 | + input_file="$1" |
| 8 | + output_file="${input_file%.webm}.mp4" |
| 9 | + ffmpeg -i "$input_file" -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 192k "$output_file" |
| 10 | +} |
| 11 | + |
| 12 | +# Write iso file to sd card |
| 13 | +iso2sd() { |
| 14 | + if [ $# -ne 2 ]; then |
| 15 | + echo "Usage: iso2sd <input_file> <output_device>" |
| 16 | + echo "Example: iso2sd ~/Downloads/ubuntu-25.04-desktop-amd64.iso /dev/sda" |
| 17 | + echo -e "\nAvailable SD cards:" |
| 18 | + lsblk -d -o NAME | grep -E '^sd[a-z]' | awk '{print "/dev/"$1}' |
| 19 | + else |
| 20 | + sudo dd bs=4M status=progress oflag=sync if="$1" of="$2" |
| 21 | + sudo eject $2 |
| 22 | + fi |
| 23 | +} |
| 24 | + |
| 25 | +# Create a desktop launcher for a web app |
| 26 | +web2app() { |
| 27 | + if [ "$#" -ne 3 ]; then |
| 28 | + echo "Usage: web2app <AppName> <AppURL> <IconURL> (IconURL must be in PNG -- use https://dashboardicons.com)" |
| 29 | + return 1 |
| 30 | + fi |
| 31 | + |
| 32 | + local APP_NAME="$1" |
| 33 | + local APP_URL="$2" |
| 34 | + local ICON_URL="$3" |
| 35 | + local ICON_DIR="$HOME/.local/share/applications/icons" |
| 36 | + local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop" |
| 37 | + local ICON_PATH="${ICON_DIR}/${APP_NAME}.png" |
| 38 | + |
| 39 | + mkdir -p "$ICON_DIR" |
| 40 | + |
| 41 | + if ! curl -sL -o "$ICON_PATH" "$ICON_URL"; then |
| 42 | + echo "Error: Failed to download icon." |
| 43 | + return 1 |
| 44 | + fi |
| 45 | + |
| 46 | + cat > "$DESKTOP_FILE" <<EOF |
| 47 | +[Desktop Entry] |
| 48 | +Version=1.0 |
| 49 | +Name=$APP_NAME |
| 50 | +Comment=$APP_NAME |
| 51 | +Exec=google-chrome --app="$APP_URL" --name="$APP_NAME" --class="$APP_NAME" --window-size=800,600 |
| 52 | +Terminal=false |
| 53 | +Type=Application |
| 54 | +Icon=$ICON_PATH |
| 55 | +Categories=GTK; |
| 56 | +MimeType=text/html;text/xml;application/xhtml_xml; |
| 57 | +StartupNotify=true |
| 58 | +EOF |
| 59 | + |
| 60 | + chmod +x "$DESKTOP_FILE" |
| 61 | +} |
| 62 | + |
| 63 | +web2app-remove() { |
| 64 | + if [ "$#" -ne 1 ]; then |
| 65 | + echo "Usage: web2app-remove <AppName>" |
| 66 | + return 1 |
| 67 | + fi |
| 68 | + |
| 69 | + local APP_NAME="$1" |
| 70 | + local ICON_DIR="$HOME/.local/share/applications/icons" |
| 71 | + local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop" |
| 72 | + local ICON_PATH="${ICON_DIR}/${APP_NAME}.png" |
| 73 | + |
| 74 | + rm "$DESKTOP_FILE" |
| 75 | + rm "$ICON_PATH" |
| 76 | +} |
| 77 | + |
| 78 | +# Ensure that external keyboards that use an fn key has the F keys as the default |
| 79 | +alias fix_fkeys='echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode' |
0 commit comments