Use Vial in Linux Without Configuring udev (and Remain Secure)

Last updated on April 6, 2025

Vial is a GUI program that can configure QMK input devices in real time. In Linux, the default configuration usually stops Vial from accessing the input devices. The official document suggests configuring udev rules. For someone who doesn't frequently configure via Vial, this seems to be overkilling and a bit insecure. After all, it opens up the access to the input devices to the user indefinitely, which may be exploited by malicious software.

In this post, I discuss a method that uses Vial in Linux without configuring udev. I believe this method is more secure than configuring udev. Furthermore, this method is arguably more convenient if you only use Vial occasionally.

Continue reading

Quickly Switch Between HTML and Plain Text in mu4e

Last updated on December 29, 2024

Mu4e defaults loading messages in HTML with shr. While this works well most of the time, sometimes a plain text version is more readable. Therefore, it is desirable to create a key binding to switch between these two versions.

I have the following in my Emacs configuration:

;; Quickly switching between plain text and HTML mime type.
(keymap-set mu4e-view-mode-map (kbd "K")
            (lambda ()
              (interactive)
              (gnus-article-jump-to-part 1)
              (gnus-article-press-button)
              (gnus-article-press-button)))

This binds key Shift+K to switch between plain text and HTML versions of a message, if the message has both versions available.

Convert PNG Images To WebP Images Losslessly Using cweb in GNU/Linux

Last updated on October 18, 2024

To losslessly convert a PNG image to a WebP image on GNU/Linux, run the following command:

cwebp -z 9 input.png -o output.webp

9 indicates the best effort to compress the image, resulting in the smallest image size. You can replace 9 with a smaller number if you prefer a less aggressive compression effort.

If you haven't installed cwebp yet, it is available in the webp package in Debian and Ubuntu.

View the TLS Certificate Details of a Website on the Command Line Using GnuTLS

Last updated on December 27, 2023

With GnuTLS, we can view the certificate details of a website with the following commands (replace "example.com" with the website of your interest):

gnutls-cli --print-cert example.com < /dev/null | certtool --certificate-info

In the command above, gnutls-cli --print-cert example.com < /dev/null prints the certificate of the website in PEM format to the standard output. Its output is then sent as the standard input to certtool --certificate-info, which prints information on the given certificate.

Continue reading

Platform Dependent Python Coverage Test with Tox

Last updated on December 20, 2020

When testing Python programs, coverage.py is often used in measuring code coverage, and enforcing 100% code coverage is regarded as a good practice:

# .coveragerc
[coverage:report]
# Enforce 100% coverage test
fail_under = 100
show_missing = True

However, if there are some lines of code that are platform dependent (i.e., they are never executed on at least one platform), code coverage tests usually fail. For example, the following code snippet would always lead to a coverage that is less than 100% on a platform other than Windows:

if os.name != 'nt':
    # Do something if the OS is not Windows...

You can ask coverage.py to ignore this block by adding a comment # pragma: no cover, but then coverage.py would ignore it on all platforms, including all non-Windows platforms. If you use tox for testing, this issue can be resolved cleanly.

Continue reading