scripts moved to ~/.local/bin
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`.
|
||||
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/.profile; then_command_goes_here
|
||||
```
|
||||
|
||||
This ensures that notifications will display, xdotool commands will function and environmental varialbes will work as well.
|
||||
18
.local/bin/cron/checkup
Executable file
18
.local/bin/cron/checkup
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/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 i3blocks
|
||||
|
||||
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
|
||||
8
.local/bin/cron/cronbat
Executable file
8
.local/bin/cron/cronbat
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/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."
|
||||
5
.local/bin/cron/crontog
Executable file
5
.local/bin/cron/crontog
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Toggles all cronjobs off/on.
|
||||
# Stores disabled crontabs in ~/.consaved until restored.
|
||||
|
||||
([ -f ~/.config/cronsaved ] && crontab - < ~/.config/cronsaved && rm ~/.config/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > ~/.config/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")
|
||||
16
.local/bin/cron/newsup
Executable file
16
.local/bin/cron/newsup
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/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..."
|
||||
|
||||
pgrep -x newsboat >/dev/null && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name newsboat)" R && exit
|
||||
|
||||
echo 🔃 > /tmp/newsupdate
|
||||
pkill -RTMIN+6 i3blocks
|
||||
/usr/bin/newsboat -x reload
|
||||
rm -f /tmp/newsupdate
|
||||
pkill -RTMIN+6 i3blocks
|
||||
/usr/bin/notify-send "📰 RSS feed update complete."
|
||||
26
.local/bin/i3cmds/cabl
Executable file
26
.local/bin/i3cmds/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)"; [ -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"
|
||||
2
.local/bin/i3cmds/camtoggle
Executable file
2
.local/bin/i3cmds/camtoggle
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0
|
||||
19
.local/bin/i3cmds/ddspawn
Executable file
19
.local/bin/i3cmds/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
|
||||
73
.local/bin/i3cmds/displayselect
Executable file
73
.local/bin/i3cmds/displayselect
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/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.
|
||||
# I plan on adding a routine from multi-monitor setups later.
|
||||
|
||||
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
|
||||
1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
|
||||
2) twoscreen ;;
|
||||
*) morescreen ;;
|
||||
esac ;}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | grep " connected" | awk '{print $1}')
|
||||
|
||||
# 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 ;;
|
||||
*) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
|
||||
esac
|
||||
|
||||
setbg # Fix background if screen size/arangement has changed.
|
||||
remaps # Re-remap keys if keyboard added (for laptop bases)
|
||||
pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen
|
||||
59
.local/bin/i3cmds/dmenumount
Executable file
59
.local/bin/i3cmds/dmenumount
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
# Gives a dmenu prompt to mount unmounted drives.
|
||||
# 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
|
||||
mp="$(find $1 | dmenu -i -p "Type in mount point.")"
|
||||
[ "$mp" = "" ] && exit 1
|
||||
if [ ! -d "$mp" ]; then
|
||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?")
|
||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||
fi
|
||||
}
|
||||
|
||||
mountusb() { \
|
||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
|
||||
sudo -A mount "$chosen" && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \( -path *%s -prune \) \ \n",$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" 741 "$mp";;
|
||||
esac
|
||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||
}
|
||||
|
||||
mountandroid() { \
|
||||
chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1)
|
||||
getmount "$HOME -maxdepth 3 -type d"
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in
|
||||
USB) mountusb ;;
|
||||
Android) mountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$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
|
||||
105
.local/bin/i3cmds/dmenurecord
Executable file
105
.local/bin/i3cmds/dmenurecord
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Usage:
|
||||
# `record`: Ask for recording type via dmenu
|
||||
# `record screencast`: Record both audio and screen
|
||||
# `record video`: Record only screen
|
||||
# `record audio`: Record only audio
|
||||
# `record 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 i3blocks
|
||||
}
|
||||
|
||||
killrecording() {
|
||||
recpid="$(cat /tmp/recordingpid)"
|
||||
# kill with SIGTERM, allowing finishing touches.
|
||||
kill -15 "$recpid"
|
||||
rm -f /tmp/recordingpid
|
||||
updateicon ""
|
||||
pkill -RTMIN+9 i3blocks
|
||||
# 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 :0.0 \
|
||||
-f alsa -i default \
|
||||
-r 30 \
|
||||
-c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
|
||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||
echo $! > /tmp/recordingpid
|
||||
updateicon "⏺️🎙️"
|
||||
}
|
||||
|
||||
video() { ffmpeg \
|
||||
-f x11grab \
|
||||
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
||||
-i :0.0 \
|
||||
-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
|
||||
41
.local/bin/i3cmds/dmenuumount
Executable file
41
.local/bin/i3cmds/dmenuumount
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/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?" | 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?")
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in
|
||||
USB) unmountusb ;;
|
||||
Android) unmountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$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/i3cmds/dmenuunicode
Executable file
18
.local/bin/i3cmds/dmenuunicode
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Give dmenu list of all unicode characters to copy.
|
||||
# Shows the selected character in dunst if running.
|
||||
|
||||
# Must have xclip installed to even show menu.
|
||||
xclip -h >/dev/null || exit
|
||||
|
||||
chosen=$(grep -v "#" ~/.config/emoji | dmenu -i -l 20 -fn Monospace-18)
|
||||
|
||||
[ "$chosen" != "" ] || exit
|
||||
|
||||
c=$(echo "$chosen" | sed "s/ .*//")
|
||||
echo "$c" | tr -d '\n' | xclip -selection clipboard
|
||||
notify-send "'$c' copied to clipboard." &
|
||||
|
||||
s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}')
|
||||
echo "$s" | tr -d '\n' | xclip
|
||||
notify-send "'$s' copied to primary." &
|
||||
2
.local/bin/i3cmds/dropdowncalc
Executable file
2
.local/bin/i3cmds/dropdowncalc
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
ifinstalled bc && echo "Welcome to the Calculator." && bc -lq
|
||||
20
.local/bin/i3cmds/ducksearch
Executable file
20
.local/bin/i3cmds/ducksearch
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/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
|
||||
$browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
|
||||
fi
|
||||
fi
|
||||
14
.local/bin/i3cmds/hover
Executable file
14
.local/bin/i3cmds/hover
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/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))
|
||||
xdotool windowsize "$current" $newheight $newwidth
|
||||
newsize=$(xdotool getwindowgeometry "$current" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}')
|
||||
newwidth=$(xdotool getwindowgeometry "$current" | grep Geometry | grep -o " [0-9]*")
|
||||
|
||||
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)) ;;
|
||||
esac
|
||||
xdotool windowmove "$current" $horizontal $vertical
|
||||
27
.local/bin/i3cmds/i3resize
Executable file
27
.local/bin/i3cmds/i3resize
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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 -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/showclip
Executable file
10
.local/bin/i3cmds/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"
|
||||
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
|
||||
4
.local/bin/i3cmds/tmuxdd
Executable file
4
.local/bin/i3cmds/tmuxdd
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/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
|
||||
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
|
||||
18
.local/bin/i3cmds/tutorialvids
Executable file
18
.local/bin/i3cmds/tutorialvids
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
vidlist="
|
||||
status bar https://www.youtube.com/watch?v=gKumet6b-WY
|
||||
sxiv (image viewer) https://www.youtube.com/watch?v=GYW9i_u5PYs
|
||||
st (terminal) https://www.youtube.com/watch?v=9H75enWM22k
|
||||
i3 (window manager) https://www.youtube.com/watch?v=GKviflL9XeI
|
||||
pacman (installing/managing programs) https://www.youtube.com/watch?v=-dEuXTMzRKs
|
||||
mutt (email) https://www.youtube.com/watch?v=2U3vRbF7v5A
|
||||
ncmpcpp (music player) https://www.youtube.com/watch?v=sZIEdI9TS2U
|
||||
newsboat (RSS reader) https://www.youtube.com/watch?v=dUFCRqs822w
|
||||
zathura (pdf viewer) https://www.youtube.com/watch?v=V_Iz4zdyRM4
|
||||
gpg keys https://www.youtube.com/watch?v=DMGIlj7u7Eo
|
||||
calcurse (calendar) https://www.youtube.com/watch?v=hvc-pHjbhdE
|
||||
urlview https://www.youtube.com/watch?v=IgzpAjFgbCw
|
||||
colorschemes with pywal https://www.youtube.com/watch?v=Es79N_9BblE
|
||||
vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E
|
||||
"
|
||||
echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 20 | awk '{print $1}')\s" | sed 's/.*\t//' | xargs -r mpv
|
||||
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)"
|
||||
BIN
.local/bin/larbs.png
Normal file
BIN
.local/bin/larbs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
32
.local/bin/statusbar/battery
Executable file
32
.local/bin/statusbar/battery
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/$/%/')"
|
||||
10
.local/bin/statusbar/clock
Executable file
10
.local/bin/statusbar/clock
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
date '+%Y %b %d (%a) %I:%M%p'
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) pgrep -x dunst >/dev/null && notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -D ~/.config/calcurse -d3)" ;;
|
||||
2) "$TERMINAL" -e calcurse -D ~/.config/calcurse ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
|
||||
- Middle click opens calcurse if installed" ;;
|
||||
esac
|
||||
10
.local/bin/statusbar/cpu
Executable file
10
.local/bin/statusbar/cpu
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/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
|
||||
|
||||
sensors | awk '/Core 0/ {print $3}'
|
||||
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}')"
|
||||
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 "❓"
|
||||
17
.local/bin/statusbar/internet
Executable file
17
.local/bin/statusbar/internet
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/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=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
|
||||
|
||||
printf "%s %s" "$wifiicon" "$(cat /sys/class/net/e*/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}'
|
||||
8
.local/bin/statusbar/mpdupdate
Executable file
8
.local/bin/statusbar/mpdupdate
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/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 i3blocks
|
||||
mpc idle >/dev/null || exit
|
||||
done
|
||||
18
.local/bin/statusbar/music
Executable file
18
.local/bin/statusbar/music
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
|
||||
17
.local/bin/statusbar/news
Executable file
17
.local/bin/statusbar/news
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# i3blocks newsboat module.
|
||||
# Displays number of unread news items and an loading icon if updating.
|
||||
# When clicked, brings up `newsboat`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e newsboat ;;
|
||||
2) setsid newsup >/dev/null & exit ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📰 News module" "\- Shows unread news items
|
||||
- Shows 🔃 if updating with \`newsup\`
|
||||
- Left click opens newsboat
|
||||
- Middle click syncs RSS feeds
|
||||
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
||||
esac
|
||||
|
||||
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)"
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
37
.local/bin/tools/compiler
Executable file
37
.local/bin/tools/compiler
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/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 -kejpt -T pdf > "$base".pdf ;;
|
||||
*\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
|
||||
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||||
*\.tex) textype "$file" ;;
|
||||
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||||
*config.h) sudo make install ;;
|
||||
*\.c) cc "$file" -o "$base" && "$base" ;;
|
||||
*\.py) python "$file" ;;
|
||||
*\.go) go run "$file" ;;
|
||||
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||||
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||
esac
|
||||
15
.local/bin/tools/dmenuhandler
Executable file
15
.local/bin/tools/dmenuhandler
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Feed this script a link and it will give dmenu
|
||||
# some choice programs to use to open it.
|
||||
|
||||
case "$(printf "copy url\\nmpv\\nmpv (loop)\\nqueue download\\n\\nqueue youtube-dl\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?")" in
|
||||
"copy url") echo "$1" | xclip -selection clipboard ;;
|
||||
mpv) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;;
|
||||
"mpv (loop)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet --loop "$1" >/dev/null 2>&1 & ;;
|
||||
"queue download") tsp curl -LO "$1" >/dev/null 2>&1 ;;
|
||||
"queue youtube-dl") tsp youtube-dl --write-metadata -ic "$1" >/dev/null 2>&1 ;;
|
||||
browser) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;;
|
||||
feh) setsid feh "$1" >/dev/null 2>&1 & ;;
|
||||
w3m) w3m "$1" >/dev/null 2>&1 ;;
|
||||
"mpv (float)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;;
|
||||
esac
|
||||
2
.local/bin/tools/dmenupass
Executable file
2
.local/bin/tools/dmenupass
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
dmenu -fn Monospace-18 -sb "#d79921" -sf "#1d2021" -nf "#000000" -nb "#000000" -p "$1" <&- && echo
|
||||
1
.local/bin/tools/ext
Symbolic link
1
.local/bin/tools/ext
Symbolic link
@@ -0,0 +1 @@
|
||||
extract
|
||||
41
.local/bin/tools/extract
Executable file
41
.local/bin/tools/extract
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# A general, all-purpose extraction script.
|
||||
#
|
||||
# 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|*.tar.xz|*.tbz2) tar xvjf "$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
|
||||
14
.local/bin/tools/getbib
Executable file
14
.local/bin/tools/getbib
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
||||
|
||||
if [ -f "$1" ]; then
|
||||
# Try to get DOI from pdfinfo or pdftotext output.
|
||||
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
|
||||
doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
|
||||
exit 1
|
||||
else
|
||||
doi="$1"
|
||||
fi
|
||||
|
||||
# Check crossref.org for the bib citation.
|
||||
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
||||
4
.local/bin/tools/getkeys
Executable file
4
.local/bin/tools/getkeys
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
cat ~/.config/getkeys/"$1" 2>/dev/null && exit
|
||||
echo "Run command with one of the following arguments for info about that program:"
|
||||
ls ~/.config/getkeys
|
||||
3
.local/bin/tools/ifinstalled
Executable file
3
.local/bin/tools/ifinstalled
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# If $1 command is not available, error code and notify.
|
||||
command -v "$1" >/dev/null || { notify-send "📦 $1" "must be installed for this function." && exit 1 ;}
|
||||
22
.local/bin/tools/linkhandler
Executable file
22
.local/bin/tools/linkhandler
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Feed script a url or file location.
|
||||
# If an image, it will view in sxiv,
|
||||
# if a video or gif, it will view in mpv
|
||||
# if a music file or pdf, it will download,
|
||||
# otherwise it opens link in browser.
|
||||
|
||||
# If no url given. Opens browser. For using script as $BROWSER.
|
||||
[ -z "$1" ] && { "$BROWSER"; exit; }
|
||||
|
||||
case "$1" in
|
||||
*mkv|*webm|*mp4|*youtube.com*|*youtu.be*|*hooktube.com*|*bitchute.com*)
|
||||
setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;;
|
||||
*png|*jpg|*jpe|*jpeg|*gif)
|
||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
|
||||
*mp3|*flac|*opus|*mp3?source*)
|
||||
setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
|
||||
*)
|
||||
if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
|
||||
else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;;
|
||||
esac
|
||||
42
.local/bin/tools/lmc
Executable file
42
.local/bin/tools/lmc
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# A general audio interface for LARBS.
|
||||
|
||||
[ -z "$2" ] && num="2" || num="$2"
|
||||
|
||||
case "$1" in
|
||||
u*) pulsemixer --change-volume +"$num" ;;
|
||||
d*) pulsemixer --change-volume -"$num" ;;
|
||||
m*) pulsemixer --toggle-mute ;;
|
||||
truemute) pulsemixer --mute ;;
|
||||
play) mpc play ;;
|
||||
n*) mpc next ;;
|
||||
prev) mpc prev ;;
|
||||
t*) mpc toggle ;;
|
||||
p*) mpc pause ; pauseallmpv ;;
|
||||
f*) mpc seek +"$num" ;;
|
||||
b*) mpc seek -"$num" ;;
|
||||
r*) mpc seek 0% ;;
|
||||
*) cat << EOF
|
||||
lmc: cli music interface for mpd and pulse for those with divine intellect too
|
||||
grand to remember the mpc/pamixer commands.
|
||||
|
||||
Allowed options:
|
||||
up NUM Increase volume (2 secs default)
|
||||
down NUM Decrease volume (2 secs default)
|
||||
mute Toggle mute
|
||||
truemute Mute
|
||||
next Next track
|
||||
prev Previous track
|
||||
toggle Toggle pause
|
||||
truepause Pause
|
||||
foward NUM Seek foward in song (2 secs default)
|
||||
back NUM Seek back in song (2 secs default)
|
||||
restart Restart current song
|
||||
all else Print this message
|
||||
|
||||
All of these commands, except for \`truemute\`, \`prev\` and \`play\` can be truncated,
|
||||
i.e. \`lmc r\` for \`lmc restart\`.
|
||||
EOF
|
||||
esac
|
||||
|
||||
pkill -RTMIN+10 i3blocks
|
||||
11
.local/bin/tools/opout
Executable file
11
.local/bin/tools/opout
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# opout: "open output": A general handler for opening a file's intended output.
|
||||
# I find this useful especially running from vim.
|
||||
|
||||
basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
|
||||
|
||||
case "$1" in
|
||||
*.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;;
|
||||
*.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;;
|
||||
*.sent) setsid sent "$1" >/dev/null 2>&1 & ;;
|
||||
esac
|
||||
4
.local/bin/tools/pauseallmpv
Executable file
4
.local/bin/tools/pauseallmpv
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
for i in $(ls /tmp/mpvsoc*); do
|
||||
echo '{ "command": ["set_property", "pause", true] }' | socat - $i;
|
||||
done
|
||||
6
.local/bin/tools/podentr
Executable file
6
.local/bin/tools/podentr
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# entr command to run `queueandnotify` when newsboat queue is changed
|
||||
|
||||
[ "$(pgrep -x $(basename $0) | wc -l)" -gt 2 ] && exit
|
||||
|
||||
echo ~/.local/share/newsboat/queue | entr -p queueandnotify 2>/dev/null
|
||||
11
.local/bin/tools/qndl
Executable file
11
.local/bin/tools/qndl
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/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."
|
||||
13
.local/bin/tools/queueandnotify
Executable file
13
.local/bin/tools/queueandnotify
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/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="$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"
|
||||
10
.local/bin/tools/remaps
Executable file
10
.local/bin/tools/remaps
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# This script is called by i3 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
|
||||
# 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'
|
||||
4
.local/bin/tools/rotdir
Executable file
4
.local/bin/tools/rotdir
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||
base="$(basename $1)"
|
||||
ls "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$base$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }"
|
||||
9
.local/bin/tools/rssadd
Executable file
9
.local/bin/tools/rssadd
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null &&
|
||||
notify-send "That doesn't look like a full URL." && exit
|
||||
RSSFILE="$HOME/.config/newsboat/urls"
|
||||
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
|
||||
notify-send "You already have this RSS feed."
|
||||
else
|
||||
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||
fi
|
||||
4
.local/bin/tools/setbg
Executable file
4
.local/bin/tools/setbg
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Sets the background. If given an argument, will set file as background.
|
||||
[ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."
|
||||
xwallpaper --zoom ~/.config/wall.png
|
||||
26
.local/bin/tools/shortcuts
Executable file
26
.local/bin/tools/shortcuts
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# Output locations. Unactivated progs should go to /dev/null.
|
||||
shell_shortcuts="$HOME/.config/shortcutrc"
|
||||
ranger_shortcuts="/dev/null"
|
||||
qute_shortcuts="/dev/null"
|
||||
fish_shortcuts="/dev/null"
|
||||
vifm_shortcuts="$HOME/.config/vifm/vifmshortcuts"
|
||||
|
||||
# Remove, prepare files
|
||||
rm -f "$ranger_shortcuts" "$qute_shortcuts" 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 `bmdirs` file in the correct syntax and sent it to all three configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \
|
||||
>(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 `configs` file in the correct syntax and sent it to both configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmfiles" | 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"
|
||||
14
.local/bin/tools/texclear
Executable file
14
.local/bin/tools/texclear
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||
# I have vim run this file whenever I exit a .tex file.
|
||||
|
||||
case "$1" in
|
||||
*.tex)
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
base="${file%.*}"
|
||||
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;;
|
||||
*) printf "Give .tex file as argument.\\n" ;;
|
||||
esac
|
||||
|
||||
9
.local/bin/tools/transadd
Executable file
9
.local/bin/tools/transadd
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running.
|
||||
|
||||
# transmission-daemon sometimes fails to take remote requests in its first moments.
|
||||
|
||||
pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks)
|
||||
|
||||
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
||||
13
.local/bin/tools/vifmimg
Executable file
13
.local/bin/tools/vifmimg
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
[ -z "$FIFO_UEBERZUG" ] && exit
|
||||
|
||||
readonly ID_PREVIEW="preview"
|
||||
|
||||
if [ "$1" = "draw" ]; then
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="${PWD}/$6") > "$FIFO_UEBERZUG"
|
||||
elif [ "$1" = "videopreview" ]; then
|
||||
[ ! -f "/tmp/$6.png" ] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp/$6.png" -s 0 -q 10 &&
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="/tmp/$6.png") > "$FIFO_UEBERZUG"
|
||||
else
|
||||
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") > "$FIFO_UEBERZUG"
|
||||
fi
|
||||
15
.local/bin/tools/vu
Executable file
15
.local/bin/tools/vu
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
|
||||
|
||||
cleanup() {
|
||||
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||
pkill -P $$ 2>/dev/null
|
||||
}
|
||||
|
||||
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
trap cleanup EXIT
|
||||
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash &
|
||||
|
||||
vifm
|
||||
cleanup
|
||||
2
.local/bin/ttymaps.kmap
Normal file
2
.local/bin/ttymaps.kmap
Normal file
@@ -0,0 +1,2 @@
|
||||
keycode 1 = Caps_Lock
|
||||
keycode 58 = Escape
|
||||
25
.local/bin/unix
Executable file
25
.local/bin/unix
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
|
||||
#converted to shell by #nixers @ irc.unix.chat
|
||||
|
||||
cat << 'eof'
|
||||
[38;5;255m,_ ,_==▄▂[0m
|
||||
[38;5;255m, ▂▃▄▄▅▅[48;5;240m▅[48;5;20m▂[48;5;240m▅¾[0m. [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;255m[48;5;20m▄[0m[38;5;255m[48;5;199m▆[38;5;16m[48;5;255m<´ [38;5;32m"[38;5;34m»[38;5;255m▓▓[48;5;32m▓[48;5;240m%[0m\ [38;5;199m/ [38;5;20m/ [38;5;45m/ [38;5;118m/[0m
|
||||
[38;5;255m,[38;5;255m[48;5;240m▅[38;5;16m[48;5;255m7" [38;5;160m´[38;5;34m>[38;5;255m[48;5;39m▓▓[38;5;199m[48;5;255m▓[0m[38;5;255m% [38;5;20m/ [38;5;118m/ [38;5;199m> [38;5;118m/ [38;5;199m>[38;5;255m/[38;5;45m%[0m
|
||||
[38;5;255m▐[48;5;240m[38;5;255m¶[48;5;240m[38;5;255m▓[48;5;255m [38;5;196m,[38;5;34m»[48;5;201m[38;5;255m▓▓[0m[38;5;255m¾´[0m [38;5;199m/[38;5;255m> %[38;5;199m/[38;5;118m%[38;5;255m/[38;5;199m/ [38;5;45m/ [38;5;199m/[0m
|
||||
[38;5;255m[48;5;240m▓[48;5;255m[38;5;16m▃[48;5;16m[38;5;255m▅▅[38;5;16m[48;5;255m▅▃,,[38;5;32m▄[38;5;16m▅[38;5;255m[48;5;16m▅▅[38;5;255m[48;5;20mÆ[0m[38;5;255m\[0m[38;5;20m/[38;5;118m/[38;5;255m /[38;5;118m/[38;5;199m/[38;5;255m>[38;5;45m// [38;5;255m/[38;5;118m>[38;5;199m/ [38;5;20m/[0m
|
||||
[48;5;20m[38;5;255mV[48;5;255m[38;5;16m║[48;5;20m[38;5;255m«[0m[38;5;255m¼.;[48;5;240m[38;5;255m→[48;5;255m[38;5;16m ║[0m[38;5;255m<«.,[48;5;25m[38;5;255m`[48;5;240m=[0m[38;5;20m/[38;5;199m/ [38;5;255m/>[38;5;45m/[38;5;118m/[38;5;255m%/[38;5;199m% / [38;5;20m/[0m
|
||||
[38;5;20m//[48;5;255m[38;5;16m╠<´ -²,)[48;5;16m[38;5;255m(▓[48;5;255m[38;5;16m~"-[38;5;199m╝/[0m[38;5;255m¾[0m[38;5;199m/ [38;5;118m%[38;5;255m/[38;5;118m>[38;5;45m/ [38;5;118m/[38;5;199m>[0m
|
||||
[38;5;20m/ / [38;5;118m/ [48;5;20m[38;5;255m▐[48;5;240m[38;5;16m%[48;5;255m -./▄▃▄[48;5;16m[38;5;255m▅[48;5;255m[38;5;16m▐[48;5;255m[38;5;16m, [38;5;199m/[48;5;199m[38;5;255m7[0m[38;5;20m/[38;5;199m/[38;5;255m;/[38;5;199m/[38;5;118m% [38;5;20m/ /[0m
|
||||
[38;5;20m/ [38;5;199m/[38;5;255m/[38;5;45m/[38;5;118m/[38;5;255m[48;5;240m`[48;5;20m[38;5;255m▌[48;5;20m[38;5;255m▐[48;5;255m[38;5;16m %z[0m[38;5;255mWv xX[48;5;20m[38;5;255m▓[48;5;34m[38;5;255m▇[48;5;199m[38;255m▌[0m[38;5;20m/[38;5;199m/[38;5;255m&;[38;5;20m% [38;5;199m/ [38;5;20m/[0m
|
||||
[38;5;20m/ / [38;5;255m/ [38;5;118m%[38;5;199m/[38;5;255m/%/[48;5;240m[38;5;255m¾[48;5;255m[38;5;16m½´[38;5;255m[48;5;16m▌[0m[38;5;246m▃▄[38;5;255m▄▄[38;5;246m▄▃▃[0m[48;5;16m[38;5;255m▐[38;5;255m[48;5;199m¶[48;5;20m[38;5;255m\[0m[38;5;20m/[0m[48;5;255m[38;5;240m&[0m [38;5;20m/[0m
|
||||
[38;5;199m<[38;5;118m/ [38;5;45m/[38;5;255m</[38;5;118m%[38;5;255m/[38;5;45m/[38;5;255m`[48;5;16m▓[48;5;255m[38;5;16m![48;5;240m[38;5;255m%[48;5;16m[38;5;255m▓[0m[38;5;255m%[48;5;240m[38;5;255m╣[48;5;240m[38;5;255;╣[0m[38;5;255mW[0m[38;5;250mY<Y)[48;5;255m[38;5;16my&[0m[38;5;255m/`[48;5;240m\[0m
|
||||
[38;5;20m/ [38;5;199m/ [38;5;199m%[38;5;255m/%[38;5;118m/[38;5;45m/[38;5;255m<[38;5;118m/[38;5;199m%[38;5;45m/[38;5;20m/[48;5;240m[38;5;255m\[38;5;16m[48;5;255mi7; ╠N[0m[38;5;246m>[38;5;255m)VY>[48;5;240m[38;5;255m7[0m[38;5;255m; [38;5;255m[48;5;240m\[0m[38;5;255m_[0m [38;5;255mUNIX IS VERY SIMPLE [38;5;45mIT JUST NEEDS A[0m
|
||||
[38;5;20m/ [38;5;255m/[38;5;118m<[38;5;255m/ [38;5;45m/[38;5;255m/<[38;5;199m/[38;5;20m/[38;5;199m/[38;5;20m<[38;5;255m_/%\[38;5;255m[48;5;16m▓[48;5;255m[38;5;16m V[0m[38;5;255m%[48;5;255m[38;5;16mW[0m[38;5;255m%£)XY[0m [38;5;240m_/%[38;5;255m‾\_,[0m [38;5;45mGENIUS TO UNDERSTAND ITS SIMPLICITY[38;5;255m[0m
|
||||
[38;5;199m/ [38;5;255m/ [38;5;199m/[38;5;255m/[38;5;118m%[38;5;199m/[48;5;240m[38;5;255m_,=-[48;5;20m-^[0m[38;5;255m/%/%%[48;5;255m[38;5;16m\¾%[0m[38;5;255m¶[0m[48;5;255m[38;5;16m%[0m[38;5;255m%}[0m [38;5;240m/%%%[38;5;20m%%[38;5;240m%;\,[0m
|
||||
[38;5;45m%[38;5;20m/[38;5;199m< [38;5;20m/[48;5;20m[38;5;255m_/[48;5;240m [0m[38;5;255m%%%[38;5;240m%%[38;5;20m;[38;5;255mX[38;5;240m%[38;5;20m%[38;5;255m\%[38;5;240m%;, _/%%%;[38;5;20m,[38;5;240m \[0m
|
||||
[38;5;118m/ [38;5;20m/ [38;5;240m%[38;5;20m%%%%[38;5;240m%;, [38;5;255m\[38;5;240m%[38;5;20m%[38;5;255ml[38;5;240m%%;// _/[38;5;20m%;,[0m [38;5;234mdmr[0m
|
||||
[38;5;20m/ [38;5;240m%[38;5;20m%%;,[0m [38;5;255m<[38;5;20m;[38;5;240m\-=-/ /[0m
|
||||
[38;5;20m;,[0m [38;5;240ml[0m
|
||||
eof
|
||||
Reference in New Issue
Block a user