These are collections of useful snippets I have collected over the years.
All on one page, for easy Ctrl+F searching.
Fix GhosTTY middle-click/primary Paste
gsettings set org.gnome.desktop.interface gtk-enable-primary-paste true
After an update, middle-click (primary) copy & paste stopped working in ghostty, because gnome decided to disable the primary clipboard by default. Since ghostty is the only gtk4 application I use, this change caught me by surprise. Luckily, the GitHub discussion was easily findable.
Rant
This is the second time in a couple of months that the way I interact with my terminal has been broken. Things like this must not happen, and I am slightly annoyed that in my 11 years of using Linux, my all my terminal emulators1 had done their job for a decade, only for it to break twice in a couple of months. Software is information, it should not break2.
Fix Compose key not working in GTK4 applications (esp. GhosTTY) on KDE
IBus is now required for GTK4 applications to work. sudo pacman -S ibus,
then logout and back in. Afterwards set System Settings -> Keyboard -> Virtual Keyboard to
none, apply, then set to IBus Wayland.
Sidenote/rant: Breaking USER INPUT is not acceptable.
Open Fronius Inverter Service Menu
- Press the 3rd button from the left until the display shows “00000”
- Then enter the service code: 77634
Growatt online Service Key
Current date in format: %Y%m%d use ~$ date '+%Y%m%d' to compute.
For example 20230102 for the January 2, 2023.
Fix user not showing up in KDE settings
sudo qdbus --system --literal org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.CacheUser $USERNAME
Automatically log into a tmux session
Put this at the end of your shell configuration file (.bashrc or .zshrc)
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
if tmux list-sessions > /dev/null; then
exec tmux attach
else
exec tmux
fi
fi
This snippet will attach to an existing session, or create a new one unless you are already inside a TMUX or screen session.
NixOS: Run shell scripts with dependencies
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cowsay lolcat
echo CoOoOoL! | cowsay | lolcat
Total number of pages in PDF documents
requires: poppler_utils, bc
find . -name '*.pdf' -exec pdfinfo {} \; | grep Pages: | grep -Eo '[0-9]+' | paste -s -d + - | bc
Get drive temperatures of all SATA HDDs
as root:
for i in /dev/sd?; do echo "$i: $(smartctl -A $i | grep Celsius | cut -d '-' -f 2)" ; done