Tag: linux

  • Rapidly reduce the size of a PDF

    I am sure you have been there before, trying to submit an important form and your PDF with high resolution scans is too big to be accepted.

    As you probably entered a lot of other data, you do not want to repeat the entire form if the page times out (which they seem to always do!).

    This is an instant one-liner that substantially reduces the PDF size without much quality degradation (my PDF went from 8.9 MiB to 1.1 Mib):

    gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
    -dPDFSETTINGS=/ebook \
    -dNOPAUSE -dQUIET -dBATCH \
    -sOutputFile=output.pdf input.pdf

    There are tons of options and parameters in Ghostscript to play with if you are interested, but the above will work for a start. Simply edit the input.pdf and output.pdf paths/files.

  • Toolbx mount access from host on Fedora Kinoite

    Since Toolbx mounts are running in different namespaces than the host, the mounts cannot be accessed from the latter. I tried many workarounds to see if it really was possible to get around this limit. After some time I decided that using the network stack was probably a better solution to communicate between Toolbx and host.

    In my particular case I never do any layering but instead try to use Flatpak, Toolbx, or even a Boxes virtual machine for any specific software not included in the base layering.

    I needed to run restic to access some documents on a remote restic repo backup. Since restic is not included I had to use Toolbx for this task. Restic uses FUSE to mount the remote end on the local system. In an ideal world I could just have opened this mount in Dolphin to search and open the needed documents. However due to the namespaces difference this mount just shows empty on the host.

    A really quick and dirty solution is to simply use rclone and its webdav option, then Dolphin just opens the webdav address with no issues. Yes, there is a tiny performance hit, but the speed and easy execution greatly makes up for this:

    restic mount ~/remote-restic

    Now that the mount is working from Toolbx itself run rclone to serve it over the network:

    rclone serve webdav ~/remote-restic --addr :8080 -L

    That is all! Now simply open Dolphin and paste the webdav address and there you have your Toolbx mount visible from the host:

    dav://127.0.0.1:8080

    Please note that this is not only for restic but can be used with any mount type like sshfs or even another rclone mount like S3.

    Is it not ironic… using a 1990s protocol (WebDAV) to solve a 2026 container problem!

  • KDE Plasma sunrise (bright) & sunset (dark) theme automatic switch

    Under System Settings > Appearance & Style > Colours & Themes > Night Light in KDE Plasma there is the expected option to automatically switch at specific times between cool and warm colour temperature for the screen. I marked my location on the map and selected Sunset and sunrise at manual location to take care of the switch automatically. This works perfectly!

    For whichever reason, and there is many, KDE Plasma cannot do the same with the bright and dark theme. This is such a miss that one wonders how anything ever gets agreed upon in large open source projects such as KDE in this case. Gnome supports the option as many other.

    As there are more ways than one to skin a cat, I had several choices to work around this missing feature. I was really looking for something quick and dirty, nothing to install and trust, and easy to undo if needed.

    I decided to use the colour temperature as an indicator of when the bright or dark theme was needed. So at 6500 K it was the cool day light temperature and the bright theme should be used. On the contrary anything below this temperature, that is warm night light, should use the dark theme. Then I would simply check for this system value at a set interval and change the theme if it changed. This simple script is placed in the System Settings > System > Autostart section as an Application and it will launch upon boot and run in the background. Copy or download & unzip the below file and remember to make the .sh file executable:

    #!/bin/bash

    current_theme=""

    while true; do
    # Retrieve the current temperature from KWin using dbus-send
    temperature=$(dbus-send --session --dest=org.kde.KWin --type=method_call --print-reply \
    /org/kde/KWin/NightLight org.freedesktop.DBus.Properties.Get string:org.kde.KWin.NightLight string:currentTemperature \
    | grep -oP 'variant\s+uint32\s+\K\d+')

    # Decide the target theme based on the temperature
    if (( temperature == 6500 )); then
    target_theme="org.fedoraproject.fedora.desktop" # Light theme for == 6500
    elif (( temperature < 6500 )); then
    target_theme="org.kde.breezedark.desktop" # Dark theme for < 6500
    fi

    # Switch theme only if it's different from the current one
    if [[ "$target_theme" != "$current_theme" ]]; then
    lookandfeeltool -a "$target_theme"
    # Update the current theme to the new one
    current_theme="$target_theme"
    # KDE notification
    notify-send "Theme Switcher" "Switched to $(basename "$target_theme") theme."
    fi

    # Sleep for 15 minutes (900 seconds)
    sleep 900
    done

  • Empty Trash from the terminal

    For some reason I can not recall I went into my Trash bin on Fedora. There was unsurprisingly a lot of trash!

    I decided to empty the Trash bin but it only succeeded partially. I had a DVD directory that did not want to be deleted. Looking closer at the message it was a permissions error. Not sure how though, since if I did not have permissions to delete the directory from the Trash bin, how on Earth could I have moved it into the Trash bin to start with…!

    Looking around my home directory in the terminal I could not locate the exact spot to manually remove the directory. As always Google came to assistance and brought up a nice forum topic about how to empty the Trash bin in Fedora from the terminal.

    The simplest way would be to run the following command as root:

    rm -rf  ~/.local/share/Trash/files/*

  • Console recursive FTP client

    Sometimes data needs moving from server to server without FXP support. For this task there is nothing simpler than good old FTP.

    What about if you have a large number of subdirectories? As the plain FTP client can not fetch the files recursively shell scripting is usually the solution. But in cases where you do not really know neither the depth of the recursion or the naming convention of the file system structure, an alternative method is needed.

    This method is named NcFTP Client. I got to know about it today as I quickly needed to copy several gigabytes of data spread over several subdirectories and NcFTP did its job flawlessly. I did not even have to install it as Fedora 10 already came with it by default.