From 2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 5 Nov 2018 17:51:24 -0500 Subject: scripts sorted --- .scripts/SCRIPTS.md | 340 ++++++++++++++++++++++++----------------- .scripts/bottomleft | 17 --- .scripts/bottomright | 18 --- .scripts/camtoggle | 2 - .scripts/compiler | 49 ------ .scripts/cron/cronbat | 8 + .scripts/cron/crontog | 5 + .scripts/cron/newsup | 14 ++ .scripts/cronbat | 8 - .scripts/crontog | 5 - .scripts/ddspawn | 26 ---- .scripts/displayselect | 49 ------ .scripts/dmenuarchwiki | 17 --- .scripts/dmenuhandler | 14 -- .scripts/dmenumount | 54 ------- .scripts/dmenurecord | 105 ------------- .scripts/dmenuumount | 36 ----- .scripts/dmenuunicode | 18 --- .scripts/dropdowncalc | 5 - .scripts/ducksearch | 15 -- .scripts/ext | 1 - .scripts/extract | 41 ----- .scripts/getbib | 15 -- .scripts/getkeys | 5 - .scripts/i3battery | 22 --- .scripts/i3cmds/bottomleft | 17 +++ .scripts/i3cmds/bottomright | 18 +++ .scripts/i3cmds/camtoggle | 2 + .scripts/i3cmds/ddspawn | 26 ++++ .scripts/i3cmds/displayselect | 49 ++++++ .scripts/i3cmds/dmenumount | 54 +++++++ .scripts/i3cmds/dmenurecord | 105 +++++++++++++ .scripts/i3cmds/dmenuumount | 36 +++++ .scripts/i3cmds/dmenuunicode | 18 +++ .scripts/i3cmds/dropdowncalc | 5 + .scripts/i3cmds/ducksearch | 15 ++ .scripts/i3cmds/i3resize | 27 ++++ .scripts/i3cmds/killrecording | 7 + .scripts/i3cmds/lockscreen | 19 +++ .scripts/i3cmds/newspod | 5 + .scripts/i3cmds/prompt | 7 + .scripts/i3cmds/samedir | 27 ++++ .scripts/i3cmds/td-toggle | 15 ++ .scripts/i3cmds/tmuxdd | 4 + .scripts/i3cmds/toggletouchpad | 4 + .scripts/i3cmds/tutorialvids | 17 +++ .scripts/i3mail | 11 -- .scripts/i3mpd | 13 -- .scripts/i3mpdupdate | 9 -- .scripts/i3pacman | 13 -- .scripts/i3resize | 27 ---- .scripts/i3torrent | 6 - .scripts/i3volume | 22 --- .scripts/i3weather | 15 -- .scripts/i3wifi | 9 -- .scripts/kb-lights.py | 35 ----- .scripts/killrecording | 7 - .scripts/linkhandler | 25 --- .scripts/lmc | 43 ------ .scripts/lock.png | Bin 7897 -> 0 bytes .scripts/lockscreen | 19 --- .scripts/musstuff | 49 ------ .scripts/newspod | 5 - .scripts/newsup | 10 -- .scripts/note | 7 - .scripts/opout | 11 -- .scripts/pauseallmpv | 4 - .scripts/pix/lock.png | Bin 0 -> 7897 bytes .scripts/polybar_launch | 16 -- .scripts/popupgrade | 10 -- .scripts/popweather | 2 - .scripts/prompt | 7 - .scripts/remaps | 19 --- .scripts/samedir | 27 ---- .scripts/shortcuts | 38 ----- .scripts/showclip | 6 - .scripts/speedvid.sh | 7 - .scripts/statusbar/i3battery | 22 +++ .scripts/statusbar/i3mail | 11 ++ .scripts/statusbar/i3mpd | 13 ++ .scripts/statusbar/i3mpdupdate | 9 ++ .scripts/statusbar/i3pacman | 13 ++ .scripts/statusbar/i3torrent | 6 + .scripts/statusbar/i3volume | 22 +++ .scripts/statusbar/i3weather | 15 ++ .scripts/statusbar/i3wifi | 9 ++ .scripts/statusbar/popupgrade | 10 ++ .scripts/statusbar/popweather | 2 + .scripts/td-toggle | 13 -- .scripts/texclear | 12 -- .scripts/tmuxdd | 4 - .scripts/toggletouchpad | 4 - .scripts/tools/compiler | 49 ++++++ .scripts/tools/dmenuhandler | 14 ++ .scripts/tools/ext | 1 + .scripts/tools/extract | 41 +++++ .scripts/tools/getbib | 15 ++ .scripts/tools/getkeys | 5 + .scripts/tools/linkhandler | 25 +++ .scripts/tools/lmc | 43 ++++++ .scripts/tools/note | 7 + .scripts/tools/opout | 11 ++ .scripts/tools/pauseallmpv | 4 + .scripts/tools/remaps | 19 +++ .scripts/tools/shortcuts | 38 +++++ .scripts/tools/speedvid | 7 + .scripts/tools/texclear | 12 ++ .scripts/tools/tpb | 169 ++++++++++++++++++++ .scripts/tools/transadd | 12 ++ .scripts/tpb | 169 -------------------- .scripts/transadd | 12 -- .scripts/tutorialvids | 17 --- 112 files changed, 1308 insertions(+), 1365 deletions(-) delete mode 100755 .scripts/bottomleft delete mode 100755 .scripts/bottomright delete mode 100755 .scripts/camtoggle delete mode 100755 .scripts/compiler create mode 100755 .scripts/cron/cronbat create mode 100755 .scripts/cron/crontog create mode 100755 .scripts/cron/newsup delete mode 100755 .scripts/cronbat delete mode 100644 .scripts/crontog delete mode 100755 .scripts/ddspawn delete mode 100755 .scripts/displayselect delete mode 100755 .scripts/dmenuarchwiki delete mode 100755 .scripts/dmenuhandler delete mode 100755 .scripts/dmenumount delete mode 100755 .scripts/dmenurecord delete mode 100755 .scripts/dmenuumount delete mode 100755 .scripts/dmenuunicode delete mode 100755 .scripts/dropdowncalc delete mode 100755 .scripts/ducksearch delete mode 120000 .scripts/ext delete mode 100755 .scripts/extract delete mode 100755 .scripts/getbib delete mode 100755 .scripts/getkeys delete mode 100755 .scripts/i3battery create mode 100755 .scripts/i3cmds/bottomleft create mode 100755 .scripts/i3cmds/bottomright create mode 100755 .scripts/i3cmds/camtoggle create mode 100755 .scripts/i3cmds/ddspawn create mode 100755 .scripts/i3cmds/displayselect create mode 100755 .scripts/i3cmds/dmenumount create mode 100755 .scripts/i3cmds/dmenurecord create mode 100755 .scripts/i3cmds/dmenuumount create mode 100755 .scripts/i3cmds/dmenuunicode create mode 100755 .scripts/i3cmds/dropdowncalc create mode 100755 .scripts/i3cmds/ducksearch create mode 100755 .scripts/i3cmds/i3resize create mode 100755 .scripts/i3cmds/killrecording create mode 100755 .scripts/i3cmds/lockscreen create mode 100755 .scripts/i3cmds/newspod create mode 100755 .scripts/i3cmds/prompt create mode 100755 .scripts/i3cmds/samedir create mode 100755 .scripts/i3cmds/td-toggle create mode 100755 .scripts/i3cmds/tmuxdd create mode 100755 .scripts/i3cmds/toggletouchpad create mode 100755 .scripts/i3cmds/tutorialvids delete mode 100755 .scripts/i3mail delete mode 100755 .scripts/i3mpd delete mode 100755 .scripts/i3mpdupdate delete mode 100755 .scripts/i3pacman delete mode 100755 .scripts/i3resize delete mode 100755 .scripts/i3torrent delete mode 100755 .scripts/i3volume delete mode 100755 .scripts/i3weather delete mode 100755 .scripts/i3wifi delete mode 100755 .scripts/kb-lights.py delete mode 100755 .scripts/killrecording delete mode 100755 .scripts/linkhandler delete mode 100755 .scripts/lmc delete mode 100644 .scripts/lock.png delete mode 100755 .scripts/lockscreen delete mode 100644 .scripts/musstuff delete mode 100755 .scripts/newspod delete mode 100755 .scripts/newsup delete mode 100755 .scripts/note delete mode 100755 .scripts/opout delete mode 100755 .scripts/pauseallmpv create mode 100644 .scripts/pix/lock.png delete mode 100755 .scripts/polybar_launch delete mode 100755 .scripts/popupgrade delete mode 100755 .scripts/popweather delete mode 100755 .scripts/prompt delete mode 100755 .scripts/remaps delete mode 100755 .scripts/samedir delete mode 100755 .scripts/shortcuts delete mode 100755 .scripts/showclip delete mode 100755 .scripts/speedvid.sh create mode 100755 .scripts/statusbar/i3battery create mode 100755 .scripts/statusbar/i3mail create mode 100755 .scripts/statusbar/i3mpd create mode 100755 .scripts/statusbar/i3mpdupdate create mode 100755 .scripts/statusbar/i3pacman create mode 100755 .scripts/statusbar/i3torrent create mode 100755 .scripts/statusbar/i3volume create mode 100755 .scripts/statusbar/i3weather create mode 100755 .scripts/statusbar/i3wifi create mode 100755 .scripts/statusbar/popupgrade create mode 100755 .scripts/statusbar/popweather delete mode 100755 .scripts/td-toggle delete mode 100755 .scripts/texclear delete mode 100755 .scripts/tmuxdd delete mode 100755 .scripts/toggletouchpad create mode 100755 .scripts/tools/compiler create mode 100755 .scripts/tools/dmenuhandler create mode 120000 .scripts/tools/ext create mode 100755 .scripts/tools/extract create mode 100755 .scripts/tools/getbib create mode 100755 .scripts/tools/getkeys create mode 100755 .scripts/tools/linkhandler create mode 100755 .scripts/tools/lmc create mode 100755 .scripts/tools/note create mode 100755 .scripts/tools/opout create mode 100755 .scripts/tools/pauseallmpv create mode 100755 .scripts/tools/remaps create mode 100755 .scripts/tools/shortcuts create mode 100755 .scripts/tools/speedvid create mode 100755 .scripts/tools/texclear create mode 100755 .scripts/tools/tpb create mode 100755 .scripts/tools/transadd delete mode 100755 .scripts/tpb delete mode 100755 .scripts/transadd delete mode 100755 .scripts/tutorialvids (limited to '.scripts') diff --git a/.scripts/SCRIPTS.md b/.scripts/SCRIPTS.md index cd16f20..6756039 100644 --- a/.scripts/SCRIPTS.md +++ b/.scripts/SCRIPTS.md @@ -1,146 +1,136 @@ # Directory of Scripts -## `audio` +I keep all my user-created scripts here in `~/.scripts/`. Scripts are sorted +into sub-directories for easy management, and all are seamlessly added to +`$PATH` with the command below in `~/.profile`: -The audio recording script run by `dmenurecord` (bound to `mod+Print`). +``` +export PATH="$(du $HOME/.scripts/ | cut -f2 | tr '\n' ':')$PATH" +``` -## `bottomleft` +## `statusbar/` -Makes the currently selected window float in the bottom left of screen. Bound -to `mod+B`. +For modules used in i3blocks. -## `camtoggle` +### `i3battery` -Starts/kills /dev/video0 webcam. Placed in bottom right by default. - -## `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 `c` in vim. - -## `crontog` - -Turns off/on all user cronjobs. - -## `displayselect` - -Select which displays to use. Bound to `mod+F3`. +i3blocks module. Shows available power remaining with icon indicating battery +status. Colors indicate different levels of charge. -## `dmenuarchwiki` +### `i3mail` -Bind this script to a key and it will give you a prompt to search for a term in -the Arch Wiki. Used to be binded to `mod+F11`, but has been replaced by -`ducksearch` there. +i3blocks module for use with mutt-wizard. Shows unread mail and if +`mailsync.sh` is running. -## `dmenuhandler` +### `i3mpd` -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. +i3blocks module. Shows current song; if paused, name will be grayed and italic. -## `dmenumount` +### `i3mpdupdate` -Detect available partitions with `lsblk` and offer to mount them. Bound to -`mod+F9`. Will do nothing if none are available. +A daemon running by default that will update the i3mpd block on mpd change. -## `dmenurecord` +### `i3pacman` -Gives a list of recording commands: `audio`, `video` and `screencast` (both) in -dmenu for selection. +i3blocks module. Detects new installable upgrades. Only works if you use +cronjobs to automatically sync repositories. -## `dmenuumount` +### `i3torrent` -Unmount a mounted non-essential partition. Bound to `mod+F10`. Will do nothing -if none are mounted. +i3blocks module. Shows torrents idle (βŒ›οΈ), downloading (⬇️) or +finished (🌱). -## `dropdowncalc` +### `i3volume` -The command initially run in the `math` window (toggeable with `mod+a`). Runs -`r` if available, else `python`. +i3blocks module. Shows volume percentage or mute notification. -## `ducksearch` +### `i3weather` -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. +i3blocks module. Gets weather forcast from wttr.in and returns today's +precipitation chance (β˜”), daily low (❄️) and daily high (β˜€οΈ). -## `extract` +### `i3wifi` -Will detect file type of archive and run appropriate extraction command. +A modified version of the i3blocks wifi module. Clicked, it brings up wifi-menu +and also appears when there is no wifi connection. -## `getbib` +### `popupdate` -Use crossref.org to automatically detect bibtex entry of a .pdf. Attempts to -search for the .pdf's DOI. Returns nothing if none detected. +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. -## `getkeys` +### `popweather` -Get the LARBS documentation on what bindings exist for main programs. +The script called by clicking on the i3 weather module. Brings up the forecast +from `http://wttr.in` and will close on . -## `i3battery` -i3blocks module. Shows available power remaining with icon indicating battery -status. Colors indicate different levels of charge. +## `cron/` -## `i3mail` +For scripts meant to be cronjobs. None are active by default on LARBS. -i3blocks module for use with mutt-wizard. Shows unread mail and if -`mailsync.sh` is running. +### `checkup` -## `i3mpd` +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. -i3blocks module. Shows current song; if paused, name will be grayed and italic. +You may need to grant your user the ability to run `pacman -Syyuw --noconfirm` +without a password (done in `/etc/sudoers`). -## `i3mpdupdate` +### `cronbat` -A daemon running by default that will update the i3mpd block on mpd change. +Gives a dunst notification if the battery is less than 25%. -## `i3pacman` +### `crontog` -i3blocks module. Detects new installable upgrades. Only works if you use -cronjobs to automatically sync repositories. +Not actually a cronjob, but just turns off/on all user cronjobs. -## `i3resize` +### `newsup` -A script that allows intuitive resizing of windows. Mapped to `mod+Y/U/I/O`. +Updates newsboat RSS feeds if connected to internet. Will also display a +newspaper update icon on i3blocks if it has not be user disabled. -## `i3torrent` +## `tools/` -i3blocks module. Shows torrents idle (βŒ›οΈ), downloading (⬇️) or -finished (🌱). +Scripts intended to be run either manually by the user or linked to a shortcut +in vim or another program. -## `i3volume` +### `compiler` -i3blocks module. Shows volume percentage or mute notification. +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 `c` in vim. -## `i3weather` +### `dmenuhandler` -i3blocks module. Gets weather forcast from wttr.in and returns today's -precipitation chance (β˜”), daily low (❄️) and daily high (β˜€οΈ). +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. -## `i3wifi` +### `extract` -A modified version of the i3blocks wifi module. Clicked, it brings up wifi-menu -and also appears when there is no wifi connection. +Will detect file type of archive and run appropriate extraction command. -## `kb-lights.py` +### `getbib` -A Python 3 script which will increase or decrease keyboard lights when given -either a `+` or `-` argument. +Use crossref.org to automatically detect bibtex entry of a .pdf. Attempts to +search for the .pdf's DOI. Returns nothing if none detected. -## `killrecording` +### `getkeys` -End a recording started by `dmenurecord` the proper way. +Get the LARBS documentation on what bindings exist for main programs. -## `linkhandler` +### `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` +### `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 @@ -148,96 +138,166 @@ 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. -## `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. - -## `musstuff` - -Some old notes and commands on deleted music shortcuts. - -## `note` +### `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` +### `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 `p` in my vim config to reveal typical output. -## `pauseallmpv` +### `pauseallmpv` Pauses all mpv instances by sending the `,` key to each. Used by several -scripts, but can be used alone as well. +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. -## `polybar_launch` +### `remaps` -For `polybar` users. Launches `polybar` on every screen. Should be run in the -i3 config. +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. -## `popweather` +### `shortcuts` -The script called by clicking on the i3 weather module. Brings up the forecast -from `http://wttr.in` and waits for input to prevent immediate closing of -spawned window. +For updating bash and ranger shortcuts. Reads `~/.key_directories` and +`~/.key_files` for pairs of keypresses and directories and files, then +autoproduces bash aliases and ranger shortcuts for them which output to +`~/.shortcuts` 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 +`~/.key_*` files. -## `prompt` +### `speedvid` -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`. +Speed up a given video file (`$1`) by a given ammount (`$2`). -## `remaps` +### `tpb` -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. +Search Pirate Bay for the certain search terms given as arguments. -## `samedir` +### `texclear` -Opens a terminal window in the same directory as the window currently -selection. Bound to `mod+shift+enter`. +Remove all `.tex` related build files. This is run by my vim when I stop +editing any `.tex` file. -## `screencast` +### `transadd` -A script for `dmenurecord`. Records default audio and the screen. +The mimeapp default script for handling torrent magnet links. Starts +`transmission-daemon` if not running and adds the link. -## `shortcuts.sh` +## `i3cmds` -For updating bash and ranger shortcuts. Reads `~/.scripts/folders` and -`~/.scripts/configs` for pairs of keypresses and directories and configfiles, -then autoproduces bash aliases and ranger shortcuts for them. See the -`README.md` at -[https://github.com/LukeSmithxyz/shortcu-sync](https://github.com/LukeSmithxyz/shortcu-sync) -for the specifics. +These are scripts linked to bindings in i3. They typically perform +user-interface actions or involve dmenu. -## `texclear` +### `bottomleft` and `bottomright` -Remove all `.tex` related build files. This is run by my vim when I stop -editing any `.tex` file. +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+Print Screen` by default. Should be kill 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. -## `tmuxinit` +### `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` +### `toggletouchpad` As the name suggests, turns off TouchPad if on, and turns it on if off. -Requires `xf86-input-synaptics`. - -## `tpb` +Requires `xf86-input-synaptics`. If your laptop has a special button for this, +it will be mapped by default. -Search Pirate Bay for the certain search terms given as arguments. - -## `tutorialvids` +### `tutorialvids` A dmenu prompt that gives some options of tutorial videos to watch. Bound to `mod+shift+e`. - -## `video` - -A script for `dmenurecord`. Records the screen with no audio. diff --git a/.scripts/bottomleft b/.scripts/bottomleft deleted file mode 100755 index 5f05beb..0000000 --- a/.scripts/bottomleft +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# This script move the selected window to the bottom left of the screen. - -current=$(xdotool getwindowfocus) - -# The window will take up no more than a third of -# the width or height of the screen. -newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) -newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) - -xdotool windowsize $(xdotool getwindowfocus) $newheight $newwidth - -newsize=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') - -height=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) -xdotool windowmove $current 0 $height diff --git a/.scripts/bottomright b/.scripts/bottomright deleted file mode 100755 index 7ddc253..0000000 --- a/.scripts/bottomright +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# This script move the selected window to the bottom left of the screen. -current=$(xdotool getwindowfocus) - -# The window will take up no more than a third of -# the width or height of the screen. -newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) -newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) - -xdotool windowsize "$(xdotool getwindowfocus)" $newheight $newwidth - -newsize=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') -newwidth=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | grep -o " [0-9]*") - -vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) -horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) -xdotool windowmove "$current" $horizontal $vertical diff --git a/.scripts/camtoggle b/.scripts/camtoggle deleted file mode 100755 index 1e39dec..0000000 --- a/.scripts/camtoggle +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0 diff --git a/.scripts/compiler b/.scripts/compiler deleted file mode 100755 index 53d6768..0000000 --- a/.scripts/compiler +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -# This script will compile or run another finishing operation on a document. I -# have this script run via vim. -# -# tex files: Compiles to pdf, including bibliography if necessary -# md files: Compiles to pdf via pandoc -# rmd files: Compiles via R Markdown -# c files: Compiles via whatever compiler is set to cc. Usually gcc. -# py files: runs via python command -# go files: compiles and runs with "go run" -# config.h files: (For suckless utils) recompiles and installs program. -# all others: run `sent` to show a presentation - -file=$(readlink -f "$1") -dir=$(dirname "$file") -base="${file%.*}" -shebang=$(sed -n 1p "$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" - } - -shebangtest() { - case "$shebang" in - \#\!*) "$file" ;; - *) sent "$file" 2>/dev/null & ;; - esac -} - -case "$file" in - *\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; - *\.rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;; - *\.tex) textype "$file" ;; - *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; - *config.h) make && sudo make install ;; - *\.c) cc "$file" -o "$base" && "$base" ;; - *\.py) python "$file" ;; - *\.go) go run "$file" ;; - *) shebangtest ;; -esac diff --git a/.scripts/cron/cronbat b/.scripts/cron/cronbat new file mode 100755 index 0000000..c09ff42 --- /dev/null +++ b/.scripts/cron/cronbat @@ -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." diff --git a/.scripts/cron/crontog b/.scripts/cron/crontog new file mode 100755 index 0000000..d5c61be --- /dev/null +++ b/.scripts/cron/crontog @@ -0,0 +1,5 @@ +#!/bin/sh +# Toggles all cronjobs off/on. +# Stores disabled crontabs in ~/.consaved until restored. + +([ -f ~/.cronsaved ] && crontab - < ~/.cronsaved && rm ~/.cronsaved && notify-send "Cronjobs have been re-enabled." && echo cronjobs re-enabled.) || ( crontab -l > ~/.cronsaved && crontab -r && echo cronjobs saved and disabled.;notify-send "Cronjobs have been saved and disabled.") diff --git a/.scripts/cron/newsup b/.scripts/cron/newsup new file mode 100755 index 0000000..ad7adc6 --- /dev/null +++ b/.scripts/cron/newsup @@ -0,0 +1,14 @@ +#!/bin/sh + +# Set as a cron job to check for new RSS entries for newsboat. +# Note that newsbot cannot be opened during the sync and this +# sync cannot run while another instance of newsboat is open. + +ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit +echo "πŸ“° πŸ”ƒ" > ~/.newsup +pkill -RTMIN+6 i3blocks +printf "Loading new RSS entries for newsboat...\\n" +/usr/bin/newsboat -x reload && + printf "Done.\\n" +echo "" > ~/.newsup +pkill -RTMIN+6 i3blocks diff --git a/.scripts/cronbat b/.scripts/cronbat deleted file mode 100755 index c09ff42..0000000 --- a/.scripts/cronbat +++ /dev/null @@ -1,8 +0,0 @@ -#!/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." diff --git a/.scripts/crontog b/.scripts/crontog deleted file mode 100644 index 1cb74ee..0000000 --- a/.scripts/crontog +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# Toggles all cronjobs off/on. -# Stores disabled crontabs in ~/.consaved until restored. - -([[ -f ~/.cronsaved ]] && cat ~/.cronsaved | crontab - && rm ~/.cronsaved && notify-send "Cronjobs have been re-enabled." && echo cronjobs re-enabled.) || ( crontab -l > ~/.cronsaved && crontab -r && echo cronjobs saved and disabled.;notify-send "Cronjobs have been saved and disabled.") diff --git a/.scripts/ddspawn b/.scripts/ddspawn deleted file mode 100755 index aedcd18..0000000 --- a/.scripts/ddspawn +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -# This script simplifies dropdown windows in i3. -# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. -# Usage: -# argument 1: script to run in dropdown window -# all other args are interpreted as options for your terminal -# My usage: -# ddpawn -# bindsym $mod+u exec --no-startup-id ddspawn tmuxdd -# Will hide/show window running the `tmuxdd` script when I press mod+u in i3 -# bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 -# Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) - - -[ -z "$1" ] && exit - -if xwininfo -tree -root | grep "(\"$1\" "; -then - echo "Window detected." -else - echo "Window not detected... spawning." - i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" - sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). -fi -i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" diff --git a/.scripts/displayselect b/.scripts/displayselect deleted file mode 100755 index e36d214..0000000 --- a/.scripts/displayselect +++ /dev/null @@ -1,49 +0,0 @@ -#!/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. - 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 --output "$secondary" --"$direction"-of "$primary" --auto - } - -morescreen() { # If multi-monitor is selected and there are more than two screens. - primary=$(echo "$screens" | dmenu -i -p "asdf") - 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" | 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 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; -esac - -# Fix feh background if screen size/arangement has changed. -feh --bg-scale "$HOME/.config/wall.png" -# Polybar users will want to uncomment this line, which reactivates polybar on all new displays: -#polybar_launch -# Re-remap keys if keyboard added (for laptop bases) -remaps diff --git a/.scripts/dmenuarchwiki b/.scripts/dmenuarchwiki deleted file mode 100755 index 276b5eb..0000000 --- a/.scripts/dmenuarchwiki +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# Gives a dmenu prompt to search the Arch Wiki in your preferred web browser -# Home goes to the home page of the Arch Wiki -# Anything else, it search it - -# Original idea/script by Github user @Caedis. Minor changes by Luke. - -pgrep -x dmenu && exit - -choice=$(echo "πŸ“–" | dmenu -i -p "Type ArchWiki page or search term:") || exit 1 - -if [ "$choice" = "πŸ“–" ]; then - $BROWSER "https://wiki.archlinux.org" -else - $BROWSER "https://wiki.archlinux.org/index.php?search=$choice" -fi diff --git a/.scripts/dmenuhandler b/.scripts/dmenuhandler deleted file mode 100755 index 2a3bc0b..0000000 --- a/.scripts/dmenuhandler +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Feed this script a link and it will give dmenu -# some choice programs to use to open it. - -x=$(printf "mpv\\nmpv (loop)\\nwget\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?") -case "$x" in - mpv) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; - "mpv (loop)") setsid mpv -quiet --loop "$1" >/dev/null 2>&1 & ;; - wget) wget "$1" >/dev/null 2>&1 ;; - browser) setsid "$TRUEBROWSER" "$1" & ;; - feh) setsid feh "$1" >/dev/null 2>&1 & ;; - w3m) w3m "$1" >/dev/null 2>&1 ;; - "mpv (float)") setsid mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;; -esac diff --git a/.scripts/dmenumount b/.scripts/dmenumount deleted file mode 100755 index cdeca18..0000000 --- a/.scripts/dmenumount +++ /dev/null @@ -1,54 +0,0 @@ -#!/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. -pgrep -x dmenu && exit - -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" && exit 0 - getmount "/mnt /media /mount /home -maxdepth 5 -type d" - sudo -A mount "$chosen" "$mp" && pgrep -x dunst && notify-send "$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" - echo simple-mtpfs --device "$chosen" "$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 diff --git a/.scripts/dmenurecord b/.scripts/dmenurecord deleted file mode 100755 index 75a2f4f..0000000 --- a/.scripts/dmenurecord +++ /dev/null @@ -1,105 +0,0 @@ -#!/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" > ~/.recordingicon - pkill -RTMIN+9 i3blocks - } - -killrecording() { - recpid="$(cat ~/.recordingpid)" - # kill with SIGTERM, allowing finishing touches. - kill -15 "$recpid" - rm -f ~/.recordingpid - updateicon "" - pkill -RTMIN+9 i3blocks - # even after SIGTERM, ffmpeg may still run, so SIGKILL it. - sleep 3 - kill -9 "$recpid" - exit - } - -screencastpulse() { \ - 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 $! > ~/.recordingpid - updateicon "βΊοΈπŸŽ™οΈ" - } - -screencastalsa() { \ - ffmpeg -y \ - -f x11grab \ - -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ - -i :0.0 \ - -thread_queue_size 1024 \ - -f alsa -ar 44100 -i hw:1 \ - -c:v libx264 -r 30 -c:a flac \ - "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & - echo $! > ~/.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 $! > ~/.recordingpid - updateicon "⏺️" - } - -audiopulse() { \ - ffmpeg \ - -f alsa -i default \ - -c:a flac \ - "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & - echo $! > ~/.recordingpid - updateicon "πŸŽ™οΈ" - } - -audioalsa() { \ - ffmpeg -y \ - -f alsa -ar 44100 -i hw:1 \ - "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & - echo $! > ~/.recordingpid - updateicon "πŸŽ™οΈ" - } - -askrecording() { \ - choice=$(printf "screencast\\nvideo\\naudio" | dmenu -i -p "Select recording style:") - case "$choice" in - screencast) screencastpulse;; - audio) audiopulse;; - video) video;; - esac - } - -asktoend() { \ - response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && - [ "$response" = "Yes" ] && killrecording - } - - -case "$1" in - screencast) screencastpulse;; - audio) audiopulse;; - video) video;; - kill) killrecording;; - *) ([ -f ~/.recordingpid ] && asktoend && exit) || askrecording;; -esac diff --git a/.scripts/dmenuumount b/.scripts/dmenuumount deleted file mode 100755 index c169326..0000000 --- a/.scripts/dmenuumount +++ /dev/null @@ -1,36 +0,0 @@ -#!/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" && pgrep -x dunst && notify-send "$chosen unmounted." - } - -unmountandroid() { \ - chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") - [ -z "$chosen" ] && exit - fusermount -u "$chosen" && pgrep -x dunst && notify-send "$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 - [ -z "$drives" ] && echo "Unmountable Android device detected." && unmountandroid - echo "Unmountable USB drive(s) and Android device(s) detected." - asktype -fi diff --git a/.scripts/dmenuunicode b/.scripts/dmenuunicode deleted file mode 100755 index 71185ef..0000000 --- a/.scripts/dmenuunicode +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 "#" ~/.emoji | dmenu -i -l 20 -fn Monospace-18) - -[ "$chosen" != "" ] || exit - -c=$(echo "$chosen" | sed "s/ .*//") -echo "$c" | tr -d '\n' | xclip -selection clipboard -pgrep -x dunst >/dev/null && notify-send "'$c' copied to clipboard." - -s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') -echo "$s" | tr -d '\n' | xclip -pgrep -x dunst >/dev/null && notify-send "'$s' copied to primary." diff --git a/.scripts/dropdowncalc b/.scripts/dropdowncalc deleted file mode 100755 index fee8f07..0000000 --- a/.scripts/dropdowncalc +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# This script ensures that i3 will spawn a calculator. -# If R is installed, it will run R, otherwise it will run -# Python. -([ -e /usr/bin/R ] && R -q --no-save) || python -q diff --git a/.scripts/ducksearch b/.scripts/ducksearch deleted file mode 100755 index 13a1e19..0000000 --- a/.scripts/ducksearch +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Gives a dmenu prompt to search DuckDuckGo. -# Without input, will open DuckDuckGo.com. -# Anything else, it search it. - -pgrep -x dmenu && exit - -choice=$(echo "πŸ¦†" | dmenu -i -p "Search DuckDuckGo:") || exit 1 - -if [ "$choice" = "πŸ¦†" ]; then - $BROWSER "https://duckduckgo.com" -else - $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" -fi diff --git a/.scripts/ext b/.scripts/ext deleted file mode 120000 index 562d2b3..0000000 --- a/.scripts/ext +++ /dev/null @@ -1 +0,0 @@ -extract \ No newline at end of file diff --git a/.scripts/extract b/.scripts/extract deleted file mode 100755 index c214583..0000000 --- a/.scripts/extract +++ /dev/null @@ -1,41 +0,0 @@ -#!/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=${archive%.*} && - 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 diff --git a/.scripts/getbib b/.scripts/getbib deleted file mode 100755 index 0ea30d3..0000000 --- a/.scripts/getbib +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Give this script a .pdf and it will attempt -# to return a proper .bib citation via doi. -# Internet connection required. - -# Get the doi from metadata, if not possible, get -# doi from pdftotext output, if not possible, exit. -doi=$(pdfinfo "$1" | grep -o doi:.*) || - doi=$(pdftotext "$1" - | grep -o doi.* -m 1) || - exit 1 - -# Check crossref.org for the bib citation. -curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\n" | - sed -e "/^[^\(\t\|@\|}\)]/d" diff --git a/.scripts/getkeys b/.scripts/getkeys deleted file mode 100755 index 928e435..0000000 --- a/.scripts/getkeys +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cat ~/.scripts/.getkeys/"$1" 2>/dev/null && exit -echo Run command with one of the following arguments for info about that program: -ls ~/.scripts/.getkeys diff --git a/.scripts/i3battery b/.scripts/i3battery deleted file mode 100755 index 6f045fc..0000000 --- a/.scripts/i3battery +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# Give a battery name (e.g. BAT0) as an argument. - -capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit -status=$(cat /sys/class/power_supply/"$1"/status) - -if [ "$capacity" -ge 80 ]; then - color="#00FF00" -elif [ "$capacity" -ge 60 ]; then - color="#FFFFFF" -elif [ "$capacity" -ge 40 ]; then - color="#FFF600" -elif [ "$capacity" -ge 20 ]; then - color="#FFAE00" -else - color="#FF0000" -fi - -[ "$status" = "Charging" ] && color="#FFF" - -printf "%s %s" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/πŸ”‹/;s/Charging/πŸ”Œ/;s/Unknown/♻️/;s/Full/⚑/;s/ 0*/ /g;s/ :/ /g")" "$(echo "$capacity" | sed -e 's/$/%/')" diff --git a/.scripts/i3cmds/bottomleft b/.scripts/i3cmds/bottomleft new file mode 100755 index 0000000..5f05beb --- /dev/null +++ b/.scripts/i3cmds/bottomleft @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script move the selected window to the bottom left of the screen. + +current=$(xdotool getwindowfocus) + +# The window will take up no more than a third of +# the width or height of the screen. +newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) +newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) + +xdotool windowsize $(xdotool getwindowfocus) $newheight $newwidth + +newsize=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') + +height=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) +xdotool windowmove $current 0 $height diff --git a/.scripts/i3cmds/bottomright b/.scripts/i3cmds/bottomright new file mode 100755 index 0000000..7ddc253 --- /dev/null +++ b/.scripts/i3cmds/bottomright @@ -0,0 +1,18 @@ +#!/bin/sh + +# This script move the selected window to the bottom left of the screen. +current=$(xdotool getwindowfocus) + +# The window will take up no more than a third of +# the width or height of the screen. +newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) +newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) + +xdotool windowsize "$(xdotool getwindowfocus)" $newheight $newwidth + +newsize=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') +newwidth=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | grep -o " [0-9]*") + +vertical=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) +horizontal=$(($(xdotool getdisplaygeometry | awk '{print $1}') - newwidth)) +xdotool windowmove "$current" $horizontal $vertical diff --git a/.scripts/i3cmds/camtoggle b/.scripts/i3cmds/camtoggle new file mode 100755 index 0000000..1e39dec --- /dev/null +++ b/.scripts/i3cmds/camtoggle @@ -0,0 +1,2 @@ +#!/bin/bash +pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0 diff --git a/.scripts/i3cmds/ddspawn b/.scripts/i3cmds/ddspawn new file mode 100755 index 0000000..aedcd18 --- /dev/null +++ b/.scripts/i3cmds/ddspawn @@ -0,0 +1,26 @@ +#!/bin/sh + +# This script simplifies dropdown windows in i3. +# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it. +# Usage: +# argument 1: script to run in dropdown window +# all other args are interpreted as options for your terminal +# My usage: +# ddpawn +# bindsym $mod+u exec --no-startup-id ddspawn tmuxdd +# Will hide/show window running the `tmuxdd` script when I press mod+u in i3 +# bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 +# Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) + + +[ -z "$1" ] && exit + +if xwininfo -tree -root | grep "(\"$1\" "; +then + echo "Window detected." +else + echo "Window not detected... spawning." + i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" + sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). +fi +i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect new file mode 100755 index 0000000..e36d214 --- /dev/null +++ b/.scripts/i3cmds/displayselect @@ -0,0 +1,49 @@ +#!/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. + 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 --output "$secondary" --"$direction"-of "$primary" --auto + } + +morescreen() { # If multi-monitor is selected and there are more than two screens. + primary=$(echo "$screens" | dmenu -i -p "asdf") + 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" | 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 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; +esac + +# Fix feh background if screen size/arangement has changed. +feh --bg-scale "$HOME/.config/wall.png" +# Polybar users will want to uncomment this line, which reactivates polybar on all new displays: +#polybar_launch +# Re-remap keys if keyboard added (for laptop bases) +remaps diff --git a/.scripts/i3cmds/dmenumount b/.scripts/i3cmds/dmenumount new file mode 100755 index 0000000..cdeca18 --- /dev/null +++ b/.scripts/i3cmds/dmenumount @@ -0,0 +1,54 @@ +#!/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. +pgrep -x dmenu && exit + +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" && exit 0 + getmount "/mnt /media /mount /home -maxdepth 5 -type d" + sudo -A mount "$chosen" "$mp" && pgrep -x dunst && notify-send "$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" + echo simple-mtpfs --device "$chosen" "$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 diff --git a/.scripts/i3cmds/dmenurecord b/.scripts/i3cmds/dmenurecord new file mode 100755 index 0000000..75a2f4f --- /dev/null +++ b/.scripts/i3cmds/dmenurecord @@ -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" > ~/.recordingicon + pkill -RTMIN+9 i3blocks + } + +killrecording() { + recpid="$(cat ~/.recordingpid)" + # kill with SIGTERM, allowing finishing touches. + kill -15 "$recpid" + rm -f ~/.recordingpid + updateicon "" + pkill -RTMIN+9 i3blocks + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + sleep 3 + kill -9 "$recpid" + exit + } + +screencastpulse() { \ + 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 $! > ~/.recordingpid + updateicon "βΊοΈπŸŽ™οΈ" + } + +screencastalsa() { \ + ffmpeg -y \ + -f x11grab \ + -s $(xdpyinfo | grep dimensions | awk '{print $2;}') \ + -i :0.0 \ + -thread_queue_size 1024 \ + -f alsa -ar 44100 -i hw:1 \ + -c:v libx264 -r 30 -c:a flac \ + "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! > ~/.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 $! > ~/.recordingpid + updateicon "⏺️" + } + +audiopulse() { \ + ffmpeg \ + -f alsa -i default \ + -c:a flac \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! > ~/.recordingpid + updateicon "πŸŽ™οΈ" + } + +audioalsa() { \ + ffmpeg -y \ + -f alsa -ar 44100 -i hw:1 \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! > ~/.recordingpid + updateicon "πŸŽ™οΈ" + } + +askrecording() { \ + choice=$(printf "screencast\\nvideo\\naudio" | dmenu -i -p "Select recording style:") + case "$choice" in + screencast) screencastpulse;; + audio) audiopulse;; + video) video;; + esac + } + +asktoend() { \ + response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && + [ "$response" = "Yes" ] && killrecording + } + + +case "$1" in + screencast) screencastpulse;; + audio) audiopulse;; + video) video;; + kill) killrecording;; + *) ([ -f ~/.recordingpid ] && asktoend && exit) || askrecording;; +esac diff --git a/.scripts/i3cmds/dmenuumount b/.scripts/i3cmds/dmenuumount new file mode 100755 index 0000000..c169326 --- /dev/null +++ b/.scripts/i3cmds/dmenuumount @@ -0,0 +1,36 @@ +#!/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" && pgrep -x dunst && notify-send "$chosen unmounted." + } + +unmountandroid() { \ + chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") + [ -z "$chosen" ] && exit + fusermount -u "$chosen" && pgrep -x dunst && notify-send "$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 + [ -z "$drives" ] && echo "Unmountable Android device detected." && unmountandroid + echo "Unmountable USB drive(s) and Android device(s) detected." + asktype +fi diff --git a/.scripts/i3cmds/dmenuunicode b/.scripts/i3cmds/dmenuunicode new file mode 100755 index 0000000..71185ef --- /dev/null +++ b/.scripts/i3cmds/dmenuunicode @@ -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 "#" ~/.emoji | dmenu -i -l 20 -fn Monospace-18) + +[ "$chosen" != "" ] || exit + +c=$(echo "$chosen" | sed "s/ .*//") +echo "$c" | tr -d '\n' | xclip -selection clipboard +pgrep -x dunst >/dev/null && notify-send "'$c' copied to clipboard." + +s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') +echo "$s" | tr -d '\n' | xclip +pgrep -x dunst >/dev/null && notify-send "'$s' copied to primary." diff --git a/.scripts/i3cmds/dropdowncalc b/.scripts/i3cmds/dropdowncalc new file mode 100755 index 0000000..fee8f07 --- /dev/null +++ b/.scripts/i3cmds/dropdowncalc @@ -0,0 +1,5 @@ +#!/bin/sh +# This script ensures that i3 will spawn a calculator. +# If R is installed, it will run R, otherwise it will run +# Python. +([ -e /usr/bin/R ] && R -q --no-save) || python -q diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch new file mode 100755 index 0000000..13a1e19 --- /dev/null +++ b/.scripts/i3cmds/ducksearch @@ -0,0 +1,15 @@ +#!/bin/sh + +# Gives a dmenu prompt to search DuckDuckGo. +# Without input, will open DuckDuckGo.com. +# Anything else, it search it. + +pgrep -x dmenu && exit + +choice=$(echo "πŸ¦†" | dmenu -i -p "Search DuckDuckGo:") || exit 1 + +if [ "$choice" = "πŸ¦†" ]; then + $BROWSER "https://duckduckgo.com" +else + $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" +fi diff --git a/.scripts/i3cmds/i3resize b/.scripts/i3cmds/i3resize new file mode 100755 index 0000000..11b0992 --- /dev/null +++ b/.scripts/i3cmds/i3resize @@ -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 + diff --git a/.scripts/i3cmds/killrecording b/.scripts/i3cmds/killrecording new file mode 100755 index 0000000..ec9a698 --- /dev/null +++ b/.scripts/i3cmds/killrecording @@ -0,0 +1,7 @@ +#!/bin/sh + +kill -9 "$(cat ~/.recordingpid)" + +# Update i3bar. +echo "" > ~/.recordingicon +pkill -RTMIN+9 i3blocks diff --git a/.scripts/i3cmds/lockscreen b/.scripts/i3cmds/lockscreen new file mode 100755 index 0000000..b745a6a --- /dev/null +++ b/.scripts/i3cmds/lockscreen @@ -0,0 +1,19 @@ +#!/bin/sh + +rm -f /tmp/locked.png + +# If `imagemagick` is not installed, use a blank screen. +[ -f /usr/bin/convert ] && +scrot -m -z /tmp/base.png && +pgrep -x dunst && notify-send -i ~/.scripts/pix/lock.png "Locking computer..." && +convert /tmp/base.png -blur 0x8 /tmp/locked.png + +# Pause music (mocp, mpd and send the pause key to all mpv videos): +mocp -P >/dev/null 2>&1 +mpc pause >/dev/null 2>&1 +pauseallmpv >/dev/null 2>&1 + +i3lock -e -f -c 000000 -i /tmp/locked.png + +# In five seconds, turn off display unless key press in last 4 seconds. +sleep 5 && [ 4000 -lt "$(xssstate -i)" ] && pgrep -x i3lock && xset dpms force off diff --git a/.scripts/i3cmds/newspod b/.scripts/i3cmds/newspod new file mode 100755 index 0000000..6432fd2 --- /dev/null +++ b/.scripts/i3cmds/newspod @@ -0,0 +1,5 @@ +#!/bin/sh +# Another script because i3 is too dumb to call basic operations right. +# Brings up newsboat, if newsboat is open, opens podboat + +newsboat || podboat diff --git a/.scripts/i3cmds/prompt b/.scripts/i3cmds/prompt new file mode 100755 index 0000000..56de2f8 --- /dev/null +++ b/.scripts/i3cmds/prompt @@ -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 diff --git a/.scripts/i3cmds/samedir b/.scripts/i3cmds/samedir new file mode 100755 index 0000000..1bc1701 --- /dev/null +++ b/.scripts/i3cmds/samedir @@ -0,0 +1,27 @@ +#!/bin/bash +# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 + +CMD=$TERMINAL +CWD='' + +# Get window ID +ID=$(xdpyinfo | grep focus | cut -f4 -d " ") + +# Get PID of process whose window this is +PID=$(xprop -id $ID | grep -m 1 PID | cut -d " " -f 3) + +# Get last child process (shell, vim, etc) +if [ -n "$PID" ]; then + TREE=$(pstree -lpA $PID | tail -n 1) + PID=$(echo $TREE | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') + + # If we find the working directory, run the command in that directory + if [ -e "/proc/$PID/cwd" ]; then + CWD=$(readlink /proc/$PID/cwd) + fi +fi +if [ -n "$CWD" ]; then + cd $CWD && $CMD +else + $CMD +fi diff --git a/.scripts/i3cmds/td-toggle b/.scripts/i3cmds/td-toggle new file mode 100755 index 0000000..4eb6652 --- /dev/null +++ b/.scripts/i3cmds/td-toggle @@ -0,0 +1,15 @@ +#!/bin/sh + +# If transmission-daemon is running, will ask to kill, else will ask to start. + +[ ! -f /usr/bin/transmission-daemon ] && echo "Transmission not installed." && exit + +if pgrep -x transmission-da >/dev/null ; +then + yn=$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?") + [ "$yn" = "Yes" ] && killall transmission-da +else + yn=$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?") + [ "$yn" = "Yes" ] && transmission-daemon +fi +sleep 3 && pkill -RTMIN+7 i3blocks diff --git a/.scripts/i3cmds/tmuxdd b/.scripts/i3cmds/tmuxdd new file mode 100755 index 0000000..c194ff1 --- /dev/null +++ b/.scripts/i3cmds/tmuxdd @@ -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 diff --git a/.scripts/i3cmds/toggletouchpad b/.scripts/i3cmds/toggletouchpad new file mode 100755 index 0000000..bbb4110 --- /dev/null +++ b/.scripts/i3cmds/toggletouchpad @@ -0,0 +1,4 @@ +#!/bin/bash +# 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." diff --git a/.scripts/i3cmds/tutorialvids b/.scripts/i3cmds/tutorialvids new file mode 100755 index 0000000..f248253 --- /dev/null +++ b/.scripts/i3cmds/tutorialvids @@ -0,0 +1,17 @@ +#!/bin/sh +vidlist=" +status bar https://www.youtube.com/watch?v=gKumet6b-WY +feh +i3 +mutt https://www.youtube.com/watch?v=2U3vRbF7v5A +ncmpcpp https://www.youtube.com/watch?v=sZIEdI9TS2U +newsboat https://www.youtube.com/watch?v=dUFCRqs822w +ranger https://www.youtube.com/watch?v=L6Vu7WPkoJo +zathura +gpg keys https://www.youtube.com/watch?v=DMGIlj7u7Eo +calcurse https://www.youtube.com/watch?v=hvc-pHjbhdE +urlview https://www.youtube.com/watch?v=IgzpAjFgbCw +vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E +" + +mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5)\\t" | sed 's/.*\t//')" diff --git a/.scripts/i3mail b/.scripts/i3mail deleted file mode 100755 index e80df86..0000000 --- a/.scripts/i3mail +++ /dev/null @@ -1,11 +0,0 @@ -#!/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 ;; -esac - -echo "$(du -a ~/.mail/*/INBOX/new/* | sed -n '$=')" $(cat ~/.config/mutt/.dl) diff --git a/.scripts/i3mpd b/.scripts/i3mpd deleted file mode 100755 index 9dc97a0..0000000 --- a/.scripts/i3mpd +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -filter() { - sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/<\\/span>/g" - } - -case $BLOCK_BUTTON in - 1) mpc status | filter && $TERMINAL -e ncmpcpp & disown ;; # right click, pause/unpause - 3) mpc toggle | filter ;; # right click, pause/unpause - 4) mpc prev | filter ;; # scroll up, previous - 5) mpc next | filter ;; # scroll down, next - *) mpc status | filter ;; -esac diff --git a/.scripts/i3mpdupdate b/.scripts/i3mpdupdate deleted file mode 100755 index 646b49e..0000000 --- a/.scripts/i3mpdupdate +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -[ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit - -while : ; do - pgrep -x mpd || exit - mpc idle > /dev/null - pkill -RTMIN+11 i3blocks ; -done diff --git a/.scripts/i3pacman b/.scripts/i3pacman deleted file mode 100755 index 6825b92..0000000 --- a/.scripts/i3pacman +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 `yay`. (`yay` required, duh.) - -case $BLOCK_BUTTON in - 1) $TERMINAL -e "popupgrade" ;; -esac - -yay -Qu | sed -e '/^Get/d' | wc -l | sed -e "s/^0$//g" diff --git a/.scripts/i3resize b/.scripts/i3resize deleted file mode 100755 index 11b0992..0000000 --- a/.scripts/i3resize +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 - diff --git a/.scripts/i3torrent b/.scripts/i3torrent deleted file mode 100755 index 603ff01..0000000 --- a/.scripts/i3torrent +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -case $BLOCK_BUTTON in - 1) $TERMINAL -e transmission-remote-cli -esac - -transmission-remote -l | grep % | sed -e "s/.*100%.*/Z/g;s/.*Idle.*/A/g;s/.*%.*/M/g" | sort -h | uniq -c | sed -e "s/Z/🌱/g;s/M/⬇️/g;s/A/βŒ›οΈ/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" diff --git a/.scripts/i3volume b/.scripts/i3volume deleted file mode 100755 index 9492906..0000000 --- a/.scripts/i3volume +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in - 1) setsid "$TERMINAL" -e pulsemixer & ;; - 3) pulsemixer --toggle-mute ;; - 4) pulsemixer --change-volume +5 ;; - 5) pulsemixer --change-volume -5 ;; -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" diff --git a/.scripts/i3weather b/.scripts/i3weather deleted file mode 100755 index 8573a42..0000000 --- a/.scripts/i3weather +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -### This is only if your location isn't automatically detected, otherwise you can leave it blank. -location="" - -[ "$location" != "" ] && location="$location+" - -[ "$BLOCK_BUTTON" = "1" ] && $TERMINAL -e popweather - -ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit - -curl -s wttr.in/$location > ~/.weatherreport - -printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/β˜” /g" | tr -d '\n')" - -sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "Β°","β˜€οΈ",$2 "Β°"}' diff --git a/.scripts/i3wifi b/.scripts/i3wifi deleted file mode 100755 index 178c88e..0000000 --- a/.scripts/i3wifi +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in - 1) $TERMINAL -e nmtui ;; -esac - -[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && echo πŸ“‘ && exit - -grep ^w /proc/net/wireless | awk '{ print "πŸ“Ά", int($3 * 100 / 70) "%" }' diff --git a/.scripts/kb-lights.py b/.scripts/kb-lights.py deleted file mode 100755 index f492de0..0000000 --- a/.scripts/kb-lights.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 -# coding: utf-8 - -from sys import argv -import dbus - - -def kb_light_set(delta): - bus = dbus.SystemBus() - kbd_backlight_proxy = bus.get_object('org.freedesktop.UPower', '/org/freedesktop/UPower/KbdBacklight') - kbd_backlight = dbus.Interface(kbd_backlight_proxy, 'org.freedesktop.UPower.KbdBacklight') - - current = kbd_backlight.GetBrightness() - maximum = kbd_backlight.GetMaxBrightness() - new = max(0, current + delta) - - if 0 <= new <= maximum: - current = new - kbd_backlight.SetBrightness(current) - - # Return current backlight level percentage - return 100 * current / maximum - -if __name__ == '__main__': - if len(argv[1:]) == 1: - if argv[1] == "--up" or argv[1] == "+": - # ./kb-light.py (+|--up) to increment - print(kb_light_set(1)) - elif argv[1] == "--down" or argv[1] == "-": - # ./kb-light.py (-|--down) to decrement - print(kb_light_set(-1)) - else: - print("Unknown argument:", argv[1]) - else: - print("Script takes exactly one argument.", len(argv[1:]), "arguments provided.") diff --git a/.scripts/killrecording b/.scripts/killrecording deleted file mode 100755 index ec9a698..0000000 --- a/.scripts/killrecording +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -kill -9 "$(cat ~/.recordingpid)" - -# Update i3bar. -echo "" > ~/.recordingicon -pkill -RTMIN+9 i3blocks diff --git a/.scripts/linkhandler b/.scripts/linkhandler deleted file mode 100755 index 86723de..0000000 --- a/.scripts/linkhandler +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Feed script a url. -# If an image, it will view in feh, -# 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. - -# Sci-Hub's domain occasionally changes due to shutdowns: -scihub="http://sci-hub.tw/" - -# If no url given. Opens browser. For using script as $BROWSER. -[ -z "$1" ] && { "$TRUEBROWSER"; exit; } - -case "$1" in - *mkv|*webm|*mp4|*gif|*youtube.com*|*hooktube.com*) - setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; - *png|*jpg|*jpe|*jpeg) - setsid feh "$1" >/dev/null 2>&1 & ;; - *mp3|*flac|*opus|*mp3?source) - setsid tsp wget "$1" >/dev/null 2>&1 & ;; - *springer.com*) - setsid curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" >/dev/null 2>&1 & ;; - *) setsid "$TRUEBROWSER" "$1" >/dev/null 2>&1 & ;; -esac diff --git a/.scripts/lmc b/.scripts/lmc deleted file mode 100755 index 9c92f3f..0000000 --- a/.scripts/lmc +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# A general audio interface for LARBS. - -newvol="pkill -RTMIN+10 i3blocks" - -[ -z "$2" ] && num="2" || num="$2" - -case "$1" in - u*) pulsemixer --change-volume +"$num" ; $newvol ;; - d*) pulsemixer --change-volume -"$num" ; $newvol ;; - m*) pulsemixer --toggle-mute ; $newvol ;; - truemute) pulsemixer --mute ; $newvol ;; - 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 diff --git a/.scripts/lock.png b/.scripts/lock.png deleted file mode 100644 index b09875d..0000000 Binary files a/.scripts/lock.png and /dev/null differ diff --git a/.scripts/lockscreen b/.scripts/lockscreen deleted file mode 100755 index 817b8d0..0000000 --- a/.scripts/lockscreen +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -rm -f /tmp/locked.png - -# If `imagemagick` is not installed, use a blank screen. -[ -f /usr/bin/convert ] && -scrot -m -z /tmp/base.png && -pgrep -x dunst && notify-send -i ~/.scripts/lock.png "Locking computer..." && -convert /tmp/base.png -blur 0x8 /tmp/locked.png - -# Pause music (mocp, mpd and send the pause key to all mpv videos): -mocp -P >/dev/null 2>&1 -mpc pause >/dev/null 2>&1 -pauseallmpv >/dev/null 2>&1 - -i3lock -e -f -c 000000 -i /tmp/locked.png - -# In five seconds, turn off display unless key press in last 4 seconds. -sleep 5 && [ 4000 -lt "$(xssstate -i)" ] && pgrep -x i3lock && xset dpms force off diff --git a/.scripts/musstuff b/.scripts/musstuff deleted file mode 100644 index 39428ab..0000000 --- a/.scripts/musstuff +++ /dev/null @@ -1,49 +0,0 @@ -These are some old lines from the i3 config. - -I now use the lmc script to change volume and music tracks, which makes i3blocks integration better. - -I deleted the alternative lines for audio commands from the i3 config. -Still, since they're a good reference for people who use ALSA, or people who use music players besides mpd, I've kept them in this file. - -You can replace the commands in the lmc script to get the setup you want. I might have the script autodecide the command later on. - -#FOR ALSA/AMIXER -#set $inc --no-startup-id amixer sset Master 2%+ -#set $biginc --no-startup-id amixer sset Master 5%+ -#set $dec --no-startup-id amixer sset Master 2%- -#set $bigdec --no-startup-id amixer sset Master 5%- -#set $mute --no-startup-id amixer sset Master toggle -#set $truemute --no-startup-id amixer sset Master mute - -##For spotify -#set $music spotify -#set $pause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause -#set $trupause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause -#set $play dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play -#set $next dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next -#set $prev dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous -#set $lilfor dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek -#set $bigfor dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek( - -# For moc: -#set $music --no-startup-id st -e mocp -#set $pause --no-startup-id mocp -G -#set $truepause --no-startup-id mocp -P -#set $next --no-startup-id mocp -f -#set $prev --no-startup-id mocp -r -#set $lilfor --no-startup-id mocp -k 10 -#set $bigfor --no-startup-id mocp -k 120 -#set $lilbak --no-startup-id mocp -k -10 -#set $bigbak --no-startup-id mocp -k -120 -#set $beg --no-startup-id mocp -j 0% - -# For cmus: -#set $music --no-startup-id st -e cmus -#set $pause --no-startup-id cmus-remote -u -#set $next --no-startup-id cmus-remote -n -#set $prev --no-startup-id cmus-remote -r -#set $lilfor --no-startup-id cmus-remote -k +10 -#set $bigfor --no-startup-id cmus-remote -k +120 -#set $lilbak --no-startup-id cmus-remote -k -10 -#set $bigbak --no-startup-id cmus-remote -k -120 -#set $beg --no-startup-id cmus-remote -k 00:00:00 diff --git a/.scripts/newspod b/.scripts/newspod deleted file mode 100755 index 6432fd2..0000000 --- a/.scripts/newspod +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Another script because i3 is too dumb to call basic operations right. -# Brings up newsboat, if newsboat is open, opens podboat - -newsboat || podboat diff --git a/.scripts/newsup b/.scripts/newsup deleted file mode 100755 index ab4116e..0000000 --- a/.scripts/newsup +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -ping -q -t 1 -c 1 `ip r | grep -m 1 default | cut -d ' ' -f 3` >/dev/null || exit -echo "πŸ“° πŸ”ƒ" > ~/.newsup -pkill -RTMIN+6 i3blocks -printf "Loading new RSS entries for newsboat...\\n" -/usr/bin/newsboat -x reload && - printf "Done.\\n" -echo "" > ~/.newsup -pkill -RTMIN+6 i3blocks diff --git a/.scripts/note b/.scripts/note deleted file mode 100755 index a90bff1..0000000 --- a/.scripts/note +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# A super basic command. Give it some arguments to use as anotification. It -# will echo them on the terminal, and if you have `dunst` running, will send a -# `notify-send` message to it. - -echo "$@" && pgrep -x dunst >/dev/null && notify-send "$@" diff --git a/.scripts/opout b/.scripts/opout deleted file mode 100755 index 1fe3928..0000000 --- a/.scripts/opout +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# opout: "open output": A general handler for opening a file's intended output. -# I find this useful especially running from vim. - -basename="${1%.*}" - -case "$1" in - *.tex|*.md|*.rmd|*.ms|*.me) setsid zathura "$basename".pdf >/dev/null 2>&1 & ;; - *.html) setsid "$TRUEBROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;; - *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; -esac diff --git a/.scripts/pauseallmpv b/.scripts/pauseallmpv deleted file mode 100755 index 08241b5..0000000 --- a/.scripts/pauseallmpv +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Sends a , key to all mpv instances, pausing them at the last frame. - -xdotool search --class mpv | xargs -I % xdotool key --window % comma diff --git a/.scripts/pix/lock.png b/.scripts/pix/lock.png new file mode 100644 index 0000000..b09875d Binary files /dev/null and b/.scripts/pix/lock.png differ diff --git a/.scripts/polybar_launch b/.scripts/polybar_launch deleted file mode 100755 index 2af56ab..0000000 --- a/.scripts/polybar_launch +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -#!/usr/bin/env sh - -# Terminate already running bar instances -killall -q polybar - -# Wait until the processes have been shut down -while pgrep -x polybar >/dev/null; do sleep 1; done - -# Launch bar1 and bar2 -#polybar example & - -for i in $(polybar -m | awk -F: '{print $1}'); do MONITOR=$i polybar example -c ~/.config/polybar/config & done -feh --bg-scale ~/.config/wall.png - -echo "Bars launched..." diff --git a/.scripts/popupgrade b/.scripts/popupgrade deleted file mode 100755 index 739fcb7..0000000 --- a/.scripts/popupgrade +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -printf "Beginning upgrade.\\n" - -yay -Syu -pacman -Qu | wc -l > ~/.pacupgrnum -pkill -RTMIN+8 i3blocks - -printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" -read -r diff --git a/.scripts/popweather b/.scripts/popweather deleted file mode 100755 index d11bdf5..0000000 --- a/.scripts/popweather +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -cat ~/.weatherreport && read diff --git a/.scripts/prompt b/.scripts/prompt deleted file mode 100755 index 56de2f8..0000000 --- a/.scripts/prompt +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 diff --git a/.scripts/remaps b/.scripts/remaps deleted file mode 100755 index 95acd90..0000000 --- a/.scripts/remaps +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# This script is called by i3 on startup. - -# Increase key speed via a rate change -xset r rate 300 50 -# Map the caps lock key to super... -setxkbmap -layout us -variant altgr-intl -option caps:super -# If you don't want a us international keyboard, rather whatever keyboard -# you set in your installation, comment out the above line and uncomment -# the one below. -#setxkbmap -option caps:super - -# But when it is pressed only once, treat it as escape. -killall xcape ; xcape -e 'Super_L=Escape' - -# Map the menu button to right super as well. -xmodmap -e 'keycode 135 = Super_R' -#keycode 135 = Super_R NoSymbol Super_R diff --git a/.scripts/samedir b/.scripts/samedir deleted file mode 100755 index 1bc1701..0000000 --- a/.scripts/samedir +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 - -CMD=$TERMINAL -CWD='' - -# Get window ID -ID=$(xdpyinfo | grep focus | cut -f4 -d " ") - -# Get PID of process whose window this is -PID=$(xprop -id $ID | grep -m 1 PID | cut -d " " -f 3) - -# Get last child process (shell, vim, etc) -if [ -n "$PID" ]; then - TREE=$(pstree -lpA $PID | tail -n 1) - PID=$(echo $TREE | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') - - # If we find the working directory, run the command in that directory - if [ -e "/proc/$PID/cwd" ]; then - CWD=$(readlink /proc/$PID/cwd) - fi -fi -if [ -n "$CWD" ]; then - cd $CWD && $CMD -else - $CMD -fi diff --git a/.scripts/shortcuts b/.scripts/shortcuts deleted file mode 100755 index c53da1d..0000000 --- a/.scripts/shortcuts +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Shell rc file (i.e. bash vs. zsh, etc.) -shellrc="$HOME/.bashrc" - -# Config locations -folders="$HOME/.key_directories" -configs="$HOME/.key_files" - -# Output locations -shell_shortcuts="$HOME/.shortcuts" -ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf" -qute_shortcuts="$HOME/.config/qutebrowser/shortcuts.py" -fish_shortcuts="$HOME/.config/fish/shortcuts.fish" - -# Remove -rm -f "$ranger_shortcuts" "$qute_shortcuts" -echo "abbr \\" > "$fish_shortcuts" -echo "alias \\" > "$shell_shortcuts" - -# Ensure text of argument 1 exists in the file argument 2 -ensure() { (grep "$1" "$2")>/dev/null 2>&1 || echo "$1" >> "$2" ;} - -ensure "source $shell_shortcuts" "$shellrc" -ensure "source $HOME/.config/ranger/shortcuts.conf" "$HOME/.config/ranger/rc.conf" -ensure "config.source('shortcuts.py')" "$HOME/.config/qutebrowser/config.py" -ensure "source $HOME/.config/fish/shortcuts.fish" "$HOME/.config/fish/config.fish" - -# Format the `folders` file in the correct syntax and sent it to all three configs. -sed "s/#.*$//;/^$/d" "$folders" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ - >(awk '{print $1, "\"cd " $2 " ; ls -a\" \\"}' >> "$fish_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/#.*$//;/^$/d" "$configs" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ - >(awk '{print $1, "\"$EDITOR "$2"\" \\"}' >> "$fish_shortcuts") \ - | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" diff --git a/.scripts/showclip b/.scripts/showclip deleted file mode 100755 index 38be25a..0000000 --- a/.scripts/showclip +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# Display contents of selection via dunst if running. -# Separate script for i3. - -pgrep -x dunst >/dev/null && notify-send "$(xclip -o -selection clipboard)" diff --git a/.scripts/speedvid.sh b/.scripts/speedvid.sh deleted file mode 100755 index ba3a4f6..0000000 --- a/.scripts/speedvid.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -base=$(basename $1) -ext="${base##*.}" -base="${base%.*}" - -ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext diff --git a/.scripts/statusbar/i3battery b/.scripts/statusbar/i3battery new file mode 100755 index 0000000..6f045fc --- /dev/null +++ b/.scripts/statusbar/i3battery @@ -0,0 +1,22 @@ +#!/bin/sh + +# Give a battery name (e.g. BAT0) as an argument. + +capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit +status=$(cat /sys/class/power_supply/"$1"/status) + +if [ "$capacity" -ge 80 ]; then + color="#00FF00" +elif [ "$capacity" -ge 60 ]; then + color="#FFFFFF" +elif [ "$capacity" -ge 40 ]; then + color="#FFF600" +elif [ "$capacity" -ge 20 ]; then + color="#FFAE00" +else + color="#FF0000" +fi + +[ "$status" = "Charging" ] && color="#FFF" + +printf "%s %s" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/πŸ”‹/;s/Charging/πŸ”Œ/;s/Unknown/♻️/;s/Full/⚑/;s/ 0*/ /g;s/ :/ /g")" "$(echo "$capacity" | sed -e 's/$/%/')" diff --git a/.scripts/statusbar/i3mail b/.scripts/statusbar/i3mail new file mode 100755 index 0000000..e80df86 --- /dev/null +++ b/.scripts/statusbar/i3mail @@ -0,0 +1,11 @@ +#!/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 ;; +esac + +echo "$(du -a ~/.mail/*/INBOX/new/* | sed -n '$=')" $(cat ~/.config/mutt/.dl) diff --git a/.scripts/statusbar/i3mpd b/.scripts/statusbar/i3mpd new file mode 100755 index 0000000..9dc97a0 --- /dev/null +++ b/.scripts/statusbar/i3mpd @@ -0,0 +1,13 @@ +#!/bin/sh + +filter() { + sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/<\\/span>/g" + } + +case $BLOCK_BUTTON in + 1) mpc status | filter && $TERMINAL -e ncmpcpp & disown ;; # right click, pause/unpause + 3) mpc toggle | filter ;; # right click, pause/unpause + 4) mpc prev | filter ;; # scroll up, previous + 5) mpc next | filter ;; # scroll down, next + *) mpc status | filter ;; +esac diff --git a/.scripts/statusbar/i3mpdupdate b/.scripts/statusbar/i3mpdupdate new file mode 100755 index 0000000..646b49e --- /dev/null +++ b/.scripts/statusbar/i3mpdupdate @@ -0,0 +1,9 @@ +#!/bin/sh + +[ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit + +while : ; do + pgrep -x mpd || exit + mpc idle > /dev/null + pkill -RTMIN+11 i3blocks ; +done diff --git a/.scripts/statusbar/i3pacman b/.scripts/statusbar/i3pacman new file mode 100755 index 0000000..6825b92 --- /dev/null +++ b/.scripts/statusbar/i3pacman @@ -0,0 +1,13 @@ +#!/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 `yay`. (`yay` required, duh.) + +case $BLOCK_BUTTON in + 1) $TERMINAL -e "popupgrade" ;; +esac + +yay -Qu | sed -e '/^Get/d' | wc -l | sed -e "s/^0$//g" diff --git a/.scripts/statusbar/i3torrent b/.scripts/statusbar/i3torrent new file mode 100755 index 0000000..603ff01 --- /dev/null +++ b/.scripts/statusbar/i3torrent @@ -0,0 +1,6 @@ +#!/bin/sh +case $BLOCK_BUTTON in + 1) $TERMINAL -e transmission-remote-cli +esac + +transmission-remote -l | grep % | sed -e "s/.*100%.*/Z/g;s/.*Idle.*/A/g;s/.*%.*/M/g" | sort -h | uniq -c | sed -e "s/Z/🌱/g;s/M/⬇️/g;s/A/βŒ›οΈ/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" diff --git a/.scripts/statusbar/i3volume b/.scripts/statusbar/i3volume new file mode 100755 index 0000000..9492906 --- /dev/null +++ b/.scripts/statusbar/i3volume @@ -0,0 +1,22 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e pulsemixer & ;; + 3) pulsemixer --toggle-mute ;; + 4) pulsemixer --change-volume +5 ;; + 5) pulsemixer --change-volume -5 ;; +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" diff --git a/.scripts/statusbar/i3weather b/.scripts/statusbar/i3weather new file mode 100755 index 0000000..8573a42 --- /dev/null +++ b/.scripts/statusbar/i3weather @@ -0,0 +1,15 @@ +#!/bin/sh +### This is only if your location isn't automatically detected, otherwise you can leave it blank. +location="" + +[ "$location" != "" ] && location="$location+" + +[ "$BLOCK_BUTTON" = "1" ] && $TERMINAL -e popweather + +ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit + +curl -s wttr.in/$location > ~/.weatherreport + +printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/β˜” /g" | tr -d '\n')" + +sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "Β°","β˜€οΈ",$2 "Β°"}' diff --git a/.scripts/statusbar/i3wifi b/.scripts/statusbar/i3wifi new file mode 100755 index 0000000..178c88e --- /dev/null +++ b/.scripts/statusbar/i3wifi @@ -0,0 +1,9 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) $TERMINAL -e nmtui ;; +esac + +[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && echo πŸ“‘ && exit + +grep ^w /proc/net/wireless | awk '{ print "πŸ“Ά", int($3 * 100 / 70) "%" }' diff --git a/.scripts/statusbar/popupgrade b/.scripts/statusbar/popupgrade new file mode 100755 index 0000000..739fcb7 --- /dev/null +++ b/.scripts/statusbar/popupgrade @@ -0,0 +1,10 @@ +#!/bin/sh + +printf "Beginning upgrade.\\n" + +yay -Syu +pacman -Qu | wc -l > ~/.pacupgrnum +pkill -RTMIN+8 i3blocks + +printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" +read -r diff --git a/.scripts/statusbar/popweather b/.scripts/statusbar/popweather new file mode 100755 index 0000000..d11bdf5 --- /dev/null +++ b/.scripts/statusbar/popweather @@ -0,0 +1,2 @@ +#!/bin/sh +cat ~/.weatherreport && read diff --git a/.scripts/td-toggle b/.scripts/td-toggle deleted file mode 100755 index 42b5f1f..0000000 --- a/.scripts/td-toggle +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# If transmission-daemon is running, will ask to kill, else will ask to start. - -if pgrep -x transmission-da ; -then - yn=$(printf "No\\nYes" | dmenu -i -p "Kill transmission-daemon?") - [ "$yn" = "Yes" ] && killall transmission-daemon -else - yn=$(printf "No\\nYes" | dmenu -i -p "Start transmission daemon?") - [ "$yn" = "Yes" ] && transmission-daemon -fi -sleep 3 && pkill -RTMIN+7 i3blocks diff --git a/.scripts/texclear b/.scripts/texclear deleted file mode 100755 index 0e08f1d..0000000 --- a/.scripts/texclear +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Clears the build files of a LaTeX/XeLaTeX build. -# I have vim run this file whenever I exit a .tex file. - -[[ "$1" == *.tex ]] || exit - -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|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete diff --git a/.scripts/tmuxdd b/.scripts/tmuxdd deleted file mode 100755 index c194ff1..0000000 --- a/.scripts/tmuxdd +++ /dev/null @@ -1,4 +0,0 @@ -#!/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 diff --git a/.scripts/toggletouchpad b/.scripts/toggletouchpad deleted file mode 100755 index bbb4110..0000000 --- a/.scripts/toggletouchpad +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# 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." diff --git a/.scripts/tools/compiler b/.scripts/tools/compiler new file mode 100755 index 0000000..53d6768 --- /dev/null +++ b/.scripts/tools/compiler @@ -0,0 +1,49 @@ +#!/bin/sh + +# This script will compile or run another finishing operation on a document. I +# have this script run via vim. +# +# tex files: Compiles to pdf, including bibliography if necessary +# md files: Compiles to pdf via pandoc +# rmd files: Compiles via R Markdown +# c files: Compiles via whatever compiler is set to cc. Usually gcc. +# py files: runs via python command +# go files: compiles and runs with "go run" +# config.h files: (For suckless utils) recompiles and installs program. +# all others: run `sent` to show a presentation + +file=$(readlink -f "$1") +dir=$(dirname "$file") +base="${file%.*}" +shebang=$(sed -n 1p "$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" + } + +shebangtest() { + case "$shebang" in + \#\!*) "$file" ;; + *) sent "$file" 2>/dev/null & ;; + esac +} + +case "$file" in + *\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + *\.rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;; + *\.tex) textype "$file" ;; + *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; + *config.h) make && sudo make install ;; + *\.c) cc "$file" -o "$base" && "$base" ;; + *\.py) python "$file" ;; + *\.go) go run "$file" ;; + *) shebangtest ;; +esac diff --git a/.scripts/tools/dmenuhandler b/.scripts/tools/dmenuhandler new file mode 100755 index 0000000..2a3bc0b --- /dev/null +++ b/.scripts/tools/dmenuhandler @@ -0,0 +1,14 @@ +#!/bin/sh +# Feed this script a link and it will give dmenu +# some choice programs to use to open it. + +x=$(printf "mpv\\nmpv (loop)\\nwget\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?") +case "$x" in + mpv) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; + "mpv (loop)") setsid mpv -quiet --loop "$1" >/dev/null 2>&1 & ;; + wget) wget "$1" >/dev/null 2>&1 ;; + browser) setsid "$TRUEBROWSER" "$1" & ;; + feh) setsid feh "$1" >/dev/null 2>&1 & ;; + w3m) w3m "$1" >/dev/null 2>&1 ;; + "mpv (float)") setsid mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;; +esac diff --git a/.scripts/tools/ext b/.scripts/tools/ext new file mode 120000 index 0000000..562d2b3 --- /dev/null +++ b/.scripts/tools/ext @@ -0,0 +1 @@ +extract \ No newline at end of file diff --git a/.scripts/tools/extract b/.scripts/tools/extract new file mode 100755 index 0000000..c214583 --- /dev/null +++ b/.scripts/tools/extract @@ -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=${archive%.*} && + 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 diff --git a/.scripts/tools/getbib b/.scripts/tools/getbib new file mode 100755 index 0000000..0ea30d3 --- /dev/null +++ b/.scripts/tools/getbib @@ -0,0 +1,15 @@ +#!/bin/bash + +# Give this script a .pdf and it will attempt +# to return a proper .bib citation via doi. +# Internet connection required. + +# Get the doi from metadata, if not possible, get +# doi from pdftotext output, if not possible, exit. +doi=$(pdfinfo "$1" | grep -o doi:.*) || + doi=$(pdftotext "$1" - | grep -o doi.* -m 1) || + exit 1 + +# Check crossref.org for the bib citation. +curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\n" | + sed -e "/^[^\(\t\|@\|}\)]/d" diff --git a/.scripts/tools/getkeys b/.scripts/tools/getkeys new file mode 100755 index 0000000..928e435 --- /dev/null +++ b/.scripts/tools/getkeys @@ -0,0 +1,5 @@ +#!/bin/sh + +cat ~/.scripts/.getkeys/"$1" 2>/dev/null && exit +echo Run command with one of the following arguments for info about that program: +ls ~/.scripts/.getkeys diff --git a/.scripts/tools/linkhandler b/.scripts/tools/linkhandler new file mode 100755 index 0000000..86723de --- /dev/null +++ b/.scripts/tools/linkhandler @@ -0,0 +1,25 @@ +#!/bin/sh + +# Feed script a url. +# If an image, it will view in feh, +# 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. + +# Sci-Hub's domain occasionally changes due to shutdowns: +scihub="http://sci-hub.tw/" + +# If no url given. Opens browser. For using script as $BROWSER. +[ -z "$1" ] && { "$TRUEBROWSER"; exit; } + +case "$1" in + *mkv|*webm|*mp4|*gif|*youtube.com*|*hooktube.com*) + setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; + *png|*jpg|*jpe|*jpeg) + setsid feh "$1" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source) + setsid tsp wget "$1" >/dev/null 2>&1 & ;; + *springer.com*) + setsid curl -sO "$(curl -s "$scihub$*" | grep -Po "(?<=location.href=').+.pdf")" >/dev/null 2>&1 & ;; + *) setsid "$TRUEBROWSER" "$1" >/dev/null 2>&1 & ;; +esac diff --git a/.scripts/tools/lmc b/.scripts/tools/lmc new file mode 100755 index 0000000..9c92f3f --- /dev/null +++ b/.scripts/tools/lmc @@ -0,0 +1,43 @@ +#!/bin/bash + +# A general audio interface for LARBS. + +newvol="pkill -RTMIN+10 i3blocks" + +[ -z "$2" ] && num="2" || num="$2" + +case "$1" in + u*) pulsemixer --change-volume +"$num" ; $newvol ;; + d*) pulsemixer --change-volume -"$num" ; $newvol ;; + m*) pulsemixer --toggle-mute ; $newvol ;; + truemute) pulsemixer --mute ; $newvol ;; + 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 diff --git a/.scripts/tools/note b/.scripts/tools/note new file mode 100755 index 0000000..a90bff1 --- /dev/null +++ b/.scripts/tools/note @@ -0,0 +1,7 @@ +#!/bin/sh + +# A super basic command. Give it some arguments to use as anotification. It +# will echo them on the terminal, and if you have `dunst` running, will send a +# `notify-send` message to it. + +echo "$@" && pgrep -x dunst >/dev/null && notify-send "$@" diff --git a/.scripts/tools/opout b/.scripts/tools/opout new file mode 100755 index 0000000..1fe3928 --- /dev/null +++ b/.scripts/tools/opout @@ -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="${1%.*}" + +case "$1" in + *.tex|*.md|*.rmd|*.ms|*.me) setsid zathura "$basename".pdf >/dev/null 2>&1 & ;; + *.html) setsid "$TRUEBROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;; + *.sent) setsid sent "$1" >/dev/null 2>&1 & ;; +esac diff --git a/.scripts/tools/pauseallmpv b/.scripts/tools/pauseallmpv new file mode 100755 index 0000000..08241b5 --- /dev/null +++ b/.scripts/tools/pauseallmpv @@ -0,0 +1,4 @@ +#!/bin/sh +# Sends a , key to all mpv instances, pausing them at the last frame. + +xdotool search --class mpv | xargs -I % xdotool key --window % comma diff --git a/.scripts/tools/remaps b/.scripts/tools/remaps new file mode 100755 index 0000000..95acd90 --- /dev/null +++ b/.scripts/tools/remaps @@ -0,0 +1,19 @@ +#!/bin/sh + +# This script is called by i3 on startup. + +# Increase key speed via a rate change +xset r rate 300 50 +# Map the caps lock key to super... +setxkbmap -layout us -variant altgr-intl -option caps:super +# If you don't want a us international keyboard, rather whatever keyboard +# you set in your installation, comment out the above line and uncomment +# the one below. +#setxkbmap -option caps:super + +# But when it is pressed only once, treat it as escape. +killall xcape ; xcape -e 'Super_L=Escape' + +# Map the menu button to right super as well. +xmodmap -e 'keycode 135 = Super_R' +#keycode 135 = Super_R NoSymbol Super_R diff --git a/.scripts/tools/shortcuts b/.scripts/tools/shortcuts new file mode 100755 index 0000000..c53da1d --- /dev/null +++ b/.scripts/tools/shortcuts @@ -0,0 +1,38 @@ +#!/bin/bash + +# Shell rc file (i.e. bash vs. zsh, etc.) +shellrc="$HOME/.bashrc" + +# Config locations +folders="$HOME/.key_directories" +configs="$HOME/.key_files" + +# Output locations +shell_shortcuts="$HOME/.shortcuts" +ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf" +qute_shortcuts="$HOME/.config/qutebrowser/shortcuts.py" +fish_shortcuts="$HOME/.config/fish/shortcuts.fish" + +# Remove +rm -f "$ranger_shortcuts" "$qute_shortcuts" +echo "abbr \\" > "$fish_shortcuts" +echo "alias \\" > "$shell_shortcuts" + +# Ensure text of argument 1 exists in the file argument 2 +ensure() { (grep "$1" "$2")>/dev/null 2>&1 || echo "$1" >> "$2" ;} + +ensure "source $shell_shortcuts" "$shellrc" +ensure "source $HOME/.config/ranger/shortcuts.conf" "$HOME/.config/ranger/rc.conf" +ensure "config.source('shortcuts.py')" "$HOME/.config/qutebrowser/config.py" +ensure "source $HOME/.config/fish/shortcuts.fish" "$HOME/.config/fish/config.fish" + +# Format the `folders` file in the correct syntax and sent it to all three configs. +sed "s/#.*$//;/^$/d" "$folders" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ + >(awk '{print $1, "\"cd " $2 " ; ls -a\" \\"}' >> "$fish_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/#.*$//;/^$/d" "$configs" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ + >(awk '{print $1, "\"$EDITOR "$2"\" \\"}' >> "$fish_shortcuts") \ + | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" diff --git a/.scripts/tools/speedvid b/.scripts/tools/speedvid new file mode 100755 index 0000000..ba3a4f6 --- /dev/null +++ b/.scripts/tools/speedvid @@ -0,0 +1,7 @@ +#!/bin/bash + +base=$(basename $1) +ext="${base##*.}" +base="${base%.*}" + +ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext diff --git a/.scripts/tools/texclear b/.scripts/tools/texclear new file mode 100755 index 0000000..0e08f1d --- /dev/null +++ b/.scripts/tools/texclear @@ -0,0 +1,12 @@ +#!/bin/bash + +# Clears the build files of a LaTeX/XeLaTeX build. +# I have vim run this file whenever I exit a .tex file. + +[[ "$1" == *.tex ]] || exit + +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|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete diff --git a/.scripts/tools/tpb b/.scripts/tools/tpb new file mode 100755 index 0000000..7a2913a --- /dev/null +++ b/.scripts/tools/tpb @@ -0,0 +1,169 @@ +#!/bin/sh +# +# by Sairon Istyar, 2012 +# distributed under the GPLv3 license +# http://www.opensource.org/licenses/gpl-3.0.html +# + +### CONFIGURATION ### +# program to use for torrent download +# magnet link to torrent will be appended +# you can add -- at the end to indicate end of options +# (if your program supports it, most do) +program='/usr/bin/transmission-remote -a' +daemon='transmission-daemon' +TPB="https://thepiratebay.org" + +# show N first matches by default +limit=50 + +# colors +numbcolor='\x1b[1;35m' +namecolor='\x1b[1;33m' +sizecolor='\x1b[1;36m' +seedcolor='\x1b[1;31m' +peercolor='\x1b[1;32m' +errocolor='\x1b[1;31m' +mesgcolor='\x1b[1;37m' +nonecolor='\x1b[0m' + +# default ordering method +# 1 - name ascending; 2 - name descending; +# 3 - recent first; 4 - oldest first; +# 5 - size descending; 6 - size ascending; +# 7 - seeds descending; 8 - seeds ascending; +# 9 - leechers descending; 10 - leechers ascending; +orderby=7 +### END CONFIGURATION ### + +thisfile="$0" + +printhelp() { + echo -e "Usage:" + echo -e "\t$thisfile [options] search query" + echo + echo + echo -e "Available options:" + echo -e "\t-h\t\tShow help" + echo -e "\t-n [num]\tShow only first N results (default 15; max 100 [top] or 30 [search])" + echo -e "\t-C\t\tDo not use colors" + echo -e "\t-P [prog]\tSet torrent client command (\`-P torrent-client\` OR \`-P \"torrent-client --options\"\`)" + echo + echo -e "Current client settings: $program [magnet link]" +} + +# change torrent client +chex() { + sed "s!^program=.*!program=\'$program\'!" -i "$thisfile" + if [ $? -eq 0 ] ; then + echo "Client changed successfully." + exit 0 + else + echo -e "${errocolor}(EE) ${mesgcolor}==> Something went wrong!${nonecolor}" + exit 1 + fi +} + +# script cmdline option handling +while getopts :hn:CP:: opt ; do + case "$opt" in + h) printhelp; exit 0;; + n) limit="$OPTARG";; + C) unset numbcolor namecolor sizecolor seedcolor peercolor nonecolor errocolor mesgcolor;; + P) program="$OPTARG"; chex;; + *) echo -e "Unknown option(s)."; printhelp; exit 1;; + esac +done + +shift `expr $OPTIND - 1` + +# correctly encode query +q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` + +# if not searching, show top torrents +if [ -z "$q" ] ; then + url="top/all" +else + url='search/'"$q"'/0/'"$orderby"'/0' +fi + +# get results +# Here be dragons! +r=`curl -k -A Mozilla -b "lw=s" -m 15 -s "$TPB/$url" \ + | grep -Eo '^]*>.*|^[^<]*' \ + | sed 's!^]*>!!; \ + s!$!!; \ + s!^]*>!!; \ + s! !\ !g; \ + s/|/!/g' \ + | sed 'N;N;N;N;s!\n!|!g'` + +# number of results +n=`echo "$r" | wc -l` + +IFS=$'\n' + +# print results +echo "$r" \ + | head -n "$limit" \ + | awk -v N=1 \ + -v NU="$numbcolor" \ + -v NA="$namecolor" \ + -v SI="$sizecolor" \ + -v SE="$seedcolor" \ + -v PE="$peercolor" \ + -v NO="$nonecolor" \ + -F '|' \ + '{print NU N ") " NA $1 " " SI $3 " " SE $4 " " PE $5 NO; N++}' + +# read ID(s), expand ranges, ignore everything else +read -p ">> Torrents to download (eg. 1 3 5-7): " selection +IFS=$'\n\ ' +for num in $selection ; do + if [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*'`" ] ; then + down="$down $num" + elif [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*-[[:digit:]][[:digit:]]*'`" ] ; then + seqstart="${num%-*}" + seqend="${num#*-}" + if [ $seqstart -le $seqend ] ; then + down="$down `seq $seqstart $seqend`" + fi + fi +done + +# normalize download list, sort it and remove dupes +down="$(echo $down | tr '\ ' '\n' | sort -n | uniq)" +IFS=$'\n' + +# check whether we're downloading something, else exit +if [ -z "$down" ] ; then + exit 0 +fi + +# starts daemon if it was not already running and download all torrents in list +echo -n "Downloading torrent(s): " +if ! [ "$(pidof $daemon)" ]; then + $daemon + for torrent in $down ; do + # check if ID is valid and in range of results, download torrent + if [ $torrent -ge 1 ] ; then + if [ $torrent -le $limit ] ; then + echo -n "$torrent " + command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`" + status=$(eval "$command" 2>&1) + if [ $? -ne 0 ] ; then + echo -n '(failed!) ' + report="$report\n(#$torrent) $status" + fi + fi + fi + done +fi + +echo +if [ -n "$report" ] ; then + echo -n "Exited with errors:" + echo -e "$report" +fi +unset IFS diff --git a/.scripts/tools/transadd b/.scripts/tools/transadd new file mode 100755 index 0000000..782f67a --- /dev/null +++ b/.scripts/tools/transadd @@ -0,0 +1,12 @@ +#!/bin/sh + +# Mimeapp script for adding torrent to transmission-daemon, but will also start +# the daemon first if not running. + +# Optionally requires my `note` script. The sleep of 3 seconds is because the +# transmission-daemon sometimes fails to take remote requests in its first +# moments. + +pgrep -x transmission-da || (transmission-daemon && note "Starting daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) + +transmission-remote -a "$@" && note "Torrent added." diff --git a/.scripts/tpb b/.scripts/tpb deleted file mode 100755 index 7a2913a..0000000 --- a/.scripts/tpb +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# by Sairon Istyar, 2012 -# distributed under the GPLv3 license -# http://www.opensource.org/licenses/gpl-3.0.html -# - -### CONFIGURATION ### -# program to use for torrent download -# magnet link to torrent will be appended -# you can add -- at the end to indicate end of options -# (if your program supports it, most do) -program='/usr/bin/transmission-remote -a' -daemon='transmission-daemon' -TPB="https://thepiratebay.org" - -# show N first matches by default -limit=50 - -# colors -numbcolor='\x1b[1;35m' -namecolor='\x1b[1;33m' -sizecolor='\x1b[1;36m' -seedcolor='\x1b[1;31m' -peercolor='\x1b[1;32m' -errocolor='\x1b[1;31m' -mesgcolor='\x1b[1;37m' -nonecolor='\x1b[0m' - -# default ordering method -# 1 - name ascending; 2 - name descending; -# 3 - recent first; 4 - oldest first; -# 5 - size descending; 6 - size ascending; -# 7 - seeds descending; 8 - seeds ascending; -# 9 - leechers descending; 10 - leechers ascending; -orderby=7 -### END CONFIGURATION ### - -thisfile="$0" - -printhelp() { - echo -e "Usage:" - echo -e "\t$thisfile [options] search query" - echo - echo - echo -e "Available options:" - echo -e "\t-h\t\tShow help" - echo -e "\t-n [num]\tShow only first N results (default 15; max 100 [top] or 30 [search])" - echo -e "\t-C\t\tDo not use colors" - echo -e "\t-P [prog]\tSet torrent client command (\`-P torrent-client\` OR \`-P \"torrent-client --options\"\`)" - echo - echo -e "Current client settings: $program [magnet link]" -} - -# change torrent client -chex() { - sed "s!^program=.*!program=\'$program\'!" -i "$thisfile" - if [ $? -eq 0 ] ; then - echo "Client changed successfully." - exit 0 - else - echo -e "${errocolor}(EE) ${mesgcolor}==> Something went wrong!${nonecolor}" - exit 1 - fi -} - -# script cmdline option handling -while getopts :hn:CP:: opt ; do - case "$opt" in - h) printhelp; exit 0;; - n) limit="$OPTARG";; - C) unset numbcolor namecolor sizecolor seedcolor peercolor nonecolor errocolor mesgcolor;; - P) program="$OPTARG"; chex;; - *) echo -e "Unknown option(s)."; printhelp; exit 1;; - esac -done - -shift `expr $OPTIND - 1` - -# correctly encode query -q=`echo "$*" | tr -d '\n' | od -t x1 -A n | tr ' ' '%'` - -# if not searching, show top torrents -if [ -z "$q" ] ; then - url="top/all" -else - url='search/'"$q"'/0/'"$orderby"'/0' -fi - -# get results -# Here be dragons! -r=`curl -k -A Mozilla -b "lw=s" -m 15 -s "$TPB/$url" \ - | grep -Eo '^]*>.*|^[^<]*' \ - | sed 's!^]*>!!; \ - s!$!!; \ - s!^]*>!!; \ - s! !\ !g; \ - s/|/!/g' \ - | sed 'N;N;N;N;s!\n!|!g'` - -# number of results -n=`echo "$r" | wc -l` - -IFS=$'\n' - -# print results -echo "$r" \ - | head -n "$limit" \ - | awk -v N=1 \ - -v NU="$numbcolor" \ - -v NA="$namecolor" \ - -v SI="$sizecolor" \ - -v SE="$seedcolor" \ - -v PE="$peercolor" \ - -v NO="$nonecolor" \ - -F '|' \ - '{print NU N ") " NA $1 " " SI $3 " " SE $4 " " PE $5 NO; N++}' - -# read ID(s), expand ranges, ignore everything else -read -p ">> Torrents to download (eg. 1 3 5-7): " selection -IFS=$'\n\ ' -for num in $selection ; do - if [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*'`" ] ; then - down="$down $num" - elif [ "$num" = "`echo $num | grep -o '[[:digit:]][[:digit:]]*-[[:digit:]][[:digit:]]*'`" ] ; then - seqstart="${num%-*}" - seqend="${num#*-}" - if [ $seqstart -le $seqend ] ; then - down="$down `seq $seqstart $seqend`" - fi - fi -done - -# normalize download list, sort it and remove dupes -down="$(echo $down | tr '\ ' '\n' | sort -n | uniq)" -IFS=$'\n' - -# check whether we're downloading something, else exit -if [ -z "$down" ] ; then - exit 0 -fi - -# starts daemon if it was not already running and download all torrents in list -echo -n "Downloading torrent(s): " -if ! [ "$(pidof $daemon)" ]; then - $daemon - for torrent in $down ; do - # check if ID is valid and in range of results, download torrent - if [ $torrent -ge 1 ] ; then - if [ $torrent -le $limit ] ; then - echo -n "$torrent " - command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`" - status=$(eval "$command" 2>&1) - if [ $? -ne 0 ] ; then - echo -n '(failed!) ' - report="$report\n(#$torrent) $status" - fi - fi - fi - done -fi - -echo -if [ -n "$report" ] ; then - echo -n "Exited with errors:" - echo -e "$report" -fi -unset IFS diff --git a/.scripts/transadd b/.scripts/transadd deleted file mode 100755 index 782f67a..0000000 --- a/.scripts/transadd +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Mimeapp script for adding torrent to transmission-daemon, but will also start -# the daemon first if not running. - -# Optionally requires my `note` script. The sleep of 3 seconds is because the -# transmission-daemon sometimes fails to take remote requests in its first -# moments. - -pgrep -x transmission-da || (transmission-daemon && note "Starting daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks) - -transmission-remote -a "$@" && note "Torrent added." diff --git a/.scripts/tutorialvids b/.scripts/tutorialvids deleted file mode 100755 index f248253..0000000 --- a/.scripts/tutorialvids +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -vidlist=" -status bar https://www.youtube.com/watch?v=gKumet6b-WY -feh -i3 -mutt https://www.youtube.com/watch?v=2U3vRbF7v5A -ncmpcpp https://www.youtube.com/watch?v=sZIEdI9TS2U -newsboat https://www.youtube.com/watch?v=dUFCRqs822w -ranger https://www.youtube.com/watch?v=L6Vu7WPkoJo -zathura -gpg keys https://www.youtube.com/watch?v=DMGIlj7u7Eo -calcurse https://www.youtube.com/watch?v=hvc-pHjbhdE -urlview https://www.youtube.com/watch?v=IgzpAjFgbCw -vi mode in shell https://www.youtube.com/watch?v=GqoJQft5R2E -" - -mpv "$(echo "$vidlist" | grep -P "^$(echo "$vidlist" | grep "https:" | sed 's/\t.*//g' | dmenu -i -p "Learn about what? (ESC to cancel)" -l 5)\\t" | sed 's/.*\t//')" -- cgit v1.3.1