Upgrade to fedora 40

Make sure your current system is up to date:

sudo dnf upgrade --refresh

Reboot:

reboot

Install dnf plugin which updates OS:

sudo dnf install dnf-plugin-system-upgrade

Download and prepare packages for upgrade:

sudo dnf system-upgrade download --releasever=40

Reboot and start upgrade process

sudo dnf system-upgrade reboot
| 23 Apr 2024

Fix missing shortcuts in Logitech MX Mechanical Mini in Linux

Logitech MX Mechanical Mini keyboard works mostly great in Linux. However, there are few buttons which don’t: Mic mute, Screenshots, Emoji, Voice dictation. To fix it, install solaar and reboot your computer (important, otherwise the app will hang):

sudo dnf install solaar
reboot

Configuring every button is 2-step process.

On the first step, the button is marked as a custom button (Diverted):

On the second step, click Rule Editor in the bottom left corner and there you can assign a new action to it:

Solaar keeps configuration files in ~/.config/solaar/ directory. Rules are stored in ~/config/solaar/rules.yaml file:

%YAML 1.3
---
- Key: [MultiPlatform Search, pressed]
- KeyPress:
  - XF86_AudioNext
  - click
...
---
- Key: [Voice Dictation, pressed]
- Execute: [firefox, 'https://gemini.google.com']
...
---
- Key: [Snipping Tool, pressed]
- KeyPress:
  - Print
  - click
...
---
- Key: [Open Emoji Panel, pressed]
- Execute: gnome-characters
...
---
- Key: [Mute Microphone, pressed]
- KeyPress:
  - XF86_AudioMicMute
  - click
...

The configuration file is located in ~/.config/solaar/config.yaml and is unique for every keyboard. It contains the keyboard’s name, serial number and etc. Our modified configuration should look like this:

- 1.1.10
- _NAME: MX Mechanical Mini
  _absent: [hi-res-scroll, lowres-scroll-mode, hires-smooth-invert, hires-smooth-resolution, hires-scroll-mode, scroll-ratchet, smart-shift, thumb-scroll-invert,
    thumb-scroll-mode, onboard_profiles, report_rate, pointer_speed, dpi, speed-change, backlight-timed, reprogrammable-keys, persistent-remappable-keys,
    crown-smooth, divert-crown, divert-gkeys, m-key-leds, mr-key-led, gesture2-gestures, gesture2-divert, gesture2-params, sidetone, equalizer, adc_power_management]
  # <redacted>
  _sensitive: {divert-keys: true, multiplatform: false}
  # <redacted>
  backlight: true
  change-host: null
  disable-keyboard-keys: {1: false, 4: false, 8: false, 16: false}
  divert-keys: {212: 1, 226: 0, 227: 0, 231: 0, 232: 0, 233: 0, 259: 1, 264: 1, 266: 1, 267: 0, 268: 0, 269: 0, 270: 0, 271: 0, 272: 0, 273: 0, 274: 0,
    277: 0, 279: 0, 280: 0, 281: 0, 282: 0, 283: 0, 284: 1, 286: 0, 316: 0, 321: 0}
  fn-swap: false
  multiplatform: 0
| 26 Feb 2024

Monitor open connections

This command will plot open connections:

{ while true; do ss -ant | grep ESTAB | wc -l; sleep 0.1; done } | ttyplot
| 24 Feb 2024

dnf: list all dependencies of a package

dnf repoquery --deplist <package-name>
| 6 Nov 2023

How to use Android phone camera on desktop computer via WiFi with IP Webcam

  1. Install IP Camera. The application is free, with minimal adds. Compared to DroidCam, it allows you to stream FullHD video
  2. Install dependencies:
sudo dnf install ffmpeg v4l2loopback akmod-v4l2loopback
  1. Verify that v4l2loopback is loaded:
lsmod | grep v4l2loopback
  1. If it is not loaded, run this command:
akmods --kernels $(uname -r) --rebuild
# Confirm that it was loaded
  1. On mobile phone, start the application and select “Start server” from the menu. Select also “Fade” option to set minimal brightness of the mobile phone screen.
  2. On desktop, run the following command:
ffmpeg -i http://192.168.2.26:8080/videofeed -vf format=yuv420p -f v4l2 /dev/video0

If for some reason v4l2loopback module is not compiled correctly, you can try to compile it manually by following this instruction

| 15 Oct 2023

sumologic: filter fields

(sourceCategory=prod/* ss-haproxy)
| parse "{|||}" as host,forwarded, referer, ua
| where forwarded matches ","
| 5 Sep 2023

Upgrade CentOS Stream 8 to CentOS Stream 9

  1. Update OS
dnf update -y
  1. Reboot system if there were any updates
reboot
  1. Disable CentOS 8-specific modules (they are blocking kernel updates)
dnf module disable python36 virt
  1. Install CentOS 9 repositories. All CentOS 9 packages are listed here
dnf install https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-release-9.0-22.el9.noarch.rpm https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-9.0-22.el9.noarch.rpm https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-9.0-22.el9.noarch.rpm
  1. Run command to switch packages:
dnf --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync -y
  1. Rebuild RPM database (this will chnage the backend to sqlite):
rpm --rebuilddb
  1. Disable subscription manager. Open file /etc/yum/pluginconf.d/subscription-manager.conf and set enabled to 0

  2. Reboot and verify

cat /etc/redhat-release
  1. Verify that the latest kernel is used (5.14+)
uname -a
  1. If not, use grubby to set the latest kernel as the default one, reboot the system and remove old kernels from CentOS 8:
# List all boot options
grubby --info=ALL

# Reflect the desired kernel in configuration
grubby --set-default vmlinuz-<version>.<arch>

# Make sure the index is also set in `/etc/default/grub` file

# Regenerate boot configuration
grub2-mkconfig -o /boot/grub2/grub.cfg

reboot

# Remove old kernels...

The instructions are inspired by CentOS 8 to CentOS Stream 8 migration guide and Fedora upgrade procedure

| 28 Aug 2023

How to use Android phone camera on desktop computer via WiFi with DroidCam

  1. Install DroidCam on your phone. There are free and paid versions. Paid version enables HD quality
  2. Install DroidCam in your desktop:
sudo dnf copr enable meeuw/droidcam
sudo dnf install droidcam
  1. Launch both mobile and desktop applications. Connect desktop client to your phone’s camera (IP address and port are displayed on your phone). Desktop client will connect to your camera via WiFi and create a virtual camera device.

If droidcam doesn’t start with the following error:

$ droidcam
Fatal: droidcam video device reported pixel format 34524742 (BGR4), expected 32315559 (YU12/I420)
Try 'v4l2loopback-ctl set-caps "video/x-raw, format=I420, width=640, height=480" /dev/video<N>'

Run this command:

v4l2loopback-ctl set-caps /dev/video "YU12:640x480"
| 2 Aug 2023

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