Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, February 22, 2026

ssh keys usage reminder (simplest home case)

* ssh key setup
** generate
example for github:
ssh-keygen -t ed25519 -C "your_email@example.com"
** client .ssh/config (private key per host)
Host deck
IdentityFile /home/user/.ssh/mydeck
Host github.com
IdentityFile /home/user/.ssh/mygithub
** remote host (server): .ssh/authorized_keys
Copy .pub key contents there.

Monday, February 16, 2026

Minimal script to limit traffic to vpn tunnel using ufw

Having ufw installed, execute the following script with sudo: 

 

ufw --force reset

ufw default deny outgoing
ufw default deny incoming

ufw allow out on tun0 from any to any
# for seeding
ufw allow in on tun0 from any to any


# vpn server ip
#ufw allow out from any to 123.123.123.123
#ufw allow out from any to 123.123.123.0/24
#ufw allow out 1198/udp
#ufw allow in 1198/udp
ufw allow out 1194/udp
ufw allow in 1194/udp

ufw enable
ufw status verbose

Monday, October 13, 2025

Install debian on encrypted volume

See https://www.blakecarpenter.dev/installing-debian-on-existing-encrypted-lvm/ The main points:
- expert install
- "Load installer components from CD. From here, you want to select crypto-dm-modules and rescue-mode."
- ctrl+alt+f2 to jump into a shell
- depmod -a
- cryptsetup luksOpen /dev/sda3 debian-crypt
- vgchange -ay
- ls /dev/mapper
control debian-crypt debian-home debian-root debian-swap
- "Hit ctrl+alt+f1 to return to the Debian installer and continue to Partition disks. Select Manual."
- setup partitions/mount points
- stop before Install the GRUB bootloader to a hard disk. ctrl+alt+f2 to jump into a terminal.
- blkid
- nano /target/etc/crypttab
debian-crypt UUID=98...eaa none luks
- "Continue to the end of the installation. When the generating initramfs step appears, the image will be built using the crypttab file you just modified."  

Saturday, October 11, 2025

USB Audio not detected after resume. Edifier M60.

Sometimes USB audio device (e.g. Edifier M60 speakers via usb-c connection) is not detected after resume, or after repluging, although
aplay -l
lists the device, the pipewire server does not add it. Restart pipewire:
systemctl --user restart pipewire
If the former does not help, try the following instead:
systemctl --user restart pipewire pipewire-pulse wireplumber

Tuesday, July 29, 2025

Fix thinkbook 13s ITL2 headphones noise

echo "0x1d 0x707 0x0" > /sys/class/sound/hwC0D0/init_verbs

Sunday, April 27, 2025

Fedora drivers

Install rpm-fusion package. Install mesa...freeworld drivers.

Sunday, February 11, 2024

Transcoding with intel quicksync (qsv) h264 -> hevc

Convert on hardware from h264 to h264 full hd, also compress audio to AAC to make a common .mp4 file.
#!/bin/env bash
# usage: enc.sh <source_file> <quality, e.g. 25, 1..51>
# https://trac.ffmpeg.org/wiki/Hardware/QuickSync
# accepts h264 and transcodes on hardware, tested.
ffmpeg -hwaccel qsv -c:v h264_qsv -i "$1" -init_hw_device qsv:hw -vf 'scale_qsv=1920:1080' -c:a aac -b:a 192K -c:v h264_qsv -global_quality:v $2 -preset:v 1 -profile:v 77 "$1-h264-aac-qsv-1080p-$2.mp4"
Convert to hevc/h265:
#!/bin/env bash
# usage: enc.sh <source_file> <quality, e.g. 25, 1..51>
# https://trac.ffmpeg.org/wiki/Hardware/QuickSync
# accepts h264 and transcodes on hardware, tested.
ffmpeg -hwaccel qsv -c:v h264_qsv -i "$1" -c:v hevc_qsv -global_quality:v $2 -preset:v 1 -profile:v 1 -c:a libopus -b:a 96K "$1-hevc-qsv-$2.mkv"
Encode to VP9 (in software):
#!/bin/env bash
# usage: enc.sh <source_file> <quality, e.g. 30, 0..63>
# https://trac.ffmpeg.org/wiki/Encode/VP9
ffmpeg -i "$1" -c:a libopus -b:a 96K -c:v libvpx-vp9 -b:v 0 -crf $2 -pass 1 -an -f null /dev/null
ffmpeg -i "$1" -c:a libopus -b:a 96K -c:v libvpx-vp9 -b:v 0 -crf $2 -pass 2 "`basename $1`_vp9tp_$2.webm"

Saturday, September 9, 2023

Kensington Expert Mouse Linux config

#!/bin/bash
# 

LEFT_HANDED=""

show_help() {
  echo "Usage: [--left]"
  echo "--left = use lefthanded config"
  exit 1
}

parse_args() {
while [[ $# -gt 0 ]]; do
  case $1 in
    --left)
      LEFT_HANDED="yes"
      shift
      ;;
    *)
      show_help
      ;;
  esac
done
}

parse_args $@

MOUSE_NAME="Kensington Expert Mouse"
CHECK=$(xinput | grep "$MOUSE_NAME")

set -e

echo "check=$CHECK"

if [[ -z "$CHECK" ]]; then
    echo "Cannot find the device: $MOUSE_NAME"
    exit 1
fi

TRACKBALL_ID=$(xinput | grep "$MOUSE_NAME" | sed 's/^.*id=\([0-9]*\)[ \t].*$/\1/')

LEFT_TOP=2
LEFT_BOTTOM=1
RIGHT_TOP=8
RIGHT_BOTTOM=3
SCROLL_CLOCKWISE=5
SCROLL_COUNTERCW=4

# LB, LT, RB, SCCW, SCW, 6, 7, RT

MOUSE_LEFT=1
MOUSE_MIDDLE=2
MOUSE_RIGHT=3

# ---

# make scrolling with the ball smooth
SCROLLING_PIXEL_DISTANCE=50

# X clients receive events with logical button numbers, where 1, 2, 3 are usually interpreted as left, middle, right and logical buttons 4, 5, 6, 7 are usually interpreted as scroll up, down, left, right. The fourth and fifth physical buttons on a device will thus send logical buttons 8 and 9. The ButtonMapping option adjusts the logical button mapping, it does not affect how a physical button is mapped to a logical button.

if [[ -n $LEFT_HANDED ]]; then
    echo "using lefthanded config"
    SCROLLING_BUTTON=$RIGHT_TOP
    # LB, LT, RB, SCCW, SCW, 6, 7, RT
    BUTTON_MAP="$MOUSE_MIDDLE $MOUSE_RIGHT $MOUSE_LEFT 4 5 6 7 8"
else
    # right hand settings
    SCROLLING_BUTTON=$LEFT_TOP
    # LB, LT, RB, SCCW, SCW, 6, 7, RT
    BUTTON_MAP="$MOUSE_LEFT 8 $MOUSE_MIDDLE 4 5 6 7 $MOUSE_RIGHT"
fi

# -------
xinput set-prop $TRACKBALL_ID "libinput Scrolling Pixel Distance" $SCROLLING_PIXEL_DISTANCE
xinput set-prop $TRACKBALL_ID "libinput Button Scrolling Button" $SCROLLING_BUTTON
xinput set-prop $TRACKBALL_ID "libinput Scroll Method Enabled" 0, 0, 1
xinput set-button-map $TRACKBALL_ID 1 2 3 4 5 6 7 8 9
echo $BUTTON_MAP
xinput set-button-map $TRACKBALL_ID $BUTTON_MAP

Monday, July 24, 2023

BIOS update from Linux for Lenovo Thinkbook 13s g2 itl

You need to download intel ME driver, BIOS and ME firmware update installers: https://pcsupport.lenovo.com/lt/en/products/laptops-and-netbooks/thinkbook-series/thinkbook-13s-g2-itl 

Download windows 10 iso: https://www.microsoft.com/en-us/software-download/windows10ISO

Then you need wine to run those installers in Wine, select "Extract only". Then the installers and firmware apps need to be overlaid on the winpe.iso, which is made from the win10 iso as described there:

https://wiki.archlinux.org/title/Windows_PE

Then you mount winpe.iso and copy all the files to the FAT32 root partition on the USB flash. Copy EFI folder from the original Win10 iso.

After booting to USB flash drive (ENTER, F12) you go to firmware update directory and run respective ...Flash/install.bat

Then you need to enter BIOS Setup (ENTER, F1), and "Load Optimized Defaults".

After that you can update ME firmware the same way, booting from the USB, "...Flash/MEUpdate.bat"


Saturday, December 17, 2022

High dpi displays better solution for laptops for Linux

 Instead of modifying each font size, it turned that adjusting only font scaling is enough.

In KDE it's "Fonts - System settings" -> "Force font DPI: 144" for 13 inch fullhd screen. Although in this way some apps may scale icons as well, e.g. LibreOffice. But still it's better than display scaling setting, which brakes some apps like Steam and games.

Friday, November 11, 2022

High dpi displays, laptops and scaling in Linux

As of November 2022 there's no proper/flawless support for "fractional" (125%, 150% etc) scaling of the GUI on the Linux desktop. Yes there is good support in KDE, but still some apps (e.g. darktable, steam) either ignore or wrongly position control elements on the screen. And there's no proper support for multiple displays with different dpi (as far as I know it's a limitation of X11).

If you have a laptop with small physical screen but higher pixel count (e.g. 13" 1920x1200), then i found the only working solution -- adjust fonts size and use some settings inside the applications to increase readability, e.g. set default zoom size to 150% in Firefox, set bigger fonts in the terminal emulator, set bigger fonts in the VSCode preferences etc, set 150% scaling in the Telegram app preferences... But this will not allow for different scaling for the external monitor.

If you plan to buy a laptop with small physical screen, look for either a 1280x800 screen or an integer multiplier of it, e.g. 2560x1600, it's what the Apple laptops have -- they do not support fractional scaling, but the display resolution is twice as large as a previously common one. By the way 16" macs with 4K displays have higher dpi than previous 2560x1600, so the texts are uncomfortably smaller and there's no solution to it at all.

If you plan to use a multiple display configuration, make sure that displays have the same or at least close DPI value.

Wednesday, October 19, 2022

android file transfer on linux (mtp)

mtp through kde is not working properly, so use:

 sudo apt-get install android-file-transfer

Saturday, August 27, 2022

Steam on Linux xbox controller troubleshooting

If the gamepad is not detected or controller buttons are not working as expected in the game  try to use the following settings.

Right click on game name in the list, choose CONTROLLER tab, click Controller General Settings, mark "Xbox configuration support", click "Back". In the OVERRIDE FOR <game name> select "Use default settings". In the list below: Xbox Controller Enabled, default setting.

In the GENERAL tab make sure "Enable the Steam Overlay while in-game" is enabled (click to trigger it off/on just to make sure it works).

Now games such as Blasphemous, Broforce will work with the gamepad as expected.

Saturday, June 25, 2022

neovim setup for development, beancount

https://neovim.io/ -- use tar with linux binaries or compile from source (not checked).

Install packer: https://github.com/wbthomason/packer.nvim

Setup lspconfig: https://github.com/neovim/nvim-lspconfig

run :PackerSync on changes to plugins.lua

setup https://github.com/matze/beancount-language-server

pip install neovim

Use CTRL-X-CTRL-O in insert mode.

Wednesday, May 11, 2022

flatpak: cannot add flathub repo on kubuntu 20.04 LTS: TLS support is not available

error: Can't load uri https://flathub.org/repo/flathub.flatpakrepo: TLS support is not available
 

Fix: need to set env. var:

 GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ flatpak -v remote-add --if-not-exists flathub
https://flathub.org/repo/flathub.flatpakrepo

Sunday, May 8, 2022

XMP metadata manipulation

Add a new tag into existing subject tags in the .xmp sidecar:

exiv2 -M 'set Xmp.digiKam.TagsList my-new-tag'  mo xxx.JPG.xmp

exiv2 -M 'set Xmp.dc.subject my-new-tag'  mo xxx.JPG.xmp

 

Print specific tag:

exiv2 -g TagsList pr xxx.JPG.xmp
 

Monday, April 11, 2022

Ventoy: multiple ISO images from usb to boot

Install Ventroy on a usb, normally copy ISO files to the drive, boot.

https://www.ventoy.net/en/index.html

Sunday, February 20, 2022

ubuntu snap apps lacking proper fonts

 https://askubuntu.com/questions/1224125/font-characters-displayed-as-squares-in-ubuntu-18-04

rm -rf ~/.cache/fontconfig 
sudo fc-cache -r -v 
 
Delete every found fontconfig folder from the snap cache, e.g. 
find ~/snap/chromium/ -name 'fontconfig'
rm -rf ~/snap/chromium/common/.cache/fontconfig/  

 

Monday, November 15, 2021

TP-Link Archer T9UH v1 [Realtek RTL8814AU] driver

 TP-Link Archer T9UH v1 [Realtek RTL8814AU] driver is at https://github.com/aircrack-ng/rtl8814au.git

Monday, November 1, 2021

Thinkbook 13s ITL G2 headphones hissing sound, noise fix

Kubuntu 20.04 LTS

Problem: wired headphones reproduce constant hissing sound, noise changes with the cursor movement etc.

Solution:

 sudo hda-verb /dev/snd/hwC0D0 0x1d SET_PIN_WIDGET_CONTROL 0x0

 

Sources:

https://www.reddit.com/r/thinkpad/comments/8j8208/audio_crackling_through_both_headphone_jack_and/

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1805079/comments/20