Switch NumLock on at startup in Xfce4

There are many ways to switch on NumLock in Linux. Some methods do not work. I used this one before:

1. Switch NumLock on at startup using numlockx in .xinitrc

apt install numlockx

cat .xinitrc
#!/bin/sh

if [ -e /usr/bin/numlockx ]; then
  /usr/bin/numlockx on
fi

But now i prefer simpler way, using Xfce4 settings.

LXDE: Add Keyboard Shortcut For Open Terminal With One Button

Using terminal very often it is convenient to start terminal with some keyboard shortcut, for example with just pressing Right Menu button (right button with logo). This is how to do that.

LXDE works with Openbox, so there is a file ~/.config/openbox/lxde-rc.xml with some configurations, also there are Keyboard shortcuts:

 

1. Edit ~/.config/openbox/lxde-rc.xml

Open file for editing with vim or any editor like gedit, mousepad or so:

vim ~/.config/openbox/lxde-rc.xml

Rsync to Android

Connecting Android to your Linux you need to use gvfs. Rsync also wants to set files timestams that is why you need this hack.

 

0. Install gvfs-fuse

For use MTP devices in terminal need to use gvfs-use:

apt install gvfs-fuse

and reboot.

 

1. Find MTP device in /run/user/1000/gvfs

ls /run/user/1000/gvfs
'mtp:host=Samsung_A7_caf675d6'

Next follow to that folder you need to store your data.

 

Compare Time and Dates in Bash. And the Simplest Alarm on Bash

Using bash it is possible to compare time easily in epoch format. If you need to compare date like 14:23 with 14:17 you need to transform it to seconds since epoch and compare as two integers. Here it is my function in ~/.bashrc and examples

 

Bash: Count Minutes and Seconds since Start of a Process

Starting long process you may want to watch how much time is it going. This helps you to guess how much time remains.

Usually you run some process and then watch on it in another terminal window in a loop `while [ 1 ]`.

For example, need to count minutes since the process start. Algorithm and simple bash script are here.

 

1. Store the start time in seconds in a variable

start=$(date +%s)

This stores start point as POSIX time in seconds like: 1660042758

 

Fill USB Flash with Zeroes on Linux

When formatting usb flash, it always only creates new partition table at the start sectors and remain all the rest as it was. So, it is possible to read the rest data, analyze and get old data if your flash will be in hacker's hands. If your data must be totally removed from flash, it needs to fill entire drive with zeroes.

 

Fill USB flash with zeroes with dd if=/dev/zero of=/dev/flash

Simplest way is to use 'dd', but it takes much time and reduces lifetime of usb flash:

dd if=/dev/zero of=/dev/FLASH

 

Add Date and Time to Each Line in ffmpeg Log with awk

When transcode video or catch bugs in live stream, sometimes it is necessary to log ffmpeg messages with also date and time. This is possible with awk.

 

Insert date and time to ffmpeg log messages using awk

Here we use test stream link from [3]. We run ffplay for check its work:

ffplay https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8 2>&1 | awk 'NF {print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush()}'

Explanation:

How to Run PHP-FPM 8.0 and PHP-FPM 7.4 Simultaneously for Different Sites on Centos 7 Nginx

Running websites on different CMS or different versions of the same CMS, it is usual that some sites need PHP 7.4, others PHP 7.2 and others can work on PHP 8.0 and so on. Centos 7 now has several php-fpm packages, and this article describes how to run two or more php-fpm services and configure nginx to use certain php version for certain site.

 

1. Update to PHP 8 on Centos if you still did not

Check current php version

php -v
  PHP 7.4.30 (cli) (built: Jun  7 2022 08:38:19) ( NTS )