Hexa's Blog

Optimizing MPV for Wayland and Nvidia

15/08/2025 @ Saigon Linux

I. What is it?

MPV is my favorite open source media player. On Fedora 42, the default display manager is Wayland (as a replacement for X11). MPV does not play well with Wayland, playing videos is delay/lagging. In addition, I am using an NVIDIA graphic card 3080. it could be a reason that my video playing is delay.

This post is all about customize mpv’s flags to work with Wayland and NVIDIA graphic card.

II. How to do?

Go to ~/.local/share/applications and create a new file named mpvfast.desktop.

[Desktop Entry]
Type=Application
Name=mpv (Fast Mode)
Exec=mpv --gpu-context=wayland -vo=gpu --video-sync=display-resample --profile=gpu-hq --hwdec=auto --demuxer-max-bytes=8G %U
Icon=mpv
Terminal=false
Categories=AudioVideo;Player;Video;
MimeType=video/x-matroska;video/mp4;video/x-msvideo;video/webm;audio/mpeg;audio/x-flac;audio/x-wav;
  • --gpu-context=wayland: Tells mpv to create its GPU rendering context using Wayland APIs instead of X11, SDL, or other backends.
  • -vo=gpu: select GPU as video output
  • --video-sync=display-resample: Syncs video playback to the display refresh rate and dynamically resamples audio to keep A/V in perfect sync.
  • --profile=gpu-hq: GPU high quality — enables higher-quality scaling algorithms
  • --hwdec=auto: Enables automatic hardware video decoding if available.
  • --demuxer-max-bytes=8G: The demuxer buffer is where mpv stores pre-read data from a file/network before decoding.

Then execute update-desktop-database to update desktop.

$ update-desktop-database ~/.local/share/applications

III. Credit

Thank for ChatGPT, it helps me so much! I can’t understand all 1250 options of MPV.

Compressing image directly on Fedora's Nautilus (File Explorer)

15/08/2025 @ Saigon Linux

I. What is it?

This post is all about compressing image on Gnome Desktop Environment with GUI. This is core script

ffmpeg -i "$img" -q:v 4 "$output_dir/$filename"

-q:v 4: refers to quality for video. It’s value range is 1-31, the smaller this value is, the higher the quality.

There are two way to executable the script

  • [1] Open gnome-terminal and execute script.
  • [2] Open nautilus (default file explorer on GNOME).

In addition, to enhance user experience, I used zenity to display progress bar.

II. How to do?

  • Create a file named 01-compress-images.sh at ~/.local/share/nautilus/scripts/
#!/bin/bash
input_dir="$1"
output_dir="${input_dir}_compressed"
mkdir -p "$output_dir"

shopt -s nullglob
files=("$input_dir"/*.{jpg,jpeg,png,webp})
total=${#files[@]}
count=0

(
for img in "${files[@]}"; do
    [ -f "$img" ] || continue
    filename=$(basename "$img")
    ffmpeg -i "$img" -q:v 4 "$output_dir/$filename" &>/dev/null
    count=$((count+1))
    echo $(( count * 100 / total ))
    echo "# [$count/$total] Compressing: $filename"
done
) | zenity --progress --title="Compress Images" --percentage=0 --auto-close

zenity --info --text="Finished! Compressed images stored at:\n$output_dir"
  • Use chmod to make 01-compress-images.sh executable.
$ chmod +x 01-compress-images.sh

III. Result

IV. Credit

Thank to ChatGPT, It helps me so much!

How to generate UUID in Libreoffice Calculator/Excel?

10/07/2025 @ Saigon etc

LibreOffice Calc & UUID formula
LibreOffice Calc & UUID formula

In this post, I would like to make a note about generating UUID in Libreoffice Calc/Excel.

=LOWER(CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",DEC2HEX(RANDBETWEEN(0,65535),4),"-",DEC2HEX(RANDBETWEEN(0,65535),4),"-",DEC2HEX(RANDBETWEEN(0,65535),4),"-",DEC2HEX(RANDBETWEEN(0,4294967295),8),DEC2HEX(RANDBETWEEN(0,65535),4)))

References

Fedora, Change directory quickly with autojump

13/06/2025 @ Saigon Linux

Why do I create this post?

Damn man, I really expected that after install dnf install autojump-zsh, everything should run without any modification, I can start using j command. But no, command j not found. This post is all about installing autojump on Fedora.

Each user has their favorite shell, I am using zsh. this guide is all about setup autojump on zsh. The methodology is the same for fish or bash.

How to install

Step 1: Install dnf install autojump-zsh -y

$ sudo dnf install autojump-zsh -y
# Output
Updating and loading repositories:
Repositories loaded.
Package                                  Arch              Version           Repository        Size
Installing:
 autojump-zsh                            noarch            22.5.3-17.fc41    fedora         2.8 KiB
Installing dependencies:
 autojump                                noarch            22.5.3-17.fc41    fedora        93.2 KiB

Transaction Summary:
 Installing:         2 packages

Complete!

Step 2: Find installed file location rpm -ql autojump-zsh

$ rpm -ql autojump-zsh
# Output
/usr/share/autojump/autojump.zsh
/usr/share/zsh/site-functions/_j

Step 3: Load autojump.zsh when start terminal

I am using zsh, it means that I need modify ~/.zshrc and append source /usr/share/autojump/autojump.zsh.

It will load autojump.zsh when terminal start.

# File ~/.zshrc

source /usr/share/autojump/autojump.zsh

Good luck, have fun!

Firefox on Wayland, can't do mouse click

12/06/2025 @ Saigon Linux

Hi, I am running Firefox on Fedora 41, my display manager is wayland by default. While using Firefox, sometime, I can’t do mouse click on Firefox. This post will help you save 5 minutes.

First of all, the key point here is environment variable MOZ_ENABLE_WAYLAND=1. We need it before running firefox.

You can test by running this command. If it works, you can read futher, else, stop wasting your time reading my post.

$ export MOZ_ENABLE_WAYLAND=1
$ firefox

I assume that you have play with your firefox smoothly. Now, we will edit .desktop file. So what is it? it’s a application shortcut for GNOME. You can find it /usr/share/applications.

$ ll /usr/share/applications  | grep firefox
-rw-r--r--. 1 root root 9.4K Jun 12 11:16 org.mozilla.firefox.desktop

Now, edit /usr/share/applications/org.mozilla.firefox.desktop, add env MOZ_ENABLE_WAYLAND=1 on Exec= line. Remember that there are many places need to update.

Example:

# Before
Exec=firefox %u

# After
Exec=env MOZ_ENABLE_WAYLAND=1 firefox %u

Done, and good luck!

References:

How to fix ssh: connect to host github.com port 22: Connection timed out

09/06/2025 @ Saigon Linux

At first, let make it clear! on May 25th, vietnamese goverment started blocking telegram.

As a consequence, I have to use CloudFlare WARP to dogde it. It’s fine till I have trouble pushing/cloning my source code to github. I am pretty sure that CloudFlare did something as a middle man!

$ ssh -T git@github.com
# ssh: connect to host github.com port 22: Connection timed out

So, there are two choices:

  • [1] Turn off cloudflare’s warp client
  • [2] Change github ssh port from 22 to 443

This post is all about the second solution. Do ssh to ssh.github.com port 443 instead of github.com port 22.

If you run ssh -T -p 443 git@ssh.github.com and it works, you can continue reading this post. Else, this post is not for you cause ssh.github.com port 443 is also BLOCKED.

$ ssh -T -p 443 git@ssh.github.com
# Hi nguyenvinhlinh! You've successfully authenticated, but GitHub does not provide shell access.

If you see that message Hi nguyenvinhlinh! You've successfully authenticated, but GitHub does not provide shell access. You can alias ssh’s config and work around ssh's port 22, connection timeout error.

I will make it short! Edit file ~/.ssh/config with the following config.

Host github.com
Hostname ssh.github.com
Port 443

And test it with: ssh -T git@github.com. You should see output like:

Hi nguyenvinhlinh! You've successfully authenticated, but GitHub does not provide shell access.

Good luck!

References

How to install phx_new manually from source code?

05/06/2025 @ Saigon Elixir

Before going further, you must prepare your dev environment. I choose asdf - version manager. This is my .tool-versions

erlang 28.0
elixir 1.18.4

1. Clone the source code

In this post, I choose the latest version v1.8.0-rc.3

$ git clone --depth 1 --branch v1.8.0-rc.3 git@github.com:phoenixframework/phoenix.git

2. Go to directory phoenix/installer and build

$ cd phoenix/installer;
$ MIX_ENV=prod mix archive.build;
# Output
Compiling 11 files (.ex)
Generated phx_new app
Generated archive "phx_new-1.8.0-rc.3.ez" with MIX_ENV=prod

3. Install archive

$ mix archive.install phx_new-1.8.0-rc.3.ez
# Output
Are you sure you want to install "phx_new-1.8.0-rc.3.ez"? [Yn] Y
* creating /home/nguyenvinhlinh/.asdf/installs/elixir/1.18.4/.mix/archives/phx_new-1.8.0-rc.3


$ mix phx.new --version
# Output
Phoenix installer v1.8.0-rc.3

4. How to remove phx_new

$ mix archive.uninstall phx_new

Mkdocs, How to maximize content space width?

03/06/2025 @ Saigon etc

This post is all about maximize content space for Mkdocs sites. The main solution is to override css and set max-width: 100%;

1. Create docs/style.css

.md-grid {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

2. Modify mkdocs.yml to use docs/style.css

extra_css:
  - style.css
[1] Before maximize content space/width
[1] Before maximize content space/width
[2] After maximize content space/width
[2] After maximize content space/width

Thông số dây AWG

28/05/2025 @ Saigon etc

AWG Code Max(A)   AWG Code Max(A)
10 55      
-—- -—-   -—- -—-
11 47   21 9
12 41   22 7
13 35   23 4.7
14 32   24 3.5
15 28   25 2.7
-—- -—-   -—- -—-
16 22   26 2.2
17 19   27 1.7
18 16   28 1.4
19 14   29 1.2
20 11   30 0.86

Câu hỏi và trả lời

1. Thông số Max(A) này là cột nào trong https://www.powerstream.com/Wire_Size.htm?

Tôi sử dụng cột Maximum amps for chassis wiring

2. Chassis Wiring là gì?

Chassis Wiring – Dây trong thiết bị/bo mạch (nội bộ).

Ứng dụng: Bên trong tủ điện, thiết bị điện tử, bảng mạch, bo mạch nguồn.

3. Power Transmission Wiring là gì?

Power Transmission – Truyền tải điện (ngoài trời hoặc công nghiệp)

Ứng dụng: Dây điện trong nhà, ngoài trời, hệ thống cấp điện công nghiệp, trạm biến áp.

4. Tại sao có sự khác biệt lớn đến như vậy giữa "Maximum amps for chassis wiring""Maximum amps for power transmission"?

Tóm tắt lại sau cùng là vì vấn đề sinh nhiệt.

Chassis Wiring – Dây trong thiết bị/bo mạch (nội bộ)

Mức dòng (amps) cao hơn

  • Chiều dài dây thường rất ngắn, nên điện trở tổng thể thấp ==> tổn thất điện năng và sinh nhiệt ít.
  • Lắp đặt trong môi trường có thể kiểm soát, chẳng hạn như bên trong hộp kim loại, thiết bị điện tử, nơi đã được tính toán kỹ về tản nhiệt.
  • Được thiết kế chịu tải trong thời gian ngắn, rất ngắn ==> không gây nguy cơ cháy nổ

Power Transmission – Truyền tải điện (ngoài trời hoặc công nghiệp)

Mức dòng (amps) thấp hơn do:

  • Chiều dài dây rất dài, tăng điện trở ==> tăng nhiệt ==> nguy cơ cháy hoặc hỏng cách điện.
  • Dây thường được bó lại hoặc đi qua ống, làm giảm khả năng tản nhiệt.
  • Yêu cầu độ an toàn và ổn định cao, vì đây là hệ thống truyền tải điện liên tục.
  • Có thể đi qua môi trường khắc nghiệt, nên cần giới hạn dòng để đảm bảo độ bền dây lâu dài.

References

ESP32, DoIt Devkit V1 Pinout

20/05/2025 @ Saigon ESP32

[1] ESP32, DoIt Devkit V1 PINOUT
[1] ESP32, DoIt Devkit V1 PINOUT

References