Home

Awesome

Useful scripts for Linux users

See my Fish config for more CLI awesomness

wa

Description

<img src="https://developer.run/pic/wa_full.png"/> <img src="https://developer.run/pic/wa.png"/> <img src="https://developer.run/pic/wa2.png"/>

Using Wolfram Alpha in command line. See blog post for description and more ideas.

Requirements

Usage

➤ wa helsinki to dublin plane
2 hours 20 minutes                                                                                           
➤ wa time in dublin
5:37:57 pm GMT; Friday, January 27, 2017
➤ wa 15.36 english money to eur
14.35 euros                                                                                                          
➤ wa days till nov 16
293 days
➤ wa 154Mbit/s to MB/s
19.2 megabytes per second
➤ wa brick red hex
#AB0303 
➤ wa weather in moscow
9 degrees Celsius and cloudy, with light winds✖
➤ wa plot x=y^2
[...draws plot if supported]
➤ # many many more usages... https://www.wolframalpha.com/examples/
<hr/>

volume

Decription

Script to control audio volume from console, hotkeys, e.t.c. Also shows nice Notify OSD buble with current volume value

Requirements

sudo apt-get install pulseaudio notify-osd

Usage

volume (up|down|mute)
<hr/>

vlc-now.sh

Description

Show file or stream currently playing in VLC. Works well with (with xfce4-genmon-plugin). See playerctl -h for another players.

Requirements

Usage

<hr/>

url-preview-md.py

Decription

Wrapper around webpreview. Takes url, downloads a preview image (or image iself, if url points to image) and returns formatted markdown with page title and description. Useful with clipboard manager. Read more

Requirements

pip install webpreview

Usage

$ url-preview-md.py img_directory url
$ url-preview-md.py ~/img http://developer.run/70
[Markdown Url Preview](http://developer.run/70) Markdown Url Preview in text editor.
![](/home/dmi3/img/2023_09_01_developer.run_url-preview-md.png)
If you have OpenGraph.io api key, add it as last argument to try it if webpreview finds nothing useful
$ url-preview-md.py ~/img http://developer.run/70 e2b0e47c-8a03-11ef-b1b2-13950b80fc62
<hr/>

tray-unread.sh

<img src="https://developer.run/pic/tray-unread.gif"/>

Decription

Update tray icon depending on script result. Current example shows unread mail count for Evolution mail (for those poor souls who need exchange but don't have web client), but actually it can check and notify about literally anything! Another example shows Git repository status.

On click simulates some keypresses to mark all mail as read.

Read more:

Requirements

  1. sudo apt-get install yad
  2. For Evolution sudo apt-get install sqlite3 wmctrl xdotool

Usage

tray-unread.sh
<hr/>

tray-git-status.sh

Decription

Update tray icon depending if there are changes in Git repository. ⚠ Note that it does not show any icon if repository is in sync Check for new changes every 10 minutes. See also git-sync

See https://stackoverflow.com/a/3278427/18078777

Requirements

  1. sudo apt-get install yad git

Usage

tray-git.sh
<hr/>

translation-insert.sh

Decription

Prompts for text. Then inputs translation. Works in any application.

Requirements

  1. Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
  2. sudo apt-get install zenity xsel

Usage

<hr/>

translate-yandex.sh

Decription

CLI Yandex Translate API ru↔en. Automatically detects language. Translates any language to Russian, and Russian to English.

Usage

yandex-translate.sh cat is a small, typically furry, carnivorous mammal # en → ru
yandex-translate.sh die Hauskatze ist eine Unterart der Wildkatze # de → ru
yandex-translate.sh кот это маленькое, пушистое и очень хитрое млекопитающее # ru → en
<hr/>

translate-selection.sh

Decription

Show popup with translation of selected text. Works in any application.

Requirements

  1. Setup https://github.com/dmi3/bin/blob/master/yandex-translate.sh
  2. sudo apt-get install zenity xsel

Usage

<hr/>

tomatych.py

<img src="http://developer.run/pic/tomatych.png"/>

Description

<hr/>

todo

Wunderlist CLI for adding todos

Decription

Wrapper for wl for adding todos with more convenient syntax Read More

Instalation

  1. ⚠ Make sure Fish shell > 2.3.0
  2. curl https://raw.githubusercontent.com/dmi3/bin/master/todo --create-dirs -o ~/bin/todo
  3. curl https://raw.githubusercontent.com/dmi3/bin/master/config/fish/completions/todo.fish --create-dirs -o ~/.config/fish/completions/todo.fish
  4. https://developer.wunderlist.com/apps
  5. [CREATE APP] (Put https://wunderlist.com to both APP URL and AUTH CALLBACK URL)
  6. Set enviroment variables in this script ↓ (line 31)
  7. Add more list shortcuts ↓ (line 39)

Usage

 todo buy stuff --life --on next monday
 todo resolve issue --work --star
 todo --work meet customer --on jan 7
<hr/>

timer

Decription

Simple timer with sound and dialog window notification. To remind you to turn stove off :). Replace pc_up.wav to any available audiofile.

Requirements

sudo apt-get install dunst aplay

Usage

timer 6 # i.e. notify after 6 minutes
<hr/>

temp.sh

Decription

Shows CPU, System and GPU temperature

Requirements

sudo apt-get install jq lm-sensors nvidia-smi

Usage

temp

<hr/>

status.sh

Description

Status

CLI web stats dashboard. Visualizes GitHub followers, top GitHub repos and last 500 blog hits with top pages and refferers. Works well in addition to headlines.sh and newsbeuter -x reload -x print-unread 2> /dev/null Read more

Requirements

Usage

<hr/>

sssh2

Decription

Like sssh, in addition:

Usage

See sssh

<hr/>

sssh

Decription

Script to change your terminal title to user@host when connecting to ssh and changing it back after exiting. Additionally sets green prompt on remote host. Useful for Keepassx and visual distinction to avoid notorious "wrong window" problem. Also works when connecting Fish → Bash If you want hostname from local ~/.ssh/config file to appear in title use sssh2.

Requirements

sudo apt-get install xdotool

Usage

sssh user@hostname alias ssh=sssh

<hr/>

snippy.sh

Decription

System wide text snippet expander. Simulates cut→replace→paste so works in almost any application. Examples:

Requirements

sudo apt-get install xdotool xclip xsel

Usage

<hr/>

skypenotify

Decription

Script to run append Skype messages in Notify OSD as shown on http://thexnews.com/uploads/notify.gif Since x-canonical-append is broken in notify-send for example in Skype you will wait forever untill all messages are shown This script makes new messages readable in same notification window Readme in russian

Requirements

wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append

Usage

skypenotify "%sname" "%smessage"

<hr/>

rundesktop

Decription

Execute .desktop file from terminal

Usage

rundesktop /usr/share/applications/firefox.desktop

<hr/>

reboot

Decription

See https://github.com/dmi3/bin/blob/master/poweroff

<hr/>

print-numbers.py

Decription

Font especially designed to fit 6 digits to 20x8 screens For some reason miniwi.flf figlet font is not working in tty Useful for Raspberry Pi 2fa

    ▐ ██ ██ ▌▐ ██ ██
    ▐  ▐  ▐ ▌▐ ▌  ▌
    ▐ ██ ██ ██ ██ ██
    ▐ ▌   ▐  ▐  ▐ ▌▐
    ▐ ██ ██  ▐ ██ ██

Usage

python3 numbers.py 123456
<hr/>

poweroff

Decription

Gracefully closes all running X applications, then powers off the computer. Make sure to avoid conflicts with system poweroff is such exists. Useful to avoid issues when calling poweroff from console:

Requirements

  1. sudo apt-get install wmctrl
<hr/>

plug

Description

Interactive (un)mount of hotplug devices (USB drives) from console using FZF! Outputs path to mounted device so could be used in alias to actomatically cd to mounted directory.

Requirements

  1. sudo apt-get install jq fzf udisks2
  2. alias unplug='plug -u'
  3. cd to mounted directory:

Usage

$ plug
>         ACRONIS_MED     DataTraveler_2.0        sdb1     
          DATA            DataTraveler_3.0        sdc1
Mounted /dev/sdb1 at /media/dmi3/ACRONIS_MED.
$ plug -u
> /media/dmi3/ACRONIS_MED ACRONIS_MED     DataTraveler_2.0                sdb1                                                                                                                          
  /                       workbuntu2020   Samsung_SSD_860_EVO_M.2_500GB   sda2                                                                                                                                  
  /media/dmi3/ElTorito    ElTorito        Samsung_SSD_860_EVO_M.2_500GB   sda1 
Unmounted /dev/sdb1 
<hr/>

notify-append

Decription

Script to run append Notify OSD messages as shown on http://thexnews.com/uploads/notify.gif Since x-canonical-append is broken in notify-send for example in Skype you will wait forever untill all messages are shown This script makes new messages shown in same notification window bellow the already shown Created as addition to notify-send. Use notify-send when you want to send notification and notify-append when you want append or replace it. Readme in russian

<hr/>

mus.sh

Decription

Setups MUS (Minimal Usable System). Targets very slow machines with very broken disks and very bad internet, so checks everything.

Usage

/usr/bin/GET https://raw.githubusercontent.com/dmi3/bin/master/mus.sh > ~/mus.sh && chmod +x ~/mus.sh && ~/mus.sh
<hr/>

memory-available.sh

Decription

Prints free memory in gigabytes. Sends urgent notification if usage is less than defined value. Cached memory is considered free. Works best with indicator-sysmonitor and dunst

Requirements

  1. sudo apt-get install notify-send
<hr/>

layoutset

Decription

Script to set keyboard layout depending if its Apple or regular keyboard + some settings

Usage

layoutset

<hr/>

knok

Decription

Knocks to given ports with 0.5 second delay. Useful when default knockd delay is to short for server to react. Additionally displays Bob Dylan's lyrics :)

Requirements

  1. sudo apt-get install knockd python3 python3-setuptools
  2. sudo easy_install3 sh

Usage

knock ip [port,port...]

<hr/>

itunec

Decription

Mounts USB device, syncs new podcast in gpodder then umounts device

Requirements

  1. sudo apt-get install python3 id3v2
  2. wget https://raw.github.com/dmi3/bin/master/notify-append -P ~/bin && chmod +x ~/bin/notify-append

Usage

  1. set LABEL to label of your player filesystem (for example SANSA CLIP to find label type ls -l /dev/disk/by-label/)
  2. set GPODDER_DIR to directory where gpodder download podcasts
  3. run itunec when you want to sync or
  4. gpodder -> Podcasts -> Prefences -> Devices; set Device type to Filesystem-based and Mountpoint path where device is mounted by default
  5. gpodder -> Podcasts -> Prefences -> Edit config -> cmd_all_download_complete -> itunec
<hr/>

headlines.sh

<img src="https://developer.run/pic/headlines.png"/>

Description

Requirements

sudo apt-get install jq

Usage

<hr/>

git-sync

Decription

Script to simply sync all changes into git repository with one command. For example publish local changes to Github.

Requirements

  1. sudo apt-get install git
  2. Setup mergetool

Usage

git-sync /path/to/repo
git-sync # current dir
git-sync # if you want sync all files
git-sync -u # if you want only sync files explicitly added via `git add filename`
<hr/>

generate-readme.fish

Decription

Generates this readme

Usage

 echo -e "#!/bin/sh\necho \# Useful scripts for Linux users > README.md\necho \"See my [Fish config](https://github.com/dmi3/fish) for more CLI awesomness\" >> README.md\ngenerate-readme.fish --reverse >> README.md\nshasum -a 256 * | grep -v 'SHASUMS\|config' > SHASUMS" > .git/hooks/pre-commit
 chmod +x .git/hooks/pre-commit    
<hr/>

game-screenshot.sh

Description

Saves full screen screenshot with current window name and date to predefined folder and plays sound if successful.

Requirements

Usage

<hr/>

ex-spotify-playlist.sh

Export playlists from Spotify without giving credentials to shady sites (to avoid your Spotify credentials be stolen and resold to someone in different timezone)

Converts Spotify playlist from "Song Links" list:

https://open.spotify.com/track/6autdCG3xl7gzoiDCEB2HN
https://open.spotify.com/track/4q6RvRkXquQ965hubV58lb
https://open.spotify.com/track/01pzLOA8rQLfoodUCLc2wj

To "Track - Artist" list:

Nerevar Rising - Jeremy Soule
Arcanum - NewEnglandStringQuartet
Wilderness - Matt Uelmen    

Requirements

sudo apt-get install jq

Usage

  1. Open Spotify app
  2. Open playlist or "Songs" view
  3. Select all tracks Ctrl+A
  4. Copy track urls Ctrl+C
  5. Paste into file and save
  6. cat /path/to/file | ex-spotify-playlist.sh
<hr/>

ec2ssh.sh

Decription

Instalation

Usage

<hr/>

duplicati-ping.py

Decription

Ping https://healthchecks.io/ on successful Duplicati backup

Usage

Add path to this script to run-script-after in job ConfigurationOptionsAdvanched Options On Windows you will need to create .bat file containing path to this script, and add path to .bat file to run-script-after

<hr/>

doom

Decription

Script to run gzdoom with various configurations/wads. Selectable via dmenu

Requirements

  1. Get latest Gzdoom
  2. `sudo apt-get install gzdoom dmenu python3 python3-setuptools
  3. sudo easy_install3 sh

Usage

doom

<hr/>

control-panel

Description

GUI LXQT Settings menu

Requirements

 fzf

Usage

control-panel
<hr/>

config/lxterminal/lxterminal.conf

Config for LXTerminal with copy/paste on Ctrl+C/V and nicer color theme

<hr/>

config/kitty/kitty.conf

Config for Kitty with custom hotkeys, nicer color scheme and some useful tweaks Refer to original documentation for more options

<hr/>

config/fish/config.fish

Fish config with awesome flexible prompt, unicode symbols, better fzf integration and tons of handy functions.

<hr/>

config/clipit/clipitrc

Config for ClipIt with sane defaults and hotheys

<hr/>

center-mouse-active-window.py

Decription

Moves mouse in the center of active window.

Requirements

sudo apt-get install xdotool python3-sh gir1.2-wnck-3.0

Usage

center-mouse-active-window.py

<hr/>

bookmarks

Decription

Script for quickly adding and accessing bookmarks. Browser independent. When you want to store bookmarks in plain format, use CLI, but don't want use bm or Buku Useful when set by hotkeys or clipboard manager actions.

Requirements

  1. sudo apt-get install fzf

Usage

<hr/>

battery

Description

One more script to show battery status as bar(s). Difference from other solutions:

Usage

$ battery # multiple batteries are installed
🔌 ▄▇
$ battery # single battery is installed
🔌 ▇
$ battery # no battery is installed
🔌
<hr/>

batch-rename.py

Decription

Renames files given in arguments. Interactively prompts for file name. If no otherwise specified - uses first file name + number.

Usage

rename.py file1 file2 file3 ...

<hr/>

backup_protectedtext.py

Decription

Usage

Run from commandline or add to cron

<hr/>

aliases.bash

Decription

Some handy bash aliases and settings. ⚠ You may find more useful commands in Fish shell aliases (which is easily portable to Bash)

Usage

  1. wget https://raw.githubusercontent.com/dmi3/bin/aliases.bash --no-check-certificate -O ~/bin/aliases.bash
  2. echo "source ~/bin/aliases.bash" >> ~/.bashrc
  3. To make bash more usable you probably want to install https://github.com/mrzool/bash-sensible
  4. To make this work across remote machines, you also may want to install https://github.com/Russell91/sshrc
<hr/>