inital commit
This commit is contained in:
87
.local/bin/SCRIPTS.md
Normal file
87
.local/bin/SCRIPTS.md
Normal file
@ -0,0 +1,87 @@
|
||||
# Directory of Scripts
|
||||
|
||||
I keep all my user-created scripts here in `~/.local/bin/`. Scripts are sorted
|
||||
into sub-directories for easy management, and all are seamlessly added to
|
||||
`$PATH` with the command below in `~/.profile`:
|
||||
|
||||
```
|
||||
export PATH="$(du $HOME/.local/bin/ | cut -f2 | tr '\n' ':')$PATH"
|
||||
```
|
||||
|
||||
## `statusbar/`
|
||||
|
||||
For modules used in i3blocks.
|
||||
|
||||
- `battery` -- i3blocks module. Shows available power remaining with icon indicating battery status. Colors indicate different levels of charge.
|
||||
- `clock` -- Shows time and date. If clicked, brings up calender or coming calcuse events.
|
||||
- `cpu` -- Shows CPU temperature. If clicked, shows most processor-intensive processes.
|
||||
- `help` -- Module which appears as a question mark. Brings up readme if clicked.
|
||||
- `internet` -- Shows whether machine is connected to wifi and ethernet. If clicked, brings up `nmtui`.
|
||||
- `mailbox` -- i3blocks module for use with mutt-wizard. Shows unread mail and if `mailsync.sh` is running.
|
||||
- `mem` -- Shows memory usage. If clicked, shows most memory-intensive processes.
|
||||
- `music` -- i3blocks module. Shows current song; if paused, name will be grayed and italic.
|
||||
- `mpdupdate` -- A daemon running by default that will update the i3mpd block on mpd change.
|
||||
- `news` -- Shows unread newsboat articles. Brings up newsboat or refreshes RSS feeds.
|
||||
- `pacpackages` -- i3blocks module. Detects new installable upgrades. Only works if you use cronjobs to automatically sync repositories.
|
||||
- `popupgrade` -- Called by clicking on the update icon if there are new packages. Spawns a `yay` upgrade of the main Arch repos and AUR packages, updates the i3blocks module once complete.
|
||||
- `torrent` -- i3blocks module. Shows torrents idle (⌛️), downloading (⬇️) or finished (🌱).
|
||||
- `volume` -- i3blocks module. Shows volume percentage or mute notification.
|
||||
- `weather` -- i3blocks module. Gets weather forcast from wttr.in and returns today's precipitation chance (☔), daily low (❄️) and daily high (☀️).
|
||||
|
||||
## `cron/`
|
||||
|
||||
For scripts meant to be cronjobs. None are active by default on LARBS.
|
||||
|
||||
- `checkup` -- If connected to internet, syncs package repositories and downloads (but does not install) any potential updates. Gives `notify-send` notifications of when it is active since other `pacman` install commands cannot be run simultaneously. You may need to grant your user the ability to run `pacman -Syyuw --noconfirm` without a password (done in `/etc/sudoers`).
|
||||
- `cronbat` -- Gives a dunst notification if the battery is less than 25%.
|
||||
- `crontog` -- Not actually a cronjob, but just turns off/on all user cronjobs.
|
||||
- `getforecast` -- Updates the weather forecast. This is automatically run by `weather` if there hasn't been a new forecast today.
|
||||
- `newsup` -- Updates newsboat RSS feeds if connected to internet. Will also display a newspaper update icon on i3blocks if it has not be user disabled.
|
||||
|
||||
## `tools/`
|
||||
|
||||
Scripts intended to be run either manually by the user or linked to a shortcut
|
||||
in vim or another program.
|
||||
|
||||
- `compiler` -- Compiles a markdown, R markdown or LaTeX document with the approriate command. Will also run `make && sudo make install` if in a `config.h` file. Otherwise it will create a sent presentation. This can be thought of a general output handler. I have it bound to `<leader>c` in vim.
|
||||
- `dmenuhandler` -- Give this script a url and it will offer dmenu options for opening it. Used by `newsboat` and some other programs as a link handler.
|
||||
- `extract` -- Will detect file type of archive and run appropriate extraction command.
|
||||
- `getbib` -- Use crossref.org to automatically detect bibtex entry of a .pdf. Attempts to search for the .pdf's DOI. Returns nothing if none detected.
|
||||
- `getkeys` -- Get the LARBS documentation on what bindings exist for main programs.
|
||||
- `linkhandler` -- The automatic link handler used by `newsboat` and other programs. Urls of video sites or of video files are opened in `mpv`, images are downloaded/opened in `feh`, music files are downloaded with `wget` and all other urls are opened in the default browser.
|
||||
- `lmc` -- A music controller that simplifies music/audio management and improves the interface with i3blocks. Check inside to see what it does. This is what i3 audio/music commands run by default. If you use a difference music system or ALSA, you can change this script rather than changing all the shortcuts in different places.
|
||||
- `note` -- Give this script some text/a message as an argument. It will print it to the terminal, and if `dunst` is running, display a notification.
|
||||
- `opout` -- "Open output", opens the corresponding `.pdf` file if run on a `.md`, `.tex` or `.rmd` file, or if given an `.html` file, will open it in the browser. Bound to `<leader>p` in my vim config to reveal typical output.
|
||||
- `pauseallmpv` -- Pauses all mpv instances by sending the `,` key to each. Used by several scripts, but can be used alone as well. It will not pause an audio only mpv instance. If you know how to add a hack to do this, feel free to PR it or email me an addition.
|
||||
- `remaps` -- Remaps capslock to escape when pressed and super/mod when held. Maps the menu key to super as well. Runs the US international keyboard setup. If you want another keyboard setup, edit this fine.
|
||||
- `shortcuts` -- For updating bash and ranger shortcuts. Reads `~/.config/bmdirs` and `~/.config/bmfiles` for pairs of keypresses and directories and files, then autoproduces bash aliases and ranger shortcuts for them which output to `~/.config/shortcutrc` and `~/.config/ranger/shortcuts.conf` respectively. These are read automatically by my bash and ranger configs. You don't have to run this script manually though, as it's run by vim whenever you edit one of the `~/.bm*` files.
|
||||
- `speedvid` -- Speed up a given video file (`$1`) by a given ammount (`$2`).
|
||||
- `tpb` -- Search Pirate Bay for the certain search terms given as arguments.
|
||||
- `texclear` -- Remove all `.tex` related build files. This is run by my vim when I stop editing any `.tex` file.
|
||||
- `transadd` -- The mimeapp default script for handling torrent magnet links. Starts `transmission-daemon` if not running and adds the link.
|
||||
|
||||
## `i3cmds`
|
||||
|
||||
These are scripts linked to bindings in i3. They typically perform
|
||||
user-interface actions or involve dmenu.
|
||||
|
||||
- `bottomleft` and `bottomright` -- Makes the currently selected window float in one of the bottom corners of the screen. `bottomleft` is bound to `mod+B` by default.
|
||||
- `camtoggle` -- Starts/kills /dev/video0 webcam. Placed in bottom right by default.
|
||||
- `ddspawn` -- This is the script called to create, show and hide the dropdown tmux terminal mapped to `mod+u`, but also the dropdown calculator mapped to `mod+a`. Give the script an argument that is a script the window will run. If a window does not already exist, `ddspawn` creates it, if it does, `ddspawn` will toggle its visibility. The the script itself for usage.
|
||||
- `displayselect` -- Select which displays to use. Bound to `mod+F3`.
|
||||
- `dmenumount` -- Gives a dmenu prompt for mounting USB drives or Android devices. Bound to `mod+F9`. Will do nothing if none are available.
|
||||
- `dmenurecord` -- Gives a list of recording commands: `audio`, `video` and `screencast` (both) in dmenu for selection. Bound to `mod+PrintScreen` by default. Should be killed by `killrecording`.
|
||||
- `dmenuumount` -- Unmount a mounted non-essential partition. Bound to `mod+F10`. Will do nothing if none are mounted. It will not try to unmount essential system partitions.
|
||||
- `dmenuunicode` -- Shows a searchable dmenu prompt of emoji characters. The selected emoji is copied to the system clipboard, while its character code is copied to primary selection (middle mouse button).
|
||||
- `dropdowncalc` -- The dropdown calculator script called by `ddspawn` and bound to `mod+a` by default. Will run an R calculator if installed, otherwise python.
|
||||
- `ducksearch` -- Show a dmenu prompt and search for the inputed text in DuckDuckGo. Can take bangtags as expected, i.e. typing in `!aw Arch Linux` will search the Arch Wiki for "Arch Linux" or `!yt Luke Smith` will search YouTube for "Luke Smith", etc.
|
||||
- `i3resize` -- A script that allows intuitive resizing of windows. Mapped to `mod+Y/U/I/O`.
|
||||
- `killrecording` -- End a recording started by `dmenurecord` the proper way without file trucation or lingering background processes, mapped to `mod+Delete` by default.
|
||||
- `lockscreen` -- The screen locker. Gives a confirm prompt and if user says yes, all audio will be paused and the screen will be distorted and locked and screen will soon time out. User must insert password to unlock. Mapped to `mod+x` by default.
|
||||
- `newspod` -- A silly line that has a script all to itself due to i3's idiosyncracies. Starts `newsboat`, if `newsboat` cannot open because of another instance being open, opens `podboat`.
|
||||
- `prompt` -- Gives a Yes/No prompt to a question given as an argument. Used by numerous bindings like `mod+shift+x`, `mod+shift+backspace` and `mod+shift+escape`.
|
||||
- `samedir` -- Opens a terminal window in the same directory as the window currently selection. Bound to `mod+shift+enter`.
|
||||
- `td-toggle` -- Gives a dmenu prompt to start `transmission-daemon` if not running, or the kill it if it is. Obviously you need `transmission-cli` installed for this to work. Mapped to `mod+F7` by default.
|
||||
- `tmuxdd` -- The startup script for the dropdown terminal (toggleable with `mod+u`). Either attaches to an existing tmux session or begins a new one.
|
||||
- `toggletouchpad` -- As the name suggests, turns off TouchPad if on, and turns it on if off. Requires `xf86-input-synaptics`. If your laptop has a special button for this, it will be mapped by default.
|
||||
- `tutorialvids` -- A dmenu prompt that gives some options of tutorial videos to watch. Bound to `mod+shift+e`.
|
154
.local/bin/bt
Executable file
154
.local/bin/bt
Executable file
@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
#wait time to discover new devices in seconds
|
||||
SCAN_PERIOD=5
|
||||
AUTOTRUST=false
|
||||
#locations of blacklist and hard coded list of paired devices (watch out, need to modify Makefile as well if you want to change these values and still use make install)
|
||||
BLACKLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/blacklist
|
||||
PAIRLIST=${XDG_DATA_HOME:-$HOME/.local/share}/bt/paired
|
||||
|
||||
actions="pair
|
||||
disconnect
|
||||
unpair"
|
||||
|
||||
[ "$AUTOTRUST" = false ] && actions+="
|
||||
trust"
|
||||
|
||||
#Checks for necessary programs to be present. Very unlikely not to be present but let's just err on the safer side.
|
||||
for prog in dmenu bluetoothctl awk cat date nl; do
|
||||
if ! hash "$prog" 2>/dev/null; then
|
||||
printf 'bthandler: %s: command not found\n' "$prog" >&2
|
||||
exit 127
|
||||
fi
|
||||
done
|
||||
|
||||
power(){
|
||||
powerstatus="$( bluetoothctl show | grep Powered | awk '{print $2}' )"
|
||||
[ "$powerstatus" = "no" ] && [ "$1" = on ] && bluetoothctl power on
|
||||
[ "$powerstatus" = "yes" ] && [ "$1" = off ] && bluetoothctl power off
|
||||
}
|
||||
scan(){
|
||||
scanstatus="$( bluetoothctl show | grep Discovering | awk '{print $2}' )"
|
||||
if [ "$1" = on ]; then
|
||||
#sets variable in case scanning was already on before the start of bt
|
||||
[ "$start_scan" = "" ] && start_scan="$( date +'%s' )"
|
||||
if [ "$scanstatus" = "no" ]; then
|
||||
bluetoothctl scan on &
|
||||
start_scan="$( date +'%s' )"
|
||||
fi
|
||||
elif [ "$1" = off ]; then
|
||||
if [ "$scanstatus" = "yes" ]; then
|
||||
bluetoothctl scan off
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#start scanning as early as possible to speed up pairing process
|
||||
#=> maybe use an option to do this? Otherwise ever invocation of bt powers on the controller.
|
||||
power on
|
||||
scan on
|
||||
|
||||
#Compile list of all Bluetooth IDS of paired devices (from bluetoothctl and from hardcoded list)
|
||||
bt_IDS="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{print $2}' )"
|
||||
|
||||
#Compile list of all device Names of paired devices (from bluetoothctl and from hardcoded list)
|
||||
paired_devices="$( ( bluetoothctl paired-devices && cat "$PAIRLIST" ) | sort -u | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' )"
|
||||
|
||||
disp_devices="$( echo "$paired_devices" | grep -vf "$BLACKLIST" )"
|
||||
|
||||
#detects current power mode of controller and adjusts options accordingly
|
||||
poweroption="$( echo "$powerstatus" | sed 's/yes/power off/; s/no/power on/' )"
|
||||
#Don't print empty device list, removes unnecessary empty choice in dmenu
|
||||
[ "$disp_devices" = "" ] && choice=$( printf "%s\n%s" "$poweroption" "$actions" | dmenu -i -p 'What BT action would you like to perform:' )
|
||||
[ "$disp_devices" != "" ] && choice=$( ( echo "$disp_devices" && printf "%s\n%s" "$poweroption" "$actions" ) | dmenu -i -p 'What BT action would you like to perform:' )
|
||||
|
||||
cleanup(){
|
||||
scan off
|
||||
exit 0
|
||||
}
|
||||
|
||||
pair(){
|
||||
#since this function can get called indefinitely, make sure to always be scanning and controller has power in the case that it got deactived by some other process.
|
||||
power on
|
||||
scan on
|
||||
#check whether $SCAN_PERIOD seconds has already passed since starting scanning, if not, wait for the rest of that time.
|
||||
if [ $((( "$(date +'%s')" - "$start_scan" ))) -lt $SCAN_PERIOD ]; then
|
||||
sleep_period="$((( "$SCAN_PERIOD" - "$( date +'%s')" + "$start_scan" )))"
|
||||
if [ "$sleep_period" -eq 1 ]; then
|
||||
notify-send "Bluetooth" "Searching for devices, please wait 1 second"
|
||||
else
|
||||
notify-send "Bluetooth" "Searching for devices, please wait $sleep_period seconds"
|
||||
fi
|
||||
|
||||
sleep "$sleep_period"
|
||||
fi
|
||||
echo paired_devices:"$paired_devices".
|
||||
echo paired_devices:$paired_devices.
|
||||
if [ $paired_devices = "" ]; then
|
||||
new_devices="$( bluetoothctl devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' | grep -vf "<(echo $paired_devices)" )"
|
||||
else
|
||||
new_devices="$( bluetoothctl devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' )"
|
||||
fi
|
||||
echo new_devices:"$new_devices".
|
||||
echo new_devices:$new_devices.
|
||||
[ $new_devices = "" ] && options="rescan" || options=$(echo "$new_devices" && echo 'rescan')
|
||||
choice=$( echo "$options" | dmenu -l 10 -i -p 'pair with which device?' )
|
||||
if [ -n "$choice" ]; then
|
||||
if [ "$choice" = "rescan" ]; then
|
||||
start_scan="$( date +'%s')"
|
||||
pair
|
||||
fi
|
||||
bt_IDS="$( bluetoothctl devices | awk '{print $2}' )"
|
||||
dev_no=$( echo "$new_devices" | nl | grep "$choice" | awk '{print $1}')
|
||||
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
|
||||
|
||||
bluetoothctl pair "$dev_id" && sleep 2
|
||||
bluetoothctl connect "$dev_id"
|
||||
if $AUTOTRUST; then
|
||||
bluetoothctl trust "$dev_id"
|
||||
fi
|
||||
#if device is not already hard coded as paired, add to paired devices list
|
||||
if [ $( grep "$dev_id" "$PAIRLIST") = "" ]
|
||||
then
|
||||
echo to be added to "$PAIRLIST":
|
||||
echo Device "$dev_id" "$choice"
|
||||
echo Device "$dev_id" "$choice" >> "$PAIRLIST"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case $choice in
|
||||
"turn on") bluetoothctl power on;;
|
||||
"turn off") bluetoothctl power off;;
|
||||
"scan on") bluetoothctl power on && echo power on && sleep 2
|
||||
([ -n "$TERMINAL" ] && $TERMINAL -e bluetoothctl scan on ) || st bluetoothctl scan on;;
|
||||
"pair") pair;;
|
||||
"unpair") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?')
|
||||
if [ -n "$choice" ]; then
|
||||
dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}')
|
||||
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
|
||||
bluetoothctl remove "$dev_id"
|
||||
#remove device to unpair from hard coded paired devices list
|
||||
new_paired_list="$( grep -v "$dev_id" "$PAIRLIST" )"
|
||||
echo "$new_paired_list" > "$PAIRLIST" #needs to be done with temp var, can't read from file and pipe into it at the same time
|
||||
fi;;
|
||||
"trust") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?')
|
||||
if [ -n "$choice" ]; then
|
||||
dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}')
|
||||
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
|
||||
bluetoothctl trust "$dev_id"
|
||||
fi;;
|
||||
"disconnect") choice=$( echo "$paired_devices" | dmenu -l 10 -i -p 'remove which paired device?')
|
||||
if [ -n "$choice" ]; then
|
||||
dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}')
|
||||
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}' )
|
||||
bluetoothctl disconnect "$dev_id"
|
||||
fi;;
|
||||
*)
|
||||
echo "$choice"
|
||||
dev_no=$( echo "$paired_devices" | nl | grep -P "[0-9]+\t$choice$" | awk '{print $1}')
|
||||
dev_id=$( echo "$bt_IDS" | nl | grep -P "^.*$dev_no\t" | awk '{print $2}')
|
||||
bluetoothctl power on
|
||||
bluetoothctl pair "$dev_id"
|
||||
bluetoothctl connect "$dev_id";;
|
||||
esac
|
||||
cleanup
|
26
.local/bin/cabl
Executable file
26
.local/bin/cabl
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# Dependencies are xclip and xorg-xprop.
|
||||
# qrencode required for qrcode generation.
|
||||
# groff/zathura required for man pages.
|
||||
prim="$(xclip -o -selection 'clipboard')"; [ -z "$prim" ] && exit
|
||||
|
||||
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
||||
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
|
||||
cd "$(readlink /proc/"$PID"/cwd)"
|
||||
[ -f "$prim" ] && xdg-open "$prim" && exit
|
||||
[ -d "$prim" ] && "$TERMINAL" "$prim" && exit
|
||||
|
||||
websearch() { "$BROWSER" "https://duckduckgo.com/?q=$@" ;}
|
||||
wikipedia() { "$BROWSER" "https://en.wikipedia.org/wiki/$@" ;}
|
||||
wiktionary() { "$BROWSER" "https://en.wiktionary.org/wiki/$@" ;}
|
||||
maps() { "$BROWSER" "https://www.openstreetmap.org/search?query=$@" ;}
|
||||
ebay() { "$BROWSER" "https://www.ebay.com/sch/$@" ;}
|
||||
|
||||
echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && gotourl() { "$BROWSER" "$@" ;}
|
||||
echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && email() { xdg-email "$@" ;}
|
||||
command -v qrencode >/dev/null && qrcode() { qrencode "$@" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;}
|
||||
man -k "^$prim$" >/dev/null && manual() { man -Tpdf "$prim" | zathura - ;}
|
||||
|
||||
func="$(declare -F | awk '{print $3}' | dmenu -p "Plumb \"$(echo "$prim" | cut -c -30)\" to?" -i -l 15)"
|
||||
|
||||
[ -z "$func" ] || "$func" "$prim"
|
10
.local/bin/castscreen
Executable file
10
.local/bin/castscreen
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
xrandr --output eDP-1 --mode 1920x1080 --auto
|
||||
xrdb -merge ~/.config/X11/Xres_casting
|
||||
wal -q -i ~/.config/wall.png -b '#000000'
|
||||
xdotool key super+F2
|
||||
st mkchromecast --video --control --screencast
|
||||
xrandr --output eDP-1 --mode 3200x1800 --auto
|
||||
xrdb -merge ~/.config/X11/Xresources
|
||||
wal -q -i ~/.config/wall.png -b '#000000'
|
||||
xdotool key super+F2
|
40
.local/bin/compiler
Executable file
40
.local/bin/compiler
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script will compile or run another finishing operation on a document. I
|
||||
# have this script run via vim.
|
||||
#
|
||||
# Compiles .tex. groff (.mom, .ms), .rmd, .md. Opens .sent files as sent
|
||||
# presentations. Runs scripts based on extention or shebang
|
||||
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
base="${file%.*}"
|
||||
|
||||
cd "$dir" || exit
|
||||
|
||||
textype() { \
|
||||
command="pdflatex"
|
||||
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
grep -i addbibresource "$file" >/dev/null &&
|
||||
biber --input-directory "$dir" "$base" &&
|
||||
$command --output-directory="$dir" "$base" &&
|
||||
$command --output-directory="$dir" "$base"
|
||||
}
|
||||
|
||||
case "$file" in
|
||||
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
||||
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
|
||||
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
|
||||
*\.[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.md) pandoc "$file" -V geometry:margin=1in --pdf-engine=xelatex -o "$base".pdf ;;
|
||||
*config.h) sudo make install ;;
|
||||
*\.c) cc "$file" -o "$base" && "$base" ;;
|
||||
*\.py) python "$file" ;;
|
||||
*\.m) octave "$file" ;;
|
||||
*\.scad) openscad -o "$base".stl "$file" ;;
|
||||
*\.go) go run "$file" ;;
|
||||
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
esac
|
11
.local/bin/cron/IMPORTANT_NOTE.md
Normal file
11
.local/bin/cron/IMPORTANT_NOTE.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Important Note
|
||||
|
||||
These cronjobs have components that require information about your current display to display notifications correctly.
|
||||
|
||||
When you add them as cronjobs, I recommend you precede the command with commands as those below:
|
||||
|
||||
```
|
||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here
|
||||
```
|
||||
|
||||
This ensures that notifications will display, xdotool commands will function and environmental variables will work as well.
|
19
.local/bin/cron/checkup
Executable file
19
.local/bin/cron/checkup
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Syncs repositories and downloads updates, meant to be run as a cronjob.
|
||||
|
||||
ping -q -c 1 1.1.1.1 > /dev/null || exit
|
||||
|
||||
notify-send "📦 Repository Sync" "Checking for package updates..."
|
||||
|
||||
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
|
||||
|
||||
Check your internet connection, if pacman is already running, or run update manually to see errors."
|
||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
||||
|
||||
if pacman -Qu | grep -v "\[ignored\]"
|
||||
then
|
||||
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
|
||||
else
|
||||
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
|
||||
fi
|
9
.local/bin/cron/cronbat
Executable file
9
.local/bin/cron/cronbat
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Notify me with notify-send if my battery is below 25%.
|
||||
# You can set this to run via cron.
|
||||
|
||||
[ "$(cat /sys/class/power_supply/BAT0/status)" = "Charging" ] && exit
|
||||
[ "$(cat /sys/class/power_supply/BAT0/capacity)" -lt 25 ] &&
|
||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1001/bus &&
|
||||
notify-send -u critical "Battery critically low."
|
6
.local/bin/cron/crontog
Executable file
6
.local/bin/cron/crontog
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Toggles all cronjobs off/on.
|
||||
# Stores disabled crontabs in ~/.consaved until restored.
|
||||
|
||||
([ -f ${XDG_CONFIG_HOME:-$HOME/.config}/cronsaved ] && crontab - < ${XDG_CONFIG_HOME:-$HOME/.config}/cronsaved && rm ${XDG_CONFIG_HOME:-$HOME/.config}/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > ${XDG_CONFIG_HOME:-$HOME/.config}/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")
|
17
.local/bin/cron/newsup
Executable file
17
.local/bin/cron/newsup
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set as a cron job to check for new RSS entries for newsboat.
|
||||
# If newsboat is open, sends it an "R" key to refresh.
|
||||
|
||||
ping -q -c 1 1.1.1.1 > /dev/null || exit
|
||||
|
||||
/usr/bin/notify-send "📰 Updating RSS feeds..."
|
||||
|
||||
ps ax | grep -q newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
|
||||
|
||||
echo 🔃 > /tmp/newsupdate
|
||||
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
|
||||
/usr/bin/newsboat -x reload
|
||||
rm -f /tmp/newsupdate
|
||||
pkill -RTMIN+6 "${STATUSBAR:-dwmblocks}"
|
||||
/usr/bin/notify-send "📰 RSS feed update complete."
|
13
.local/bin/cv
Executable file
13
.local/bin/cv
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
source $HOME/.config/aliasrc
|
||||
alldata="/tmp/allfiles"
|
||||
videos="/tmp/videos"
|
||||
du -a ~/vids/* --time | sort -u | awk '!($1="")' | sort -bg | awk '!($1="")' | awk '!($1="")' | sed 's/^ //' | tac > $alldata
|
||||
touch $videos
|
||||
while read line; do
|
||||
[ -f "$line" ] && echo $line >> $videos
|
||||
done <$alldata
|
||||
choice=$( cat $videos | dmenu -i -l 50 -p "Choose a video to watch:" )
|
||||
[ -n "$choice" ] && st mkchromecast --video --control -i "$choice"
|
||||
rm -f "$alldata"
|
||||
rm -f "$videos"
|
19
.local/bin/ddspawn
Executable file
19
.local/bin/ddspawn
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Toggle floating dropdown terminal in i3, or start if non-existing.
|
||||
# $1 is the script run in the terminal.
|
||||
# All other args are terminal settings.
|
||||
# Terminal names are in dropdown_* to allow easily setting i3 settings.
|
||||
|
||||
[ -z "$1" ] && exit
|
||||
|
||||
script=$1
|
||||
shift
|
||||
if xwininfo -tree -root | grep "(\"dropdown_$script\" ";
|
||||
then
|
||||
echo "Window detected."
|
||||
i3 "[instance=\"dropdown_$script\"] scratchpad show; [instance=\"dropdown_$script\"] move position center"
|
||||
else
|
||||
echo "Window not detected... spawning."
|
||||
i3 "exec --no-startup-id $TERMINAL -n dropdown_$script $@ -e $script"
|
||||
fi
|
83
.local/bin/displayselect
Executable file
83
.local/bin/displayselect
Executable file
@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A UI for detecting and selecting all displays. Probes xrandr for connected
|
||||
# displays and lets user select one to use. User may also select "manual
|
||||
# selection" which opens arandr.
|
||||
|
||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
|
||||
# Mirror displays using native resolution of external display and a scaled
|
||||
# version for the internal display
|
||||
if [ "$mirror" = "yes" ]; then
|
||||
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
|
||||
internal=$(echo "$screens" | grep -v "$external")
|
||||
|
||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_ext_x=$(echo $res_external | sed 's/x.*//')
|
||||
res_ext_y=$(echo $res_external | sed 's/.*x//')
|
||||
res_int_x=$(echo $res_internal | sed 's/x.*//')
|
||||
res_int_y=$(echo $res_internal | sed 's/.*x//')
|
||||
|
||||
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 \
|
||||
--output "$internal" --auto --same-as "$external" \
|
||||
--scale "$scale_x"x"$scale_y"
|
||||
else
|
||||
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary")
|
||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||
fi
|
||||
}
|
||||
|
||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
|
||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
|
||||
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
|
||||
}
|
||||
|
||||
multimon() { # Multi-monitor handler.
|
||||
case "$(echo "$screens" | wc -l)" in
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
esac ;}
|
||||
|
||||
onescreen() { # If only one output available or chosen.
|
||||
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$1" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ')
|
||||
}
|
||||
|
||||
postrun() { # Stuff to run to clean up.
|
||||
setbg # Fix background if screen size/arangement has changed.
|
||||
remaps # Re-remap keys if keyboard added (for laptop bases)
|
||||
{ killall dunst ; setsid dunst & } >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||
|
||||
# If there's only one screen
|
||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
|
||||
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
|
||||
|
||||
# Get user choice including multi-monitor and manual selection:
|
||||
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
||||
case "$chosen" in
|
||||
"manual selection") arandr ; exit ;;
|
||||
"multi-monitor") multimon ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
||||
|
||||
postrun
|
78
.local/bin/dmenu-recent-aliases
Executable file
78
.local/bin/dmenu-recent-aliases
Executable file
@ -0,0 +1,78 @@
|
||||
#!/bin/zsh
|
||||
#cache=~/.cache/dmenu_run
|
||||
freq="$HOME/.cache/dmenu_history_test"
|
||||
alias_file="$HOME/.config/aliasrc"
|
||||
dmenucmd='dmenu -i '
|
||||
|
||||
source $alias_file
|
||||
|
||||
#pull our previously run commands in
|
||||
history=$(<$freq)
|
||||
#for ones that have arguments, condense them down to an asterisk
|
||||
history=$(sed "s/[[:space:]].*/*/" <<< "$history")
|
||||
|
||||
#generate list of commands including functions and alias'
|
||||
#tail command gets rid of a few of the weird bash builtins
|
||||
#at the beginning of the list
|
||||
cache=$(compgen -a; compgen -c | grep -vxF "$(compgen -a)" | sort | tail -n +10)
|
||||
|
||||
# sort history by frequency of use
|
||||
sorted=$(sort <<< "$history" | uniq -c | sort -hr | colrm 1 8)
|
||||
filter=$(sed 's/[*;]*$//' <<< "$sorted")
|
||||
|
||||
echo "$filter"
|
||||
# grep removes the duplicates from the unsorted list
|
||||
cache_deduped=$(grep -vxF "$filter" <<< "$cache")
|
||||
|
||||
# run the actual dmenu and let the user choose a command
|
||||
cmd="$(echo "$sorted"$'\n'"$cache_deduped" | $dmenucmd)"
|
||||
|
||||
# To remove a file from history:
|
||||
# Trail the selected item with ;remove
|
||||
if [[ $cmd == *";remove" ]]; then
|
||||
cmd=${cmd/;remove/}
|
||||
grep -vx "$cmd" $freq > temp
|
||||
mv temp $freq
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# expand an asterisked command to include argument history
|
||||
regex='.+[*]$'
|
||||
if [[ "$cmd" =~ $regex ]]; then
|
||||
history=$(grep "${cmd/[*]/}" $freq)
|
||||
sorted=$(sort <<< "$history" | uniq -c | sort -hr | colrm 1 8)
|
||||
# remove trailing whitespace and asterisks from arguments
|
||||
cmd=$(sed 's/[[:space:]*]*$//' <<< "$@")
|
||||
dmenucmd+=' -l 17'
|
||||
(sleep .1; xdotool key Tab) &
|
||||
cmd="$(echo "$sorted"$'\n'"$cache" | $dmenucmd)"
|
||||
if [[ $cmd == *";remove" ]]; then
|
||||
cmd=${cmd/;remove/}
|
||||
egrep -vx "$cmd" $freq > temp
|
||||
mv temp $freq
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ "$cmd" == "" ]; then
|
||||
# remember which commands have been run
|
||||
echo "$cmd" >> $freq
|
||||
cmdexec=$(alias | grep "${cmd/;/}=" | cut -f2 -d "'" | tr -d "'")
|
||||
if [ -z "$cmdexec" ]; then
|
||||
cmdexec=${cmd/;/}
|
||||
fi
|
||||
|
||||
# open a command up in a terminal
|
||||
# a second semicolon holds the xterm open
|
||||
if [[ $cmd == *";;" ]]; then
|
||||
cmdexec="xterm -hold -e $cmdexec"
|
||||
elif [[ $cmd == *";" ]]; then
|
||||
cmdexec="xterm -e $cmdexec"
|
||||
fi
|
||||
|
||||
# Workaround to run functions...
|
||||
echo "$cmdexec" | compgen -F "$cmdexec" | zsh -i
|
||||
# ...and aliases
|
||||
echo "$cmdexec" | zsh -i
|
||||
fi
|
||||
|
66
.local/bin/dmenumount
Executable file
66
.local/bin/dmenumount
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Gives a dmenu prompt to mount unmounted drives and Android phones. If
|
||||
# they're in /etc/fstab, they'll be mounted automatically. Otherwise, you'll
|
||||
# be prompted to give a mountpoint from already existsing directories. If you
|
||||
# input a novel directory, it will prompt you to create that directory.
|
||||
|
||||
getmount() { \
|
||||
[ -z "$chosen" ] && exit 1
|
||||
# shellcheck disable=SC2086
|
||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
||||
[ "$mp" = "" ] && exit 1
|
||||
if [ ! -d "$mp" ]; then
|
||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||
fi
|
||||
}
|
||||
|
||||
mountusb() { \
|
||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||
case "$partitiontype" in
|
||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
||||
esac
|
||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||
}
|
||||
|
||||
mountandroid() { \
|
||||
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
||||
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
||||
getmount "$HOME -maxdepth 3 -type d"
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
||||
case $choice in
|
||||
USB) mountusb ;;
|
||||
Android) mountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||
|
||||
if [ -z "$usbdrives" ]; then
|
||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||
echo "Android device(s) detected."
|
||||
mountandroid
|
||||
else
|
||||
if [ -z "$anddrives" ]; then
|
||||
echo "USB drive(s) detected."
|
||||
mountusb
|
||||
else
|
||||
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
6
.local/bin/dmenupass
Executable file
6
.local/bin/dmenupass
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is the SUDO_ASKPASS variable, meaning that it will be used as a
|
||||
# password prompt if needed.
|
||||
|
||||
dmenu -fn Monospace-18 -P -p "$1" <&- && echo
|
120
.local/bin/dmenurecord
Executable file
120
.local/bin/dmenurecord
Executable file
@ -0,0 +1,120 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# `$0`: Ask for recording type via dmenu
|
||||
# `$0 screencast`: Record both audio and screen
|
||||
# `$0 video`: Record only screen
|
||||
# `$0 audio`: Record only audio
|
||||
# `$0 kill`: Kill existing recording
|
||||
#
|
||||
# If there is already a running instance, user will be prompted to end it.
|
||||
|
||||
updateicon() { \
|
||||
echo "$1" > /tmp/recordingicon
|
||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||
}
|
||||
|
||||
killrecording() {
|
||||
recpid="$(cat /tmp/recordingpid)"
|
||||
# kill with SIGTERM, allowing finishing touches.
|
||||
kill -15 "$recpid"
|
||||
rm -f /tmp/recordingpid
|
||||
updateicon ""
|
||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
|
||||
sleep 3
|
||||
kill -9 "$recpid"
|
||||
exit
|
||||
}
|
||||
|
||||
screencast() { \
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-r 30 \
|
||||
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️🎙️"
|
||||
}
|
||||
|
||||
screencast_old() { \
|
||||
ffmpeg -y \
|
||||
-f x11grab \
|
||||
-framerate 60 \
|
||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-f alsa -i default \
|
||||
-r 30 \
|
||||
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️🎙️"
|
||||
}
|
||||
|
||||
|
||||
|
||||
video() { ffmpeg \
|
||||
-f x11grab \
|
||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||
-i "$DISPLAY" \
|
||||
-c:v libx264 -qp 0 -r 30 \
|
||||
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️"
|
||||
}
|
||||
|
||||
webcamhidef() { ffmpeg \
|
||||
-f v4l2 \
|
||||
-i /dev/video0 \
|
||||
-video_size 1920x1080 \
|
||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "🎥"
|
||||
}
|
||||
|
||||
webcam() { ffmpeg \
|
||||
-f v4l2 \
|
||||
-i /dev/video0 \
|
||||
-video_size 640x480 \
|
||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "🎥"
|
||||
}
|
||||
|
||||
|
||||
audio() { \
|
||||
ffmpeg \
|
||||
-f alsa -i default \
|
||||
-c:a flac \
|
||||
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "🎙️"
|
||||
}
|
||||
|
||||
askrecording() { \
|
||||
choice=$(printf "screencast\\nvideo\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
|
||||
case "$choice" in
|
||||
screencast) screencast;;
|
||||
audio) audio;;
|
||||
video) video;;
|
||||
webcam) webcam;;
|
||||
"webcam (hi-def)") webcamhidef;;
|
||||
esac
|
||||
}
|
||||
|
||||
asktoend() { \
|
||||
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
||||
[ "$response" = "Yes" ] && killrecording
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
screencast) screencast;;
|
||||
audio) audio;;
|
||||
video) video;;
|
||||
kill) killrecording;;
|
||||
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
|
||||
esac
|
44
.local/bin/dmenuumount
Executable file
44
.local/bin/dmenuumount
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu prompt to unmount drives.
|
||||
# Provides you with mounted partitions, select one to unmount.
|
||||
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||
|
||||
unmountusb() {
|
||||
[ -z "$drives" ] && exit
|
||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
unmountandroid() { \
|
||||
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
||||
case "$choice" in
|
||||
USB) unmountusb ;;
|
||||
Android) unmountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||
|
||||
if ! grep simple-mtpfs /etc/mtab; then
|
||||
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||
echo "Unmountable USB drive detected."
|
||||
unmountusb
|
||||
else
|
||||
if [ -z "$drives" ]
|
||||
then
|
||||
echo "Unmountable Android device detected."
|
||||
unmountandroid
|
||||
else
|
||||
echo "Unmountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
18
.local/bin/dmenuunicode
Executable file
18
.local/bin/dmenuunicode
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The famous "get a menu of emojis to copy" script.
|
||||
|
||||
# Must have xclip installed to even show menu.
|
||||
xclip -h 2>/dev/null || exit 1
|
||||
|
||||
chosen=$(cut -d ';' -f1 ${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji | dmenu -i -l 20 | sed "s/ .*//")
|
||||
|
||||
[ "$chosen" != "" ] || exit
|
||||
|
||||
# If you run this command with an argument, it will automatically insert the character.
|
||||
if [ -n "$1" ]; then
|
||||
xdotool key Shift+Insert
|
||||
else
|
||||
echo "$chosen" | tr -d '\n' | xclip -selection clipboard
|
||||
notify-send "'$chosen' copied to clipboard." &
|
||||
fi
|
3
.local/bin/dropdowncalc
Executable file
3
.local/bin/dropdowncalc
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
ifinstalled bc && echo "Welcome to the Calculator." && bc -lq
|
21
.local/bin/ducksearch
Executable file
21
.local/bin/ducksearch
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Gives a dmenu prompt to search DuckDuckGo.
|
||||
# Without input, will open DuckDuckGo.com.
|
||||
# URLs will be directly handed to the browser.
|
||||
# Anything else, it search it.
|
||||
browser=${BROWSER:-firefox}
|
||||
|
||||
pgrep -x dmenu && exit
|
||||
|
||||
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
||||
|
||||
if [ "$choice" = "🦆" ]; then
|
||||
$browser "https://duckduckgo.com"
|
||||
else
|
||||
if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then
|
||||
$browser "$choice"
|
||||
else
|
||||
string="$(echo $choice | sed 's/\ /+/g')"
|
||||
$browser "https://duckduckgo.com/?q=$string&t=ffab&atb=v1-1"
|
||||
fi
|
||||
fi
|
44
.local/bin/ext
Executable file
44
.local/bin/ext
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A general, all-purpose extraction script. Not all extraction programs here
|
||||
# are installed by LARBS automatically.
|
||||
#
|
||||
# Default behavior: Extract archive into new directory
|
||||
# Behavior with `-c` option: Extract contents into current directory
|
||||
|
||||
while getopts "hc" o; do case "${o}" in
|
||||
c) extracthere="True" ;;
|
||||
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit ;;
|
||||
esac done
|
||||
|
||||
if [ -z "$extracthere" ]; then
|
||||
archive="$(readlink -f "$*")" &&
|
||||
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
|
||||
mkdir -p "$directory" &&
|
||||
cd "$directory" || exit
|
||||
else
|
||||
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")"
|
||||
fi
|
||||
|
||||
[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit
|
||||
|
||||
if [ -f "$archive" ] ; then
|
||||
case "$archive" in
|
||||
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
|
||||
*.tar.xz) tar -xf "$archive" ;;
|
||||
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
|
||||
*.lzma) unlzma "$archive" ;;
|
||||
*.bz2) bunzip2 "$archive" ;;
|
||||
*.rar) unrar x -ad "$archive" ;;
|
||||
*.gz) gunzip "$archive" ;;
|
||||
*.tar) tar xvf "$archive" ;;
|
||||
*.zip) unzip "$archive" ;;
|
||||
*.Z) uncompress "$archive" ;;
|
||||
*.7z) 7z x "$archive" ;;
|
||||
*.xz) unxz "$archive" ;;
|
||||
*.exe) cabextract "$archive" ;;
|
||||
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
|
||||
esac
|
||||
else
|
||||
printf "File \"%s\" not found.\\n" "$archive"
|
||||
fi
|
8
.local/bin/f2py
Executable file
8
.local/bin/f2py
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy.f2py.f2py2e import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
8
.local/bin/f2py3
Executable file
8
.local/bin/f2py3
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy.f2py.f2py2e import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
8
.local/bin/f2py3.8
Executable file
8
.local/bin/f2py3.8
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy.f2py.f2py2e import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
5
.local/bin/getkeys
Executable file
5
.local/bin/getkeys
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
cat ${XDG_DATA_HOME:-$HOME/.local/share}/larbs/getkeys/"$1" 2>/dev/null && exit
|
||||
echo "Run command with one of the following arguments for info about that program:"
|
||||
ls ${XDG_DATA_HOME:-$HOME/.local/share}/larbs/getkeys
|
22
.local/bin/i3cmds/hover
Executable file
22
.local/bin/i3cmds/hover
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -z "$1" ] && exit # If $1 is left, hovers in the bottom left, if right, the bottom right
|
||||
current=$(xdotool getwindowfocus)
|
||||
newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3))
|
||||
newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3))
|
||||
centerwidth=$(( $(xdotool getdisplaygeometry | awk '{print $1}') / 2))
|
||||
newsize=$(xdotool getwindowgeometry "$current" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}')
|
||||
newwidth=$(xdotool getwindowgeometry "$current" | grep Geometry | grep -o " [0-9]*")
|
||||
baroffset=47
|
||||
|
||||
case "$1" in
|
||||
left) horizontal=0; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
|
||||
right) horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) ; vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) ;;
|
||||
center) echo "$centerwidth"
|
||||
horizontal=$(( ( $(xdotool getdisplaygeometry | awk '{print $1}') - centerwidth ) / 2 ));
|
||||
vertical=$baroffset
|
||||
newheight=$(( $(xdotool getdisplaygeometry | awk '{print $2}' ) - baroffset -5))
|
||||
newwidth=$centerwidth;;
|
||||
esac
|
||||
xdotool windowsize "$current" $newwidth $newheight
|
||||
xdotool windowmove "$current" $horizontal $vertical
|
28
.local/bin/i3cmds/i3resize
Executable file
28
.local/bin/i3cmds/i3resize
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script was made by `goferito` on Github.
|
||||
# Some cleanup by Luke.
|
||||
|
||||
[ -z "$1" ] && echo "No direction provided" && exit 1
|
||||
distanceStr="2 px or 2 ppt"
|
||||
|
||||
moveChoice() {
|
||||
i3-msg resize "$1" "$2" "$distanceStr" | grep '"success":true' || \
|
||||
i3-msg resize "$3" "$4" "$distanceStr"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
moveChoice grow up shrink down
|
||||
;;
|
||||
down)
|
||||
moveChoice shrink up grow down
|
||||
;;
|
||||
left)
|
||||
moveChoice shrink right grow left
|
||||
;;
|
||||
right)
|
||||
moveChoice grow right shrink left
|
||||
;;
|
||||
esac
|
||||
|
7
.local/bin/i3cmds/killrecording
Executable file
7
.local/bin/i3cmds/killrecording
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
kill -9 "$(cat ~/.recordingpid)"
|
||||
|
||||
# Update i3bar.
|
||||
echo "" > ~/.recordingicon
|
||||
pkill -RTMIN+9 i3blocks
|
9
.local/bin/i3cmds/maimpick
Executable file
9
.local/bin/i3cmds/maimpick
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
||||
"a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
|
||||
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
|
||||
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
|
||||
esac
|
7
.local/bin/i3cmds/prompt
Executable file
7
.local/bin/i3cmds/prompt
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# A dmenu binary prompt script.
|
||||
# Gives a dmenu prompt labeled with $1 to perform command $2.
|
||||
# For example:
|
||||
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
|
||||
|
||||
[ "$(printf "No\\nYes" | dmenu -i -n -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2
|
5
.local/bin/i3cmds/samedir
Executable file
5
.local/bin/i3cmds/samedir
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
||||
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
|
||||
cd "$(readlink /proc/"$PID"/cwd)"
|
||||
"$TERMINAL"
|
10
.local/bin/i3cmds/td-toggle
Executable file
10
.local/bin/i3cmds/td-toggle
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
||||
if pgrep -x transmission-da >/dev/null ;
|
||||
then
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon killed."
|
||||
else
|
||||
ifinstalled transmission-cli || exit
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon started."
|
||||
fi
|
||||
sleep 3 && pkill -RTMIN+7 i3blocks
|
5
.local/bin/i3cmds/tmuxdd
Executable file
5
.local/bin/i3cmds/tmuxdd
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is the script that i3 runs to either start tmux in
|
||||
# the dropdown terminal or log into a previous session.
|
||||
tmux a || tmux
|
10
.local/bin/i3cmds/toggle-welcome
Executable file
10
.local/bin/i3cmds/toggle-welcome
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Toggles the LARBS welcome message.
|
||||
|
||||
PIC="${XDG_DATA_HOME:-$HOME/.local/share}/larbs/larbs.png"
|
||||
|
||||
grep LARBSWELCOME "$HOME/.xprofile" &&
|
||||
( sed -i "/LARBSWELCOME/d" ~/.xprofile && notify-send -i "$PIC" "LARBS welcome message" "Welcome message disabled. Press Super+Shift+F1 again to reverse." ) ||
|
||||
( echo "notify-send -i \"$PIC\" \"Welcome to LARBS\" \"Press super+F1 for the help menu.\" # LARBSWELCOME" >> ~/.xprofile &&
|
||||
notify-send -i "$PIC" "LARBS welcome message" "Welcome message re-enabled." )
|
4
.local/bin/i3cmds/toggletouchpad
Executable file
4
.local/bin/i3cmds/toggletouchpad
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Toggle touchpad. Requires xf86-input-synaptics.
|
||||
(synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0)>/dev/null && echo "TouchPad reactivated." && exit
|
||||
synclient TouchpadOff=1 && echo "TouchPad deactivated."
|
6
.local/bin/i3cmds/torwrap
Executable file
6
.local/bin/i3cmds/torwrap
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
ifinstalled transmission-remote-cli transmission-cli || exit
|
||||
|
||||
! pgrep -x transmission-da >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks
|
||||
|
||||
$TERMINAL -e transmission-remote-cli
|
2
.local/bin/i3cmds/winresize
Executable file
2
.local/bin/i3cmds/winresize
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo "📐" | dmenu -p "Give width and height:" | xargs xdotool windowsize "$(xdotool getwindowfocus)"
|
8
.local/bin/ifinstalled
Executable file
8
.local/bin/ifinstalled
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Some optional functions in LARBS require programs not installed by default. I
|
||||
# use this little script to check to see if a command exists and if it doesn't
|
||||
# it informs the user that they need that command to continue. This is used in
|
||||
# various other scripts for clarity's sake.
|
||||
|
||||
pacman -Qq "$1" >/dev/null || { notify-send "📦 $1" "must be installed for this function." && exit 1 ;}
|
9
.local/bin/launch_polybar
Executable file
9
.local/bin/launch_polybar
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Terminate already running bar instances
|
||||
killall -q polybar
|
||||
|
||||
# Wait until the processes have been shut down
|
||||
while pidof polybar >/dev/null; do sleep 1; done
|
||||
|
||||
for i in $(polybar -m | awk -F: '{print $1}'); do MONITOR=$i polybar default & done
|
9
.local/bin/lf-select
Executable file
9
.local/bin/lf-select
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Reads file names from stdin and selects them in lf.
|
||||
|
||||
while read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
lf -remote "send select \"$file\""
|
||||
lf -remote "send toggle"
|
||||
done
|
28
.local/bin/lmc
Executable file
28
.local/bin/lmc
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
NUM="${2:-5}"
|
||||
|
||||
# Uncomment the following line to use Pulseaudio.
|
||||
# PULSE=true
|
||||
|
||||
if [ "$PULSE" ]; then
|
||||
toggle() { pulsemixer --toggle-mute ;}
|
||||
mute() { pulsemixer --mute ;}
|
||||
up() { pulsemixer --change-volume +"$NUM" ;}
|
||||
down() { pulsemixer --change-volume -"$NUM" ;}
|
||||
control() { pulsemixer ;}
|
||||
else
|
||||
toggle() { amixer sset Master toggle ;}
|
||||
mute() { amixer sset Master mute ;}
|
||||
up() { amixer sset Master "$NUM"%+ ;}
|
||||
down() { amixer sset Master "$NUM"%- ;}
|
||||
control() { alsamixer ;}
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
toggle) toggle ;;
|
||||
mute) mute ;;
|
||||
up) up ;;
|
||||
down) down ;;
|
||||
control) control ;;
|
||||
esac
|
14
.local/bin/maimpick
Executable file
14
.local/bin/maimpick
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is bound to Shift+PrintScreen by default, requires maim. It lets you
|
||||
# choose the kind of screenshot to take, including copying the image or even
|
||||
# highlighting an area to copy. scrotcucks on suicidewatch right now.
|
||||
|
||||
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
||||
"a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
|
||||
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
|
||||
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
|
||||
esac
|
12
.local/bin/manga-py
Executable file
12
.local/bin/manga-py
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: 'manga-py==1.19.7','console_scripts','manga-py'
|
||||
__requires__ = 'manga-py==1.19.7'
|
||||
import re
|
||||
import sys
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(
|
||||
load_entry_point('manga-py==1.19.7', 'console_scripts', 'manga-py')()
|
||||
)
|
8
.local/bin/markdown_py
Executable file
8
.local/bin/markdown_py
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from markdown.__main__ import run
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(run())
|
8
.local/bin/mpd-module-update
Executable file
8
.local/bin/mpd-module-update
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This loop will update the mpd statusbar module whenever a command changes the
|
||||
# music player's status. mpd must be running on X's start for this to work.
|
||||
|
||||
while : ; do
|
||||
mpc idle >/dev/null && pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" || break
|
||||
done
|
304
.local/bin/muccadoro
Executable file
304
.local/bin/muccadoro
Executable file
@ -0,0 +1,304 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o nounset -o pipefail
|
||||
# Before doing anything, check if the required programs are installed. See
|
||||
# <https://stackoverflow.com/q/592620>. Some of these can probably be reasonably assumed
|
||||
# to be present, but err on the side of caution.
|
||||
for prog in awk cowsay figlet notify-send stty tput; do
|
||||
if ! hash "$prog" 2>/dev/null; then
|
||||
printf 'muccadoro: %s: command not found\n' "$prog" >&2
|
||||
exit 127
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
temp_loc=/tmp/pomptemptimes
|
||||
temp_timeloc=/tmp/mucc_time
|
||||
statusbar="dwmblocks"
|
||||
update_signal="3"
|
||||
|
||||
freetime=${2:-w}
|
||||
if [ "$freetime" = "f" ]; then
|
||||
temp_loc=/tmp/pomptemptimesft
|
||||
fi
|
||||
|
||||
declare -i silly=1
|
||||
|
||||
# http://mywiki.wooledge.org/BashFAQ/035#getopts
|
||||
# http://wiki.bash-hackers.org/howto/getopts_tutorial
|
||||
while getopts ':s' opt; do
|
||||
case $opt in
|
||||
s) (( ++silly ));;
|
||||
esac
|
||||
done
|
||||
shift "$((OPTIND-1))" # Shift off the options and optional --.
|
||||
|
||||
# One pomodoro lasts "$1" minutes. The default duration is 25 minutes.
|
||||
declare -i duration=$((${1:-25}*60)) num_pomodoros=4
|
||||
|
||||
(( silly %= 5 ))
|
||||
if (( silly )); then
|
||||
declare -i silliness=$((2**(4-silly)))
|
||||
# `apps` stands for appearances, of course.
|
||||
declare -a apps=('' '-b' '-d' '-g' '-p' '-s' '-t' '-w' '-e oO' '-e Oo' '-e ><' '-e -o'
|
||||
'-e o-' '-e >o' '-e o<')
|
||||
num_apps=${#apps[@]}
|
||||
cowtell() {
|
||||
app_num=$((RANDOM % (silliness * num_apps)))
|
||||
(( app_num >= num_apps )) && app_num=0
|
||||
cowsay -n ${apps[app_num]}
|
||||
}
|
||||
else
|
||||
cowtell() {
|
||||
cowsay -n
|
||||
}
|
||||
fi
|
||||
|
||||
summary=
|
||||
|
||||
# Standard output must be a terminal. See <https://unix.stackexchange.com/q/91638>. Save
|
||||
# the original stdout to file descriptor 3 (see <https://unix.stackexchange.com/q/80988>).
|
||||
exec 3>&1 &>/dev/tty
|
||||
|
||||
# Save the current terminal settings.
|
||||
initial_tty_settings=$(stty -g)
|
||||
|
||||
# Revert all changed terminal settings (FIXME: restore everything from saved settings) and
|
||||
# print a summary.
|
||||
cleanup() {
|
||||
tput rmcup
|
||||
tput cnorm
|
||||
stty "$initial_tty_settings"
|
||||
[[ $summary ]] && echo -ne "$summary" >&3
|
||||
rm -f $temp_loc
|
||||
rm -f $temp_timeloc
|
||||
pkill -RTMIN+$update_signal $statusbar
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
# Switch to the alternate screen. See <https://unix.stackexchange.com/q/27941>, xterm(1),
|
||||
# terminfo(5), and <https://stackoverflow.com/q/11023929>.
|
||||
tput smcup
|
||||
|
||||
# TODO: explain. See
|
||||
# <http://www.unix.com/shell-programming-and-scripting/176837-bash-hide-terminal-cursor.html>.
|
||||
tput civis
|
||||
|
||||
# Don't echo characters typed on the tty. See <https://unix.stackexchange.com/a/28620>.
|
||||
stty -echo
|
||||
|
||||
# Output empty lines before the message so the message is displayed at the bottom of the
|
||||
# terminal. See <https://stackoverflow.com/a/29314659>. Also, instead of `clear`ing
|
||||
# (which causes flickering), pad all lines of the message with spaces all the way to the
|
||||
# right edge of the terminal, thereby overwriting any currently displayed characters. See
|
||||
# <https://stackoverflow.com/questions/9394408>. TODO: probably just use Bash and not
|
||||
# awk.
|
||||
pad() {
|
||||
awk -v lines="$(tput lines)" -v cols="$(tput cols)" '
|
||||
NR!=1 && FNR==1 { n=lines-NR; for(; n>0; n--) printf "%-"cols"s\n", "" }
|
||||
NR==FNR { next }
|
||||
{ printf "%-"cols"s\n", $0 }' <(echo "$1"){,}
|
||||
}
|
||||
|
||||
pp() {
|
||||
tput cup 0 0 # TODO: explain.
|
||||
pad "$1"
|
||||
}
|
||||
|
||||
ppp() {
|
||||
tput cup 0 0
|
||||
# FIXME: probably just check once if we have lolcat.
|
||||
pad "$1" | { lolcat 2>/dev/null || cat; }
|
||||
}
|
||||
|
||||
declare -a lyrics
|
||||
declare -i line_index=0
|
||||
lyrics=(
|
||||
"Can't stop, addicted to the shindig;"
|
||||
"Chop Top, he says I'm gonna win big;"
|
||||
"Choose not a life of imitation;"
|
||||
"Distant cousin to the reservation;"
|
||||
"Defunct the pistol that you pay for;"
|
||||
"This punk, the feeling that you stay for;"
|
||||
"In time I want to be your best friend;"
|
||||
"East side lovers living on the west end;"
|
||||
"Knocked out but boy you better come to;"
|
||||
"Don't die, you know the truth as some do;"
|
||||
"Go write your message on the pavement;"
|
||||
"Burn so bright I wonder what the wave meant;"
|
||||
)
|
||||
|
||||
declare -i state=0
|
||||
|
||||
cant-stop() {
|
||||
(( state == 2 )) && return
|
||||
state=2
|
||||
tty_settings=$(stty -g)
|
||||
trap '' INT
|
||||
stty susp undef
|
||||
pp "$(cowsay -e '><' -W $(($(tput cols)-3)) ${lyrics[line_index]})"
|
||||
|
||||
((++line_index)); ((line_index%=${#lyrics[@]}))
|
||||
sleep 2 & wait $!
|
||||
stty "$tty_settings"
|
||||
count-state
|
||||
}
|
||||
|
||||
# SIGTSTP handler.
|
||||
on-tstp() {
|
||||
# Signal all processes in the process group $$ (the group leader) to continue. See
|
||||
# kill(1), and <https://unix.stackexchange.com/q/139222>. Pomodoros are not
|
||||
# interruptible.
|
||||
kill -CONT -- -$$
|
||||
if (( state == 1 )); then
|
||||
cant-stop
|
||||
fi
|
||||
}
|
||||
trap on-tstp TSTP
|
||||
|
||||
count-state() {
|
||||
# 130 is the exit status for termination by Ctrl-C. See
|
||||
# <http://www.tldp.org/LDP/abs/html/exitcodes.html>.
|
||||
trap 'trap on-int INT; on-int; return 130' INT
|
||||
state=1
|
||||
}
|
||||
|
||||
dead-state() {
|
||||
trap on-int INT
|
||||
state=0
|
||||
}
|
||||
|
||||
pause-state() {
|
||||
trap on-int INT
|
||||
state=0
|
||||
}
|
||||
|
||||
on-int() {
|
||||
if (( state==0 )); then
|
||||
# We are supposed to kill ourselves with SIGINT instead of using `exit`. See
|
||||
# <http://mywiki.wooledge.org/SignalTrap#Special_Note_On_SIGINT>.
|
||||
trap - INT
|
||||
kill -INT $$
|
||||
elif (( state==1 )); then
|
||||
dead-state
|
||||
elif (( state==2 )); then
|
||||
count-state
|
||||
fi
|
||||
}
|
||||
|
||||
# XXX: beware of bugs due to SIGINT (Ctrl-C) being received during the short timeframe in
|
||||
# which another function invoked by this one is executing. The `return 1` statement of
|
||||
# the SIGINT trap will be ran in the context of the inner function.
|
||||
pomodoro() {
|
||||
count-state
|
||||
while :; do
|
||||
# Handle signals immediately, not after `sleep` exits. See
|
||||
# <http://mywiki.wooledge.org/SignalTrap#When_is_the_signal_handled.3F>.
|
||||
sleep 1 &
|
||||
# See <http://mywiki.wooledge.org/BashFAQ/002>.
|
||||
planned_end_time=$(( $start_time_secs + $duration ))
|
||||
seconds=$(( $planned_end_time - $( date +'%s') ))
|
||||
the_time=$((seconds/60)):$(printf '%02d' $((seconds%60)))
|
||||
# Keep in mind that almost everything causes new values to be assigned to `$?`:
|
||||
# $ false
|
||||
# $ (( $? )) && echo $?
|
||||
# 0
|
||||
# $ false || { (( $? != 148 )) && echo $?; }
|
||||
# 0
|
||||
# In both cases, when `echo $?` is executed, `$?` is no longer 1.
|
||||
fail=$?
|
||||
if (( fail && fail != 148 )); then
|
||||
return $fail
|
||||
fi
|
||||
text=$(figlet -f small "$the_time" ) #remove | cowtell
|
||||
fail=$?
|
||||
if (( ! fail )); then
|
||||
pp "$text"
|
||||
fail=$?
|
||||
echo "$the_time" > $temp_timeloc
|
||||
pkill -RTMIN+$update_signal $statusbar
|
||||
(( fail && fail != 148 )) && return $fail
|
||||
elif (( fail != 148 )); then
|
||||
return $fail
|
||||
fi
|
||||
wait
|
||||
((--seconds <= 0)) && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
flush-stdin() {
|
||||
# See <https://superuser.com/q/276531>.
|
||||
read -r -d '' -t 0.1 -n 1000
|
||||
}
|
||||
|
||||
# FIXME: why `dummy` (http://wiki.bash-hackers.org/commands/builtin/read#press_any_key).
|
||||
pause() {
|
||||
# See <http://wiki.bash-hackers.org/syntax/pe#use_an_alternate_value>.
|
||||
read -r -n 1${1:+ -t $1}
|
||||
}
|
||||
|
||||
for (( n=1; n<=num_pomodoros; ++n )); do
|
||||
declare -i seconds=$duration
|
||||
declare -i start_time_secs=$(date +'%s')
|
||||
start_time=$(date --date "@$start_time_secs" +'%H:%M')
|
||||
pomodoro
|
||||
fail=$?
|
||||
if (( fail == 130 )); then
|
||||
end_time=$(date +'%H:%M')
|
||||
end_time_secs=$(date -d $end_time +'%s')
|
||||
day=$(date '+%Y%b%d')
|
||||
summary+="Abandoned: $start_time to $end_time ($((($end_time_secs - $start_time_secs)/ 60))) $day\n"
|
||||
#summary+="Abandoned: $start_time to $(date +'%H:%M')\n"
|
||||
# Pomodoros are atomic.
|
||||
pp "$(cowsay -d -W $(($(tput cols)-3)) 'You abandoned pomodoro '$n'. Press any' \
|
||||
'key to restart it.')"
|
||||
rm -f $temp_timeloc
|
||||
pkill -RTMIN+$update_signal $statusbar
|
||||
pause
|
||||
(( --n ))
|
||||
continue
|
||||
elif (( fail )); then
|
||||
exit $fail
|
||||
fi
|
||||
pause-state
|
||||
tty_settings=$(stty -g)
|
||||
stty susp undef
|
||||
end_time_secs=$(date +'%s')
|
||||
end_time=$(date --date "@$end_time_secs" +'%H:%M')
|
||||
#end_time_secs=$(date -d $end_time +'%s')
|
||||
#start_time_secs=$(date -d $start_time +'%s')
|
||||
day=$(date '+%Y%b%d')
|
||||
summary+="Pomodoro $n: $start_time to $end_time ($(( ($end_time_secs - $start_time_secs )/60))) $day\n"
|
||||
#summary+="Pomodoro $n: $start_time to $(date +'%H:%M') \n"
|
||||
if (( n!=num_pomodoros )); then
|
||||
start_time=$(date +'%s')
|
||||
notify-send "You completed pomodoro $n. Take a short break (3-5 minutes)."
|
||||
#
|
||||
#
|
||||
echo "($n*$duration)/60" | bc > $temp_loc
|
||||
pkill -RTMIN+$update_signal $statusbar
|
||||
# TODO: it may be nice to create this message asynchronously with `lolcat -f` since
|
||||
# lolcat is a bit slow. That's not a priority, though.
|
||||
ppp "$(cowsay -e '^^' -W $(($(tput cols)-3)) 'You completed pomodoro '$n'. Take' \
|
||||
'a short break (3-5 minutes), then press any key to continue.')"
|
||||
rm -f $temp_timeloc
|
||||
pkill -RTMIN+$update_signal $statusbar
|
||||
flush-stdin
|
||||
if ! pause 180; then
|
||||
pp "$(cowsay -w -W $(($(tput cols)-3)) 'Press any key to continue.')"
|
||||
pause 120 || {
|
||||
notify-send -u critical 'Time to start the next pomodoro.'; pause;
|
||||
}
|
||||
fi
|
||||
break_duration=$((($(date +'%s')-start_time+30)/60))
|
||||
summary+="Break: about $break_duration minute"
|
||||
(( break_duration != 1 )) && summary+=s # plural
|
||||
summary+='\n'
|
||||
fi
|
||||
stty "$tty_settings"
|
||||
done
|
||||
|
||||
notify-send "You completed all $num_pomodoros pomodoros!"
|
||||
|
||||
# vim: tw=90 sts=-1 sw=3 et
|
13
.local/bin/opout
Executable file
13
.local/bin/opout
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# opout: "open output": A general handler for opening a file's intended output,
|
||||
# usually the pdf of a compiled document. I find this useful especially
|
||||
# running from vim.
|
||||
|
||||
basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
|
||||
|
||||
case "$1" in
|
||||
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid xdg-open "$basename".pdf >/dev/null 2>&1 & ;;
|
||||
*.html) setsid "$BROWSER" "$basename".html >/dev/null 2>&1 & ;;
|
||||
*.sent) setsid sent "$1" >/dev/null 2>&1 & ;;
|
||||
esac
|
10
.local/bin/pauseallmpv
Executable file
10
.local/bin/pauseallmpv
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# You might notice all mpv commands are aliased to have this input-ipc-server
|
||||
# thing. That's just for this particular command, which allows us to pause
|
||||
# every single one of them with one command! This is bound to super + shift + p
|
||||
# (with other things) by default and is used in some other places.
|
||||
|
||||
for i in $(ls /tmp/mpvSockets/*); do
|
||||
echo '{ "command": ["set_property", "pause", true] }' | socat - $i;
|
||||
done
|
7
.local/bin/podentr
Executable file
7
.local/bin/podentr
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
# entr command to run `queueandnotify` when newsboat queue is changed
|
||||
|
||||
[ "$(pgrep -x $(basename $0) | wc -l)" -gt 2 ] && exit
|
||||
|
||||
echo ${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue | entr -p queueandnotify 2>/dev/null
|
13
.local/bin/pom
Executable file
13
.local/bin/pom
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
SAVE_DIR=~/eth/pomodoros
|
||||
case $1 in
|
||||
add) start=$2
|
||||
start_secs=$(date -d $start +'%s')
|
||||
end=$3
|
||||
end_secs=$(date -d $end +'%s')
|
||||
duration="$(( ($end_secs - $start_secs)/60 ))"
|
||||
echo "Pomodoro 1: $start to $end ($duration) $(date '+%Y%b%d')" | tee -ai $SAVE_DIR;;
|
||||
*) xdotool key super+shift+9
|
||||
muccadoro $1 | tee -ai "$SAVE_DIR";;
|
||||
esac
|
||||
pkill -RTMIN+3 dwmblocks
|
12
.local/bin/pomft
Executable file
12
.local/bin/pomft
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
SAVE_DIR=~/bks/pomodoros_freetime
|
||||
case $1 in
|
||||
add) start=$2
|
||||
start_secs=$(date -d $start +'%s')
|
||||
end=$3
|
||||
end_secs=$(date -d $end +'%s')
|
||||
duration="$(( ($end_secs - $start_secs)/60 ))"
|
||||
echo "Pomodoro 1: $start to $end ($duration) $(date '+%Y%b%d')" | tee -ai $SAVE_DIR;;
|
||||
*) muccadoro ${1:-25} 'f' | tee -ai "$SAVE_DIR";;
|
||||
esac
|
||||
pkill -RTMIN+3 dwmblocks
|
8
.local/bin/prompt
Executable file
8
.local/bin/prompt
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu binary prompt script.
|
||||
# Gives a dmenu prompt labeled with $1 to perform command $2.
|
||||
# For example:
|
||||
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
|
||||
|
||||
[ "$(printf "No\\nYes" | dmenu -i -n -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2
|
8
.local/bin/pyls
Executable file
8
.local/bin/pyls
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pyls.__main__ import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
12
.local/bin/qndl
Executable file
12
.local/bin/qndl
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $1 is a url; $2 is a command
|
||||
[ -z "$1" ] && exit
|
||||
base="$(basename "$1")"
|
||||
notify-send "⏳ Queuing $base..."
|
||||
cmd="$2"
|
||||
[ -z "$cmd" ] && cmd="youtube-dl --add-metadata"
|
||||
idnum="$(tsp $cmd "$1")"
|
||||
realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")"
|
||||
tsp -D "$idnum" mv "$base" "$realname"
|
||||
tsp -D "$idnum" notify-send "👍 $realname done."
|
14
.local/bin/queueandnotify
Executable file
14
.local/bin/queueandnotify
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Podboat sucks. This script replaces it.
|
||||
# It reads the newsboat queue, queuing downloads with taskspooler.
|
||||
# It also removes the junk from extentions.
|
||||
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
|
||||
|
||||
while read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
url="$(echo "$line" | awk '{print $1}')"
|
||||
qndl "$url" "curl -LO"
|
||||
done < "$queuefile"
|
||||
|
||||
echo > "$queuefile"
|
5
.local/bin/refbar
Executable file
5
.local/bin/refbar
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Refresh the dwmbar.
|
||||
# Send SIGTRAP signal to dwmbar script, which will handle it with a trap.
|
||||
pkill -SIGTRAP dwmbar
|
11
.local/bin/remaps
Executable file
11
.local/bin/remaps
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is called on startup to remap keys.
|
||||
# Increase key speed via a rate change
|
||||
xset r rate 300 50
|
||||
# Map the caps lock key to super...
|
||||
setxkbmap -option caps:super -variant intl
|
||||
# But when it is pressed only once, treat it as escape.
|
||||
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
|
||||
# Map the menu button to right super as well.
|
||||
xmodmap -e 'keycode 135 = Super_R'
|
8
.local/bin/samedir
Executable file
8
.local/bin/samedir
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Open a terminal window in the same directory as the currently active window.
|
||||
|
||||
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
||||
PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
|
||||
cd "$(readlink /proc/"$PID"/cwd)" || return 1
|
||||
"$TERMINAL"
|
20
.local/bin/setbg
Executable file
20
.local/bin/setbg
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script does the following:
|
||||
# Run by itself, set the wallpaper (at X start).
|
||||
# If given a file, set that as the new wallpaper.
|
||||
# If given a directory, choose random file in it.
|
||||
# If wal is installed, also generates a colorscheme.
|
||||
|
||||
# Location of link to wallpaper link.
|
||||
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
|
||||
|
||||
[ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
|
||||
|
||||
[ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen."
|
||||
|
||||
# If pywal is installed, use it.
|
||||
wal -s -i "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
|
||||
|
||||
pidof dwm >/dev/null && xdotool key super+F12
|
||||
xwallpaper --zoom "$bgloc"
|
29
.local/bin/shortcuts
Executable file
29
.local/bin/shortcuts
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Output locations. Unactivated progs should go to /dev/null.
|
||||
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc"
|
||||
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc"
|
||||
ranger_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/ranger/shortcuts.conf"
|
||||
qute_shortcuts="/dev/null"
|
||||
fish_shortcuts="/dev/null"
|
||||
vifm_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/vifm/vifmshortcuts"
|
||||
|
||||
# Remove, prepare files
|
||||
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2>/dev/null
|
||||
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
||||
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
||||
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
||||
|
||||
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "${XDG_CONFIG_HOME:-$HOME/.config}/directories" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \
|
||||
>(awk '{print "hash -d "$1"="$2}' >> "$zsh_named_dirs") \
|
||||
>(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \
|
||||
>(awk '{print "map g" $1, ":cd", $2 "<CR>\nmap t" $1, "<tab>:cd", $2 "<CR><tab>\nmap M" $1, "<tab>:cd", $2 "<CR><tab>:mo<CR>\nmap Y" $1, "<tab>:cd", $2 "<CR><tab>:co<CR>" }' >> "$vifm_shortcuts") \
|
||||
>(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \
|
||||
| awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts"
|
||||
|
||||
# Format the `files` file in the correct syntax and sent it to both configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "${XDG_CONFIG_HOME:-$HOME/.config}/files" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \
|
||||
>(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \
|
||||
>(awk '{print "map", $1, ":e", $2 "<CR>" }' >> "$vifm_shortcuts") \
|
||||
| awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts"
|
10
.local/bin/showclip
Executable file
10
.local/bin/showclip
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Display contents of selection via dunst if running.
|
||||
# Separate script for i3.
|
||||
|
||||
clip=$(xclip -o -selection clipboard)
|
||||
prim=$(xclip -o -selection primary)
|
||||
|
||||
[ -n "$clip" ] && notify-send "Clipboard:" "$clip"
|
||||
[ -n "$prim" ] && notify-send "Primary:" "$prim"
|
27
.local/bin/statusbar/battery
Executable file
27
.local/bin/statusbar/battery
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints all batteries, their percentage remaining and an emoji corresponding
|
||||
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
❗: battery very low!" ;;
|
||||
esac
|
||||
|
||||
# Loop through all attached batteries.
|
||||
for battery in /sys/class/power_supply/BAT?
|
||||
do
|
||||
# Get its remaining capacity and charge status.
|
||||
capacity=$(cat "$battery"/capacity) || break
|
||||
status=$(sed "s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/" "$battery"/status)
|
||||
|
||||
# If it is discharging and 25% or less, we will add a ❗ as a warning.
|
||||
[ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗"
|
||||
|
||||
printf "%s%s%s%% " "$status" "$warn" "$capacity"
|
||||
unset warn
|
||||
done | sed 's/ *$//'
|
32
.local/bin/statusbar/battery_dwm
Executable file
32
.local/bin/statusbar/battery_dwm
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Give a battery name (e.g. BAT0) as an argument.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
❗: battery very low!
|
||||
- Text color reflects charge left" ;;
|
||||
esac
|
||||
|
||||
capacity=$(cat /sys/class/power_supply/"$1"/capacity 2>/dev/null) || exit
|
||||
status=$(cat /sys/class/power_supply/"$1"/status)
|
||||
|
||||
if [ "$capacity" -ge 75 ]; then
|
||||
color="#00ff00"
|
||||
elif [ "$capacity" -ge 50 ]; then
|
||||
color="#ffffff"
|
||||
elif [ "$capacity" -ge 25 ]; then
|
||||
color="#ffff00"
|
||||
else
|
||||
color="#ff0000"
|
||||
warn="❗"
|
||||
fi
|
||||
|
||||
[ -z $warn ] && warn=" "
|
||||
|
||||
[ "$status" = "Charging" ] && color="#ffffff"
|
||||
|
||||
printf "%s%s%s" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
|
32
.local/bin/statusbar/battery_personal
Executable file
32
.local/bin/statusbar/battery_personal
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Give a battery name (e.g. BAT0) as an argument.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
❗: battery very low!
|
||||
- Text color reflects charge left" ;;
|
||||
esac
|
||||
|
||||
capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
|
||||
status=$(cat /sys/class/power_supply/"$1"/status)
|
||||
|
||||
if [ "$capacity" -ge 75 ]; then
|
||||
color="#00ff00"
|
||||
elif [ "$capacity" -ge 50 ]; then
|
||||
color="#ffffff"
|
||||
elif [ "$capacity" -ge 25 ]; then
|
||||
color="#ffff00"
|
||||
else
|
||||
color="#ff0000"
|
||||
warn="❕"
|
||||
fi
|
||||
|
||||
[ -z $warn ] && warn=" "
|
||||
|
||||
[ "$status" = "Charging" ] && color="#ffffff"
|
||||
|
||||
printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown//;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
|
2
.local/bin/statusbar/btstatus
Executable file
2
.local/bin/statusbar/btstatus
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
bluetoothctl show | grep Powered | awk '{print $2}' | sed "s/no//; s/yes/🎧/"
|
3
.local/bin/statusbar/clock
Executable file
3
.local/bin/statusbar/clock
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
date '+%H:%M'
|
11
.local/bin/statusbar/corona
Executable file
11
.local/bin/statusbar/corona
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
( [ "$(stat -c %y ~/.cache/corona | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] || [ "$1" = "up" ] )&&
|
||||
curl -s https://corona-stats.online/Switzerland | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > ~/.cache/corona && notify-send "Corona" "Stats updated"; sleep 5; pkill -RTMIN+15 dwmblocks
|
||||
|
||||
increase=$( grep "Switzerland" ~/.cache/corona |
|
||||
sed "s/\s*//g; s/║//g; s/│/;/g" | awk -F';' '{print $4}' )
|
||||
[ "$increase" != "" ] && ( grep "Switzerland" ~/.cache/corona |
|
||||
sed "s/\s*//g; s/║//g; s/│/;/g" |
|
||||
awk -F';' '{print "😷"$3 " ("$4") 💀"$5 }' ) || ( grep "Switzerland" ~/.cache/corona |
|
||||
sed "s/\s*//g; s/║//g; s/│/;/g" |
|
||||
awk -F';' '{print "😷"$3 " 💀"$5 }' )
|
12
.local/bin/statusbar/cpu
Executable file
12
.local/bin/statusbar/cpu
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;;
|
||||
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
||||
- Click to show intensive processes.
|
||||
- % is of single core." ;;
|
||||
esac
|
||||
|
||||
temp=$(sensors | awk '/Package id 0/ {print "🌡 "$4}' | sed 's/\.[0-9]//; s/+//')
|
||||
[ -n "$temp" ] && echo $temp > /tmp/cpu_temp
|
||||
cat /tmp/cpu_temp
|
53
.local/bin/statusbar/crypto
Executable file
53
.local/bin/statusbar/crypto
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Shows the price for desired cryptocurrencies. Module updates automatically
|
||||
# every calendar day, but can also be updated with a middle click.
|
||||
|
||||
# Currencies should be ;-separated:
|
||||
# human-readable name;urlname;icon
|
||||
coins="Bitcoin;btc;💰
|
||||
Etherium;eth;🍸
|
||||
Basic Attention Token;bat;🦁
|
||||
LBC;lbc;📚"
|
||||
|
||||
# Directory where currency info is stored.
|
||||
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
||||
|
||||
getprices() { # The command to get the desired prices
|
||||
printf "🔃 "; printprices
|
||||
{ rm -rf "${dir:?}/*"
|
||||
echo "$coins" | while IFS=';' read -r human web icon; do
|
||||
val="$(curl -s "rate.sx/1$web")" &&
|
||||
echo "$icon;$val;$human" > "$dir/$web"
|
||||
done; [ -d "$dir" ] && touch "$dir"
|
||||
pkill -RTMIN+13 "${STATUSBAR:-dwmblocks}" ;} &
|
||||
exit
|
||||
}
|
||||
|
||||
printprices() { # Print/format all prices
|
||||
for x in "$dir"/*; do
|
||||
[ -f "$x" ] || break
|
||||
info="$(cut -d';' -f-2 --output-delimiter=' ' "$x")"
|
||||
printf "%s $%0.2f " $info
|
||||
done | sed 's/ $//'
|
||||
}
|
||||
|
||||
[ ! -d "$dir" ] && mkdir -p "$dir" && { getprices; exit ;}
|
||||
|
||||
# If currencies haven't been updated today, try to update them.
|
||||
[ "$(stat -c %x "$HOME/.local/share/crypto-prices" | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
||||
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && getprices || exit ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) uptime="$(date -d "$(stat -c %x "$dir")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
|
||||
notify-send "Exact prices in USD" "$(awk -F';' '{print $1, $3 ":\n\t$" $2}' "$dir"/*)
|
||||
<b>Last updated:</b>
|
||||
$uptime" ;;
|
||||
2) getprices ;;
|
||||
3) notify-send "💸 Crypto-currency module" "\- Left click for exact prices.
|
||||
- Middle click to update.
|
||||
- Shows 🔃 if updating prices.
|
||||
- Manually add/remove currencies to list in the script." ;;
|
||||
esac
|
||||
|
||||
printprices
|
2
.local/bin/statusbar/current_day
Executable file
2
.local/bin/statusbar/current_day
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
date '+%a %b %d'
|
18
.local/bin/statusbar/disk
Executable file
18
.local/bin/statusbar/disk
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint
|
||||
# $2 is optional icon, otherwise mountpoint will displayed
|
||||
|
||||
[ -z "$1" ] && exit
|
||||
|
||||
icon="$2"
|
||||
[ -z "$2" ] && icon="$1"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) pgrep -x dunst >/dev/null && notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "💽 Disk module" "\- Shows used hard drive space.
|
||||
- Click to show all disk info." ;;
|
||||
esac
|
||||
|
||||
printf "%s: %s" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
2
.local/bin/statusbar/getbright
Executable file
2
.local/bin/statusbar/getbright
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo ☀ $(bc <<< "scale=0; $(cat /sys/class/backlight/intel_backlight/brightness) /9.37")%
|
3
.local/bin/statusbar/getmail
Executable file
3
.local/bin/statusbar/getmail
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
num=$(find ~/.local/share/mail/*/INBOX/new -type f | wc -l)
|
||||
[ $num != 0 ] && echo "📬 "$num
|
6
.local/bin/statusbar/getpomminutes
Executable file
6
.local/bin/statusbar/getpomminutes
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
day=$(date '+%Y%b%d')
|
||||
logged=$(grep -v Break ~/eth/pomodoros | grep $(date '+%Y%b%d') | grep -Eo "\(.*\)" | paste -sd+ | bc)
|
||||
temp=$(cat /tmp/pomptemptimes 2>/dev/null)
|
||||
min=$([ "$logged" != "" ] && ([ "$temp" != "" ] && echo "$logged + $temp" | bc || echo $logged ) || ([ "$temp" != "" ] && echo $temp))
|
||||
[ -n "$min" ] && echo '🍅'$min
|
6
.local/bin/statusbar/getpomminutesft
Executable file
6
.local/bin/statusbar/getpomminutesft
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
day=$(date '+%Y%b%d')
|
||||
logged=$(grep -v Break ~/bks/pomodoros_freetime | grep $(date '+%Y%b%d') | grep -Eo "\(.*\)" | paste -sd+ | bc)
|
||||
temp=$(cat /tmp/pomptemptimesft 2>/dev/null)
|
||||
min=$([ "$logged" != "" ] && ([ "$temp" != "" ] && echo "$logged + $temp" | bc || echo $logged ) || ([ "$temp" != "" ] && echo $temp))
|
||||
[ -n "$min" ] && echo '📚'$min
|
2
.local/bin/statusbar/headset_connected
Executable file
2
.local/bin/statusbar/headset_connected
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
pactl list sinks | grep -qE 'device.icon_name = \"audio-(headset|headphones)-bluetooth\"' && echo 🎧
|
7
.local/bin/statusbar/help
Executable file
7
.local/bin/statusbar/help
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
case $BLOCK_BUTTON in
|
||||
1) groff -mom ~/.local/share/larbs/readme.mom -Tpdf | zathura - ;;
|
||||
2) i3 restart ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
||||
- Middle click to refresh i3.";;
|
||||
esac; echo "❓"
|
16
.local/bin/statusbar/help-icon
Executable file
16
.local/bin/statusbar/help-icon
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The clickable help menu. Middle click to restart wm.
|
||||
|
||||
# If dwm is running, use dwm's readme and restart.
|
||||
ps ax | grep -q "\sdwm$" &&
|
||||
READMEFILE=/usr/local/share/dwm/larbs.mom
|
||||
restartwm() { pkill -HUP dwm ;} ||
|
||||
restartwm() { i3 restart ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
|
||||
2) restartwm ;;
|
||||
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
||||
- Middle click to refresh window manager.";;
|
||||
esac; echo "❓"
|
19
.local/bin/statusbar/internet
Executable file
19
.local/bin/statusbar/internet
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e nmtui ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🌐 Internet module" "\- Click to connect
|
||||
📡: no wifi connection
|
||||
📶: wifi connection with quality
|
||||
❎: no ethernet
|
||||
🌐: ethernet working
|
||||
" ;;
|
||||
esac
|
||||
|
||||
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡"
|
||||
|
||||
[ ! -n "${wifiicon+var}" ] && wifiicon="📶"
|
||||
#[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
|
||||
|
||||
|
||||
printf "%s%s" "$wifiicon" "$(cat /sys/class/net/w*/operstate | sed "s/down/❎/;s/up/🌐/")"
|
9
.local/bin/statusbar/iplocate
Executable file
9
.local/bin/statusbar/iplocate
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Gets your public ip address checks which country you are in and
|
||||
# displays that information in the statusbar
|
||||
#
|
||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||
ifinstalled "geoiplookup" || exit
|
||||
addr="$(curl ifconfig.me 2>/dev/null)" || exit
|
||||
grep "flag: " ~/.config/emoji | grep "$(geoiplookup $addr | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"
|
16
.local/bin/statusbar/mailbox
Executable file
16
.local/bin/statusbar/mailbox
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# i3blocks mail module.
|
||||
# Displays number of unread mail and an loading icon if updating.
|
||||
# When clicked, brings up `neomutt`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) "$TERMINAL" -e neomutt ;;
|
||||
2) setsid mailsync >/dev/null & ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📬 Mail module" "\- Shows unread mail
|
||||
- Shows 🔃 if syncing mail
|
||||
- Left click opens neomutt
|
||||
- Middle click syncs mail" ;;
|
||||
esac
|
||||
|
||||
echo "$(du -a ~/.local/share/mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)"
|
9
.local/bin/statusbar/memory
Executable file
9
.local/bin/statusbar/memory
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
||||
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
||||
- Click to show memory hogs." ;;
|
||||
esac
|
||||
|
||||
free -h | awk '/^Mem:/ {print $3 "/" $2}'
|
25
.local/bin/statusbar/moonphase
Executable file
25
.local/bin/statusbar/moonphase
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Shows the current moon phase. Requires `pom-perl`.
|
||||
|
||||
mnphs=$(pom $1 | grep -o 'New\|Waxing Crescent\|First Quarter\|Waxing Gibbous\|Full\|Waning Gibbous\|Last Quarter\|Waning Crescent' | grep -m1 '.')
|
||||
prcnt=$(pom $1 | grep -o '[[:digit:]]*%' | grep -o '[[:digit:]]*' )
|
||||
case "$mnphs" in
|
||||
"New") icon="🌑" prcnt="0" ;;
|
||||
"Waxing Crescent") icon="🌒" ;;
|
||||
"First Quarter") icon="🌓" prcnt="50" ;;
|
||||
"Waxing Gibbous") icon="🌔" ;;
|
||||
"Full") icon="🌕" prcnt="100" ;;
|
||||
"Waning Gibbous") icon="🌖" ;;
|
||||
"Last Quarter") icon="🌗" prcnt="50" ;;
|
||||
"Waning Crescent") icon="🌘" ;;
|
||||
*) echo errorrrr ;;
|
||||
esac
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $mnphs ;;
|
||||
2) $mnphs ;;
|
||||
3) notify-send " 🌜$(pom)" ;;
|
||||
esac
|
||||
|
||||
echo "$icon" "$prcnt"%
|
9
.local/bin/statusbar/mpdupdate
Executable file
9
.local/bin/statusbar/mpdupdate
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Whenever the mpd state changes, update the mpd i3 module.
|
||||
#kill -0 "$(cat /tmp/mpdupdate)" 2>/dev/null && exit || echo $$ > /tmp/mpdupdate
|
||||
|
||||
#sleep 5 && while : ; do
|
||||
#pkill -RTMIN+11 dwmblocks
|
||||
#mpc idle >/dev/null || exit
|
||||
#done
|
||||
pkill -RTMIN+11 dwmblocks
|
10
.local/bin/statusbar/music
Executable file
10
.local/bin/statusbar/music
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
if [ $( mpc status | grep '\[paused\]' | wc -l ) -eq 1 ]; then
|
||||
echo ""
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $( mpc status | grep '\[playing\]' | wc -l ) -eq 1 ]; then
|
||||
echo $(mpc status | sed "/^volume:/d" | tac | sed -e "s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/ /g")
|
||||
exit
|
||||
fi
|
18
.local/bin/statusbar/music_old
Executable file
18
.local/bin/statusbar/music_old
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
filter() {
|
||||
sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' | sed -e "s/$/<\\/span>/g"
|
||||
}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) mpc status | filter && setsid "$TERMINAL" -e ncmpcpp & ;; # right click, pause/unpause
|
||||
2) mpc toggle | filter ;; # right click, pause/unpause
|
||||
3) mpc status | filter && pgrep -x dunst >/dev/null && notify-send "🎵 Music module" "\- Shows mpd song playing.
|
||||
- Italic when paused.
|
||||
- Left click opens ncmpcpp.
|
||||
- Middle click pauses.
|
||||
- Scroll changes track.";; # right click, pause/unpause
|
||||
4) mpc prev | filter ;; # scroll up, previous
|
||||
5) mpc next | filter ;; # scroll down, next
|
||||
*) mpc status | filter ;;
|
||||
esac; exit
|
3
.local/bin/statusbar/news
Executable file
3
.local/bin/statusbar/news
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
num=$( cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)")
|
||||
[ "$num" = "" ] || echo 📰$num
|
18
.local/bin/statusbar/pacpackages
Executable file
18
.local/bin/statusbar/pacpackages
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# i3blocks module for pacman upgrades.
|
||||
# Displays number of upgradeable packages.
|
||||
# For this to work, have a `pacman -Sy` command run in the background as a
|
||||
# cronjob every so often as root. This script will then read those packages.
|
||||
# When clicked, it will run an upgrade via pacman.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e popupgrade ;;
|
||||
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "Upgrade module" "📦: number of upgradable packages
|
||||
- Left click to upgrade packages
|
||||
- Middle click to show upgradable packages" ;;
|
||||
esac
|
||||
|
||||
|
||||
pacman -Qu | grep -v "\[ignored\]" | wc -l | sed -e "s/^0$//g"
|
9
.local/bin/statusbar/popupgrade
Executable file
9
.local/bin/statusbar/popupgrade
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "Beginning upgrade.\\n"
|
||||
|
||||
yay -Syu
|
||||
pkill -RTMIN+8 i3blocks
|
||||
|
||||
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
||||
read -r
|
32
.local/bin/statusbar/statusbarinfo
Executable file
32
.local/bin/statusbar/statusbarinfo
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "
|
||||
____ _ _ _
|
||||
/ ___|| |_ __ _| |_ _ _ ___| |__ __ _ _ __
|
||||
\___ \| __/ _\` | __| | | / __| '_ \ / _\` | '__|
|
||||
___) | || (_| | |_| |_| \__ \ |_) | (_| | |
|
||||
|____/ \__\__,_|\__|\__,_|___/_.__/ \__,_|_|
|
||||
|
||||
This is a list of the statusbar modules.
|
||||
|
||||
📦5 \033[31mpacpackages\033[0m: updatable packages (must have pacman -Sy run in root cronjob to check).
|
||||
📰 41 \033[32mnews\033[0m: unread RSS entries in newsboat.
|
||||
☔ 83% ❄️ 69° 🌞 80° \033[33mweather\033[0m: ☔ for precipitation, 🌞 and ❄ for daily high and low.
|
||||
📬 20 \033[34mmailbox\033[0m: number of unread mail if mutt-wizard is active.
|
||||
🔉 62% \033[35mvolume\033[0m: master sink volume.
|
||||
🔌83% \033[36mbattery\033[0m: 🔌 for charging, 🔋 for discharging, ⚡ for full.
|
||||
📶 80% ❎ \033[37minternet\033[0m: 📶 for wifi with % (📡 if none), 🌐 for ethernet. (❎ if none).
|
||||
|
||||
Obviously the time and date are displayed as well.
|
||||
|
||||
Optional script modules:
|
||||
|
||||
Edit \033[32m~/.local/src/dwmblocks/config.h\033[0m to add these or your own if you'd like (and recompile and restart dwmblocks).
|
||||
|
||||
'memory' 🧠 559Mi/3.7Gi Current used memory/total memory.
|
||||
'cpu' 🌡 +46.0°C CPU temperature.
|
||||
'disk' 🖥 : 28G/30G Remaining disk space...
|
||||
'disk ~' 🏠: 641G/850G ...can be given directory argument.
|
||||
'moonphase' 🌕 39% Phase of the moon (requires \033[32m\`pom-perl\`\033[0m).
|
||||
'iplocate' 🇺🇸 United States Your own or VPN location (requires \033[32m\`geoiplookup\`\033[0m).
|
||||
" | less
|
8
.local/bin/statusbar/sync_status
Executable file
8
.local/bin/statusbar/sync_status
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
string="$(insync get_status)"
|
||||
|
||||
case "$string" in
|
||||
SYNCED) echo '🔗' ;;
|
||||
OFFLINE) echo '🔗' ;;
|
||||
SYNCING) echo '🔄' ;;
|
||||
esac
|
28
.local/bin/statusbar/torrent
Executable file
28
.local/bin/statusbar/torrent
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
transmission-remote -l | grep % |
|
||||
sed " # This first sed command is to ensure a desirable order with sort
|
||||
s/.*Stopped.*/A/g;
|
||||
s/.*Seeding.*/Z/g;
|
||||
s/.*100%.*/N/g;
|
||||
s/.*Idle.*/B/g;
|
||||
s/.*Uploading.*/L/g;
|
||||
s/.*%.*/M/g" |
|
||||
sort -h | uniq -c | sed " # Now we replace the standin letters with icons.
|
||||
s/A/🛑/g;
|
||||
s/B/⌛️/g;
|
||||
s/L/🔼/g;
|
||||
s/M/🔽/g;
|
||||
s/N/✅/g;
|
||||
s/Z/🌱/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e transmission-remote-cli ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "Torrent module" "🛑: paused
|
||||
⏳: idle (seeds needed)
|
||||
🔼: uploading (unfinished)
|
||||
🔽: downloading
|
||||
✅: done
|
||||
🌱: done and seeding" ;;
|
||||
esac
|
||||
|
48
.local/bin/statusbar/volume
Executable file
48
.local/bin/statusbar/volume
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Prints the current volume or 🔇 if muted. Uses PulseAudio by default,
|
||||
# uncomment the ALSA lines if you remove PulseAudio.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
# 1) setsid "$TERMINAL" -e alsamixer & ;;
|
||||
# 2) amixer sset Master toggle ;;
|
||||
# 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;;
|
||||
# 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;;
|
||||
1) setsid "$TERMINAL" -e pulsemixer & ;;
|
||||
2) pamixer -t ;;
|
||||
4) pamixer --allow-boost -i 1 ;;
|
||||
5) pamixer --allow-boost -d 1 ;;
|
||||
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change."
|
||||
esac
|
||||
|
||||
volstat="$(pactl list sinks)"
|
||||
# volstat="$(amixer get Master)" # ALSA only equivalent.
|
||||
|
||||
# Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
|
||||
if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
|
||||
echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
|
||||
else
|
||||
echo "$volstat" | grep -A10 "State: RUNNING" | grep -q "Mute: yes" && printf "🔇\\n" && exit
|
||||
fi
|
||||
# echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA
|
||||
|
||||
# Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
|
||||
if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
|
||||
vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
|
||||
else
|
||||
vol="$(echo "$volstat" | grep -A10 "State: RUNNING" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
|
||||
fi
|
||||
|
||||
# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="🔊"
|
||||
elif [ "$vol" -lt "30" ]; then
|
||||
icon="🔈"
|
||||
else
|
||||
icon="🔉"
|
||||
fi
|
||||
|
||||
printf "%s %s%%\\n" "$icon" "$vol"
|
25
.local/bin/statusbar/volume_
Executable file
25
.local/bin/statusbar/volume_
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e pulsemixer & ;;
|
||||
2) pulsemixer --toggle-mute ;;
|
||||
4) pulsemixer --change-volume +5 ;;
|
||||
5) pulsemixer --change-volume -5 ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change."
|
||||
esac
|
||||
|
||||
[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit
|
||||
|
||||
vol=$(pulsemixer --get-volume | awk '{print $1}')
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="🔊"
|
||||
elif [ "$vol" -lt "30" ]; then
|
||||
icon="🔈"
|
||||
else
|
||||
icon="🔉"
|
||||
fi
|
||||
|
||||
printf "%s %s%%\\n" "$icon" "$vol"
|
23
.local/bin/statusbar/weather
Executable file
23
.local/bin/statusbar/weather
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
location="$1"; [ -z "$location" ] || { location="$location+" && rm -f "$HOME/.local/share/weatherreport" ;}
|
||||
|
||||
getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
|
||||
curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" || exit 1 ;}
|
||||
|
||||
showweather() { printf "%s" "$(sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
|
||||
sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e less -S "$HOME/.local/share/weatherreport" ;;
|
||||
2) getforecast && showweather ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🌈 Weather module" "\- Left click for full forecast.
|
||||
- Middle click to update forecast.
|
||||
☔: Chance of rain/snow
|
||||
❄: Daily low
|
||||
🌞: Daily high" ;;
|
||||
esac
|
||||
|
||||
if [ "$(stat -c %y "$HOME/.local/share/weatherreport" >/dev/null 2>&1 | awk '{print $1}')" != "$(date '+%Y-%m-%d')" ]
|
||||
then getforecast && showweather
|
||||
else showweather
|
||||
fi
|
14
.local/bin/sysact
Executable file
14
.local/bin/sysact
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# A dmenu wrapper script for system functions.
|
||||
|
||||
cmds="\
|
||||
lock screen slock
|
||||
leave dwm kill -TERM $(pidof -s dwm)
|
||||
refresh dwm kill -HUP $(pidof -s dwm)
|
||||
reboot sudo -A reboot
|
||||
shutdown sudo -A shutdown -h now"
|
||||
|
||||
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
|
||||
|
||||
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`
|
12
.local/bin/td-toggle
Executable file
12
.local/bin/td-toggle
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
||||
|
||||
if pidof transmission-daemon >/dev/null ;
|
||||
then
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
|
||||
else
|
||||
ifinstalled transmission-cli || exit
|
||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
|
||||
fi
|
||||
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
3
.local/bin/test2
Executable file
3
.local/bin/test2
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo $1
|
||||
echo $2
|
2
.local/bin/testscript
Executable file
2
.local/bin/testscript
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
[ -n "$1" ] && echo "$1" > "/home/alex/test"
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user