easyscripts

A big problem of Ubuntu-based distros for the normal desktop users are the software repository. Many software are not updated to the last version and this is a problem when a particular program like youtube-dl must be always updated to work properly.

To update it automatically you have to schedule the curl command available on the official github repository with cron. From a terminal windows, let run the crontab command.

sudo crontab -e

and add the following line at the end of the file.

35 9 * * 1 curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl

The numbers before the curl command are needed to schedule the command. If you want to create your personal schedule easily, please use the Crontab Guru website. In my string above: 35 minutes 9 hours * every day of the month * every month 1 every monday

My schedule is set to download the offical program every Monday at 9.35 AM. Change the parameters as you wish to best fit your needs.

If youtube-dl returns a python error after the first update of youtube-dl with curl (it happened on Mint) you just have to create a symlink for python:

sudo ln -s /usr/bin/python3 /usr/local/bin/python

Sometimes you may want to disable the integrated keyboard of your laptop or notebook. For example in the case it's broken and some key result as always pushed.

This is an easy one-line script to disable the internal keyboard. You can execute it in the terminal or put it on a .sh script. This is not the best way, but it worked for me and that's all I need :–) I hope it can work for you, too.

The code

xinput float $(xinput list | grep AT | cut -d'=' -f 2 | cut -c 1-2)

How it works

xinput list allows to see all the attached input devices xinput float allows to virtually detach one of the input devices

Example of the xinput list command result: Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ MLK Trust Deskset 16593 id=12 [slave pointer (2)] ⎜ ↳ Logitech M570 id=13 [slave pointer (2)]

To detach the Logitech M570 I should input xinput float 13 where 13 is the M570 ID on my system (it's shown by the xinput list command)

Since the integrated keyboard is often shown as “AT Translated Set 2 keyboard”, the code above just extracts the ID number of the “AT Translated Set 2 keyboard”.

  • xinput float detaches the device with the ID extracted with the following command
    • xinput list lists the devices
    • grep AT keeps only the line with AT in the string (the AT Translated Set 2 keyboard in my case)
    • cut -d'=' -f 2 keeps only the characters that follows the = which is used to show the ID of the device
    • cut -c 1-2 keeps only the 2 chars of the ID

The cut -d'=' -f 2 is used to cut only 2 char and it should be enough without the next cut command, but it doesn't work and I can't figure out why. I had use the cut command twice to achieve the result I need.

Important note

This script works if the ID of your integrated keyboard is >9 (it's composed by 2 char and not only 1). If your AT device id is <=9 you should change the cut -c 1-2 to cut -c 1-1

How to run it automatically

This part heavily depends on your distro and dekstop environment. You can run it manually, running the string in the terminal everytime you boot the system, but I think the easy way is to put that string in a executable .sh script. * Just open the notepad app and save it with the .sh extension. * Then run chmod +x NameOfTheScript.sh to make it executable

Now you can run it at the startup: double click on it or put the script in the startup applications. If you need more details, just search online run sh script at startup linux (or specifying your distro or dekstop envinronment) and you will find a lot of guides.