Welcome to Tony Tascioglu's informational wiki site. Thanks for dropping by and enjoy your stay!

Over the years, I have build up several useful scripts to use on Linux systems. I'll try to document them here!

I have split this long page into several sub pages:

Any other unsorted stuff will be here!

Misc commands

Tearfree mode

Tearfree is like a triple buffer for graphics. As the name implies, it's great at stopping tearing that's so annoying on my system.

It is NOT freesync, that is separate.

Enable it like this:

xrandr --output DisplayPort-1 --set TearFree on

Some games might go 5fps, in which case, disable it again, since games usually have their own buffer and vsync.

Run all executable in a folder

Sometimes it is useful to run all executables in a folder. Rather then looping, if you have debianutils or busybox, you can use the dedicated run-parts command.

Note the slightly different syntax between the debian and busybox ones. busybox can't do –report or -v to print the name of all files as they are run.

run-parts .

Where the . is the folder to run executables from.

Make sure you test what will be run as follows

run-parts --test

IIRC, you can also pass parameters to the files being run. This may be useful for running test executables.

Boot Linux to serial port

For many people, this would fall within the Why? section. For the 1 homelab sysadmin reading it, this may be useful.

Essentially, Linux by default boots to /dev/tty0, which is generally the main monitor and console. However, you can have it print all the systemd messages elsewhere, such as a serial port. This is useful if you have a motherboard with IPMI that supports serial port redirection but has broken KVM (*cough* supermicro x9 boards needing some java version for kvm *cough*).

This can be beter then running sshd or x2go on startup, because if you have a special boot process (such as full disk encryption), then you need to boot to be able to start those services.

To do this, just add the console to the kernel boot parameters:

console=ttyS1,9600

The first parameter is the console name. Serial ports start with /dev/ttyS0, then S1, so on. Like COM ports on Windows. The 2nd parameter is the baud rate, ie: speed. 9600 is quite slow, and any lower would take too long to boot, however this is a common speed that's almost guaranteed to be supported.

If you don't know where to add this, see you GRUB or REFIND or config of your bootloader. It's the line that includes

initrd=/initramfs-linux-zen.img

Mount Seagate external drive without UAS

Normally, you can't run smartctl on a Seagate external drive since they use UAS (USB attached SCSI), which might make it a bit faster for planar drives, but smartctl doesn't support reading SMART data over UAS.

First, unmount and unplug the drive if it is in use

Then, remove the usb-storage and uas modules

sudo modprobe -r usb-storage
sudo modprobe -r uas

(or alternatively, use rmmod)

sudo rmmod usb-storage
sudo rmmod uas

Next, before you plug the drive in (which will auto-load uas), you need to load the usb-storage module with the quirk to disable uas for your Seagate drive.

To do this, get the vendor and product id by doing lsusb (the xxxx:yyyy stuff)

Finally, reload the module with the quirk as follows

sudo modprobe usb-storage quirks=0bc2:331a:u

Where the xxxx:yyyy is the vendor and product id for your drive, and the :u tells it to not use uas.

Map Wacom tablet to one display

By default, connecting a graphic tablet such as a Wacom will map the full resolution of the X11 window to the tablet. If you have more then one display, it will mess with the aspect ratio.

The solution is simple. If you are on X11, this can be done with xinput. You can also use xsetwacom with libinput.

First check the list of input devices by doing

xinput

This will return the list of input devices. You want to search for the one that is the pen or stylus for your tablet, as it is the one that send the mouse inputs. Copy the id of this device.

Since most devices have the work stylus, you can just grep for it

xinput list | grep "stylus"

Then, check the display name you want to map it to by running

xrandr

or using a display manager of your choice.

Finally, to map the input to the display, run the following

xinput map-to-output <input> <display>

For example, to map input device 10 to display DVI-D-0

xinput map-to-output 10 DVI-D-0

Alternatively, on some systems, you can use xsetwacom to achieve the same thing if you don't use libinput.

xsetwacom set 10 MapToOutput DVI-D-0

2021 update: automated version

For my Intuos tablet, I figured I can automate this instead of using my eyes to find the id from xinput.

Here is the jank result that somehow works. Parameter 1 is to map to DisplayPort-0 or DisplayPort-1, my 2 monitors.

input=$(xinput list | grep stylus | cut -c 55-57);
echo "Wacom is on $input";
echo "Mapping to DisplayPort-$1";
xsetwacom set $input MapToOutput DisplayPort-$1

I basically cut the result of xinput through hardcoded columns 55-57 since that's where the id always is for me.

Then, I feed that to xsetwacom, with the monitor set by my parameter. Make it a script or bash function.

Why?

Things that make you question why this was implemented.

Play music from motherboard speaker

Have you wanted to relive the experience of listening to music through a tin can or the audiophile grade (lol) 70v ceiling speakers installed at your old school? Well, the kernel has got the solution for you!

Some custom computers and most prebuilt computers have a small onboard speaker or buzzer on the motherboard. This is usually very handy for debugging as it can produce a range of tones to help troubleshoot problems. On Linux, the bell input and some escape characters normally trigger the buzzer. I also use the beep command to signal notifications with a range of tones. It's like the old RGB indicator on phones, where you can tell what program just fired a notification from the sound (like you could based on the colour of the LED).

beep

Of course, people have already compiled a range of melodies for this, and you can find it here https://github.com/ShaneMcC/beeps

But, what if that's not enough, and you want to use the buzzer as a speaker? By default the kernel loads the pcspkr module for using the speaker/buzzer. There is however another module snd-pcsp that can mount the speaker as an ALSA output, allowing PulseAudio to use it as a sound output.

sudo rmmod pcspkr 
sudo modprobe snd-pcsp

Finally, bring up pavucontrol and enable the mono output. You mau need to unmute it first from alsamixer as well. Then, you can simply set a program like MPD to use it as an output and enjoy your music in what may be usable quality if your MB has a speaker, and horrifying quality that sounds like a dying fire alarm if your MB has a buzzer. (tip: change the base frequency to be above the range where you can hear it).

todo: attach a recording of the sound quality

Have fun!

Discussion

Enter your comment:
R F F X W
 
Navigation