Peter Bohner

Notes

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.


  1. a surprisingly long list. I remember using: gnome-terminal, konsole, urxvt, st, alacritty, foot and ghostty. ↩︎

  2. that said, he who lives in a glass house… ↩︎


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

  1. Press the 3rd button from the left until the display shows “00000”
  2. 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

source


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

source


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