rygel: Disable inactivity timeout when streaming video

This script demonstrates how to disable system inactivity timeout in Gnome when running Rygel and restore it to the original value after exiting:

#!/bin/bash

# Save current inactivity timeout
TIMEOUT=$(gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout)
echo "Current timeout: $TIMEOUT"

# Execute commands on Ctrl + C
function ctrl_c() {
  echo "Exiting rygel..."
  gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout $TIMEOUT
  echo "Inactivity timeout restored to $TIMEOUT. Bye!"
  sleep 2
}

# Set the trap for Ctrl+C
trap ctrl_c INT

# Disable the inactivity timeout
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0

# Briefly start rygel to allow it to add new files
timeout 2s rygel

# Run command to fix filenames
rygel-titlefix

# Actually run rygel
rygel

| 17 Jul 2023

Monitor number of open sockets by a process

Example with watch command:

watch -n 1 'ps aux | kazy -i cmproxy -e kazy | kazy -r "[\d]+" -x | xargs -I % ls -l /proc/%/fd/ | kazy -i socket | wc -l'

Example with ttyplot command:

{ while true; do ps aux | kazy -i cmproxy -e kazy | kazy -r "[\d]+" -x | xargs -I % ls -l /proc/%/fd/ | kazy -i socket | wc -l; sleep 1; done } | ttyplot
| 16 Apr 2023

Monitor DNS query time

{ while true; do dig google.com | kazy -i "Query time" | kazy -r -x "[\d.]*"; sleep 1; done } | ttyplot -t "dig to google.com"
| 12 Apr 2023

Plot real time ping data in terminal

Install ttyplot:

grm install tenox7/ttyplot -n ttyplot

Ping plot:

ping 8.8.8.8 | sed -u 's/^.*time=//g; s/ ms//g' | ttyplot -t "ping to 8.8.8.8" -u ms

More examples

| 12 Apr 2023

Monitor all http traffic in wireshark on specific ports

Open wireshark GUI as root user:

sudo wireshark

Start capturing by clicking Capture button and add the following display filter:

http and (tcp.port == 8082 or tcp.port == 8000)
| 29 Mar 2023

git: How to remove submodule pointer update in pull request

Case 1: it is done in a separate commit:

  • rebase on a base branch git rebase -i <base_branch>
  • in the editor, find the commit which updates the pointer and remove it from history (by replacing pick with d)
  • force push it when the rebase is done

Case 2: it is done in the commit which contains other changes

  • rebase on a base branch git rebase -i <base_branch>
  • in the editor, find the commit which includes the pointer update and mark it for editing (by replacing pick with e)
  • git will start rebasing the code and will stop on selected commit for editing
  • unstage the change git restore --staged <path_to_submodule>
  • continue the rebase git rebase --continue
  • force push it when the rebase is done
| 29 Mar 2023

HUNT 44 Aerodynamicist Carbon Disc Wheelset

HUNT 44 Aerodynamicist Carbon Disc Wheelset product page

Max tyre pressure is 6.9 bar (100 psi). Recommended tyre pressure:

  • for 28 mm tyres: 5.4 bar (max 6.9 bar)
  • for 30 mm tyres: 4.7 bar (max 4.8 bar)
| 4 Mar 2023

Make port available as unix socket

socat UNIX-LISTEN:/var/run/hapee-lb.sock,mode=666,fork TCP-CONNECT:127.0.0.1:1936

Will create /var/run/hapee-lb.sock file which forwards all input to 127.0.0.1:1936. fork parameter will allow it to handle connection close and accept more than 1 request

| 13 Feb 2023

git: Cherry-pick branch

Very useful command to cherry pick the whole branch

git cherry-pick 751a77^..8b62f1

^ - means the the first commit will be included too

| 3 Nov 2022

Use Github Desktop with pre-commit hooks with husky

If your repository has an installed pre-commit hook which uses husky or anything similar and you use Github Desktop for linux installed via flatpak it won’t work. The reason for this is that flatpak environment doesn’t have all necessary dependencies (npx, husky and etc.). There is a way to mount parts of your host file system to the flatpak environment (with --filesystem flag), but it excludes all sensitive folders (including /usr/bin/). A possible solution would be to mount the content of /usr/bin/ to a custom folder in flatpak environment and override PATH environmental variable. But the quick fix for now is to just disable it:

flatpak override --user --env=HUSKY=0 io.github.shiftey.Desktop
| 5 Sep 2022