XXIIVV

Linux is a collection of tools built within the Unix operating systems.

linux software

dwm

Shift+Alt+EnterOpen terminal session
Shift+Alt+CClose Application
Shift+Alt+QQuit
Alt+POpen Application
Alt+JPrevious Application
Alt+KNext Application
Alt+TTile Applications
Alt+MouseLeftMove floating window
Alt+MouseRightResize floating window

To change the content of the rightmost label in the menu bar, edit the content of ~/.xinitrc.

while true; do
  xsetroot -name $(arvelie)" "$(neralie)
  sleep 1m
done &

exec dwm

micro

Ctrl+TNew Tab
Ctrl+BRun shell command
Ctrl+ERun micro command

surf

Ctrl+HBack History
Ctrl+LNext History
Ctrl+BToggle Input
Ctrl+Shift+O

Git

Branching/Merging

git checkout -b branchname
git checkout -b main
git merge branchname

Cache Password

git config remote.origin.url # Get URL
git config credential.helper store
git push REPOSITORY.git # Replace with URL

Merge

git remote add ft git@git.sr.ht:~ft/orca
git fetch ft
git merge ft/variable-index-0

Patch

A patch is essentially a git commit expressed in plain text. It describes what commit the change is based on, and what has changed. A basic patch looks like this:

To generate a patch:

git format-patch HEAD^
From eb91e94ef4b495b9e664c7605e036fcacb0abe71 Mon Sep 17 00:00:00 2001
From: neauoire 
Date: Mon, 18 Jan 2021 09:38:49 -0800
Subject: [PATCH] Fixed issue with the z operator

diff --git a/orca.c b/orca.c
index b9b6a80..a5dc162 100644
--- a/orca.c
+++ b/orca.c
@@ -163,18 +163,8 @@ clmp(int val, int min, int max)
  return (val >= min) ? (val <= max) ? val : max : min;
 }
 
-char *
-scpy(char *src, char *dst, int len)
-{
- int i = 0;
- while((dst[i] = src[i]) && i < len - 2)
-   i++;
- dst[i + 1] = '\0';
- return dst;
-}
-- 
2.29.2

To apply a patch, use the am command:

git am < 0005-some-patch-name.patch

Rename master to main

git branch -m master main && git push -u origin main && git push origin --delete master

SSH

ssh-keygen # Generate a key
vi ~/.ssh/id_rsa.pub # See the key

CMUS

Get cmus currently playing.

cmus-remote -Q | grep tag | head -n 3 | cut -d ' ' -f 3- 

Kill cmus

ps ax | grep cmus
sudo kill -9 PID

Commands

Feh

Viewing graphic files.

feh -m # Montage mode
feh -w # Multi-window mode
feh -i # Index mode
feh -m --thumb-height 150 --thumb-width 200

EyeD3

Editing the ID3 tags of MP3 files.

eyeD3 -a "Artist" -A "Album" -t "Track Title" song.mp3
eyeD3 song.mp3

Youtube-dl

Converting videos to mp3 files.

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
// Single
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=sfIls6LMAGE
// Playlist
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" 'https://www.youtube.com/watch?v=5KpK7yhDRXE&list=PLfGibfZATlGq4e4UsUiPLs3asiOqysjei'

Format SD Card

lsblk # Find device
sudo parted /dev/sdb --script -- mklabel msdos # Create partition, replace sbd with device name
sudo parted /dev/sdb --script -- mkpart primary fat32 1MiB 100% # Take all available space
sudo mkfs.vfat -F32 /dev/sdb1 # Format
sudo parted /dev/sdb --script print # Verify

Mount USB Stick

lsblk # List all devices, find dev/sda1
mkdir usbstick # create a folder somewhere
mount dev/sda1 /usbstick # use the folder to browse usb stick

Format hard drive

df -h
sudo umount /dev/sdb2
sudo mkfs.vfat /dev/sdb2

Untar

tar xzf file.tar.gz # to uncompress a gzip tar file (.tgz or .tar.gz)
tar xjf file.tar.bz2 # to uncompress a bzip2 tar file (.tbz or .tar.bz2) to extract the contents.
tar xf file.tar # to uncompressed tar file (.tar)

Config Micro

To set the theme to the terminal colors, use set colorscheme cmc-16.

micro ~/.config/micro/settings.json
{
  "color_scheme": "Packages/Theme/Tech49.tmTheme",
  "font_size": 9,
  "margin": 2,
  "tab_size": 2,
  "theme": "Adaptive.sublime-theme",
  "translate_tabs_to_spaces": true
}

Use a .deb File

sudo dpkg -i filename.deb
sudo dpkg -i ./bitwig-studio-3.1.3.deb # Updating bitwig

Capture screenshot of selection

import ss.png

Capture video and audio

ffmpeg -f x11grab -video_size 1366x768 -framerate 25 -i $DISPLAY -f pulse -ac 2 -i default -c:v libx264 -preset ultrafast -c:a aac screen.mp4

Capture video and audio(partial)

ffmpeg -video_size 544x352 -framerate 25 -f x11grab -i :0.0+413,208 -f pulse -ac 2 -i default screen-recording.mkv

Resize video for web

ffmpeg -i screen-recording.mkv -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 25 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 output.mp4

Export part of a video

ffmpeg -ss [start] -i in.mp4 -t [duration] -c copy out.mp4

Add audio to video

ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -codec:v libx264 \
-preset medium -crf 23 -codec:a aac -b:a 192k -shortest output.mp4

Find file size

du -sk name

Battery management

sudo powertop --auto-tune

Autodetect time

systemctl enable ntpd
systemctl enable ntpdate

Copy image to clipboard

xclip -selection clipboard -t image/png -i example.png

Images to PDF

convert image1.jpg image2.png image3.bmp output.pdf

Folder of images to pdf

convert *.jpg output.pdf

Plan9Port

git clone https://github.com/9fans/plan9port /usr/local/plan9
chown -R $(whoami):$(whoami) /usr/local/plan9
cd /usr/local/plan9
./INSTALL

# add /usr/local/plan9/bin to your $PATH
export PATH=$PATH:/usr/local/plan9/bin