Today I Learned

Linux

<TIL

Disable capslock

Short version (tested in ubuntu):

setxkbmap -option caps:none

Try creating the file 10-nocaps.conf with the following content:

Section "InputClass"
        Identifier             "keyboard-layout"
        MatchIsKeyboard        "on"
        Option "XkbOptions"    "ctrl:nocaps"
EndSection

…and place it in either /etc/X11/xorg.conf.d or /usr/share/X11/xorg.conf.d (depending on which folder your distro uses) and log out and back in again to test.

Creating a bootable USB using dd

Warning: This will irrevocably destroy all data on /dev/sdx. To restore the USB drive as an empty, usable storage device after using the Arch ISO image, the ISO 9660 filesystem signature needs to be removed by running wipefs --all /dev/sdx as root, before repartitioning and reformating the USB drive.

Tip: Find out the name of your USB drive with lsblk or lsusb and # fdisk -l to see the partition of the USB. Make sure that it is not mounted.

Run the following command, replacing /dev/sdx with your drive, e.g. /dev/sdb. (Do not append a partition number, so do not use something like /dev/sdb1)

# dd bs=4M if=path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync

Tip: If the UEFI version of the USB’s Arch ISO hangs or is unable to load, try repeating the dd medium creation process on the same USB drive one or more times.

source

Add suffix to filename

e.g to change the name of a file from old.name to old.name_backup:

mv old.name{,_backup}

Check the status of all services

$ sudo service --status-all

source

Watch/capture webcam feed

$ ffplay /dev/video0

$ mpv /dev/video0

or

$ mpv av://v4l2:/dev/video0

$ vlc v4l2:///dev/video0

Source

How to install pass extensions

This guide refers to extensions for passwordstore.org: git clone https://github.com/browserpass/browserpass-native.git

cd browserpass-native

docker build -t browserpass-native .

docker run --rm -v "$(pwd)":/src browserpass-native browserpass-linux64

make BIN=browserpass-linux64 configure

sudo make BIN=browserpass-linux64 install

cp /usr/lib/browserpass/hosts/chromium/com.github.browserpass.native.json ~/.config/slimjet/NativeMessagingHosts/

source

Edit a long command that you previously run

After you run the wrong command (or the one you wan to change) run fc. It will open a vim buffer and paste the last command you run.

Edit it and when you close vim, it will run the command.

Or, use zsh with vim navigation :)

source

Hide tabs in firefox

  1. Add a userChrome.css file
    • Open your currently active profile folder
    • Create a new folder named chrome
    • Create a new text file inside the chrome folder named userChrome.css
    • Set Firefox to look for userChrome.css at startup source
  2. Add css rules to hide the bar:
    #main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar > .toolbar-items {
      opacity: 0;
      pointer-events: none;
    }
    #main-window:not([tabsintitlebar="true"]) #TabsToolbar {
     visibility: collapse !important;
    }
    #main-window[tabsintitlebar="true"]:not([extradragspace="true"]) #TabsToolbar .titlebar-spacer {
         border-inline-end: none;
    }
    

    source

Copying gpg keys between machines

On the source machine: gpg --export ID > public.key gpg --export-secret-key ID > public.key On the destination machine: gpg --import public.key gpg --import private.key

source

Set 10 workspaces in popos

gsettings set org.gnome.mutter dynamic-workspaces false
gsettings set org.gnome.desktop.wm.preferences num-workspaces 10
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<Super>1']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-1 "['<Super><Shift>1']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<Super>2']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-2 "['<Super><Shift>2']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<Super>3']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-3 "['<Super><Shift>3']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<Super>4']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<Super><Shift>4']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-5 "['<Super>5']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-5 "['<Super><Shift>5']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-6 "['<Super>6']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-6 "['<Super><Shift>6']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-7 "['<Super>7']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-7 "['<Super><Shift>7']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-8 "['<Super>8']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-8 "['<Super><Shift>8']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-9 "['<Super>9']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-9 "['<Super><Shift>9']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-10 "['<Super>0']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-10 "['<Super><Shift>0']"

source

Enable right-click functionality for touchpad

$ sudo gsettings set org.gnome.desktop.peripherals.touchpad click-method areas

src

Support md files on firefox

Firefox on Linux may not know how to handle markdown files by default. These mime types are stored in a file indicated by helpers.private_mime_types_file, by default it is ~/.mime.types. Create this file if it does not exist, otherwise edit it, and add the following line:

type=text/plain exts=md,mkd,mkdn,mdwn,mdown,markdown, desc="Markdown document"

src

i3 with gaps and transparent terminal

i3-gaps

compton

$ sudo apt-get install compton && compton -bcf

xfce-terminal

How to run both the integrated and the dedicated graphic cards

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

src

Set default application with xdg

  1. find out the MIME type string: $ file -i name_of_the.file

  2. find out the name of the application .desktop file: $ grep "application_name" -l -r /usr/share/applications

  3. make the assignement: $ xdg-mime default application_name file/type

Example:

$ file -i Broken_Blossoms.webm
Broken_Blossoms.webm: video/webm; charset=binary
$ grep "mpv" -l -r /usr/share/applications
/usr/share/applications/mpv.desktop
$ xdg-mime default mpv.desktop video/webm

src

Add ssh key to remote server

ssh-copy-id -i ~/.ssh/id_rsa.pub YOUR_USER_NAME@IP_ADDRESS_OF_THE_SERVER

or

mkdir -p /home/user_name/.ssh && touch /home/user_name/.ssh/authorized_keys

and paste the public key to authorized_keys file.

Don’t forget to: chmod 700 /home/user_name/.ssh && chmod 600 /home/user_name/.ssh/authorized_keys chown -R username:username /home/username/.ssh

kitty missing or unsuitable terminal error

kitty +kitten ssh myserver

src

Load a small linux distro inside the /boot

“Tiny Core’s small enough that I’ll often throw the entirety of it in /boot or /boot/EFI on my Linux desktops as a recovery environment.

root (hd0,1)
    kernel /tinycore/vmlinuz tce=sda1/tinycore/tce vga=794
    initrd /tinycore/core.gz

in GRUB’s shell should do the trick no matter what might lurk in grub.cfg.”

src