Posts

Enable Anydesk on Linux

 By default, Anydesk doesn't work on Ubuntu as it uses a different display server than what is expected by Anydesk (it expects the traditional X11 rather than Wayland). Dump this into a file, say, "fix_anydesk.sh", and then run it with sudo bash fix_anydesk.sh The script: #!/bin/bash # Check if the user has root privileges if [[ $EUID -ne 0 ]]; then    echo "This script must be run as root"     exit 1 fi # Backup the GDM configuration file GDM_CONFIG="/etc/gdm3/custom.conf" if [[ -f "$GDM_CONFIG" ]]; then     cp "$GDM_CONFIG" "$GDM_CONFIG.bak"     echo "Backup of custom.conf created." else     echo "GDM configuration file not found."     exit 1 fi # Disable Wayland by uncommenting and setting the 'WaylandEnable' option to false sed -i 's/#WaylandEnable=false/WaylandEnable=false/' "$GDM_CONFIG" # Inform the user echo "Wayland has been disabled. The system will use X11 inste

folderizer

 This script moves large numbers of files into subfolders sorted alphabetically. #!/bin/bash # Create folders for letters and numbers for letter in {A..Z}; do   mkdir -p "$letter" done for num in {1..9}; do   mkdir -p "$num" done # Create a folder for punctuation-based files mkdir -p "M" # Function to handle files starting with a punctuation mark handle_punctuation() {   for file in *; do     if [[ -f $file ]]; then       first_char="${file:0:1}"       if [[ $first_char =~ [[:punct:]] ]]; then         new_name="_${file}"         mv "$file" "$new_name"         first_char="${new_name:0:1}"         if [[ $first_char =~ [[:digit:]] ]]; then           mv "$new_name" "$first_char/"         elif [[ $first_char =~ [A-Za-z] ]]; then           # Normalize to uppercase for letter folders           first_char=$(echo "$first_char" | tr '[:lower:]' '[:upper:]')           mv &

A script to turn unencrypted epub files into plain text, bash

 #!/bin/bash # Check if a directory is provided if [ "$#" -ne 1 ]; then     echo "Usage: $0 <path-to-directory>"     exit 1 fi DIRECTORY="$1" # Check if the provided argument is a directory if [ ! -d "$DIRECTORY" ]; then     echo "The specified path is not a directory."     exit 1 fi # Process each EPUB file in the directory find "$DIRECTORY" -type f -name "*.epub" | while IFS= read -r EPUB_FILE; do     # Extract the base name without the extension     BASE_NAME=$(basename "$EPUB_FILE" .epub)     TEXT_FILE="$DIRECTORY/${BASE_NAME}.txt"     echo "Processing $EPUB_FILE"          # Create a temporary directory to extract the EPUB file     TEMP_DIR=$(mktemp -d)     echo "Extracting EPUB file to $TEMP_DIR"          # Unzip the EPUB file into the temporary directory     unzip -q "$EPUB_FILE" -d "$TEMP_DIR"          # Find the content directory (OEBPS, EPUB,

apt produces errors relating to python

 If you get these errors: produces this error again: Fetched 1,363 kB in 9s (153 kB/s) (Reading database ... 195577 files and directories currently installed.) Preparing to unpack .../archives/apt_2.4.12_amd64.deb ... Unpacking apt (2.4.12) over (2.4.12) ... Setting up apt (2.4.12) ... Setting up python3 (3.10.6-1~22.04.1) ... running python rtupdate hooks for python3.10... Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main() File "/usr/bin/py3clean", line 196, in main pfiles = set(dpf.from_package(options.package)) File "/usr/share/python3/debpython/files.py", line 55, in from_package raise Exception("cannot get content of %s" % package_name) Exception: cannot get content of gdebi-core error running python rtupdate hook gdebi-core Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main()

Docker incantations

 I find docker a bit obscure so I will list a short list of commands here to jog my memory. Build the docker container: docker compose up  or docker-compose up See what docker containers are running to get their IDs docker ps -a Login to a container using bash: (while running): docker exec -it d762049858c7 bash See what the password/s are including for mysql for a docker container: docker inspect d762049858c7 | grep -i password Nuke the container to edit it to rebuild: docker compose down Copy a local file to a running container: docker cp /path/to/local/file d762049858c7:/path/inside/container/ See what is going on: docker logs d762049858c7 Get the container IP address: docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' d762049858c7

Convert MKV to MOV or MP4 to MOV

# MKV to MP4      ffmpeg -i movie-file.mkv  -codec copy movie-file.mp4 # MKV to MOV (compressed)      ffmpeg -i movie-file.mkv  -f mov movie-file.mov # MP4 to MOV (compressed)      ffmpeg -i movie-file.mp4  -f mov movie-file.mov # MKV to MOV (raw/uncompressed: warning huge file):      ffmpeg -i movie-file.mkv -c:v prores_ks -profile:v 3 -c:a pcm_s24le movie-file.mov

Permanently turn off graphics

 If you are running linux as a server, you do not need graphics wasting RAM. vi /etc/default/grub replace "splash" with "text" update-grub systemctl enable multi-user.target --force systemctl set-default multi-user.target systemctl set-default multi-user systemctl isolate multi-user.target gnome-session-quit systemctl stop gdm systemctl disable gdm apt remove gdm