Massive overhaul to scripts file
This commit is contained in:
parent
d7285aa85d
commit
cc5bc1c236
1 changed files with 223 additions and 116 deletions
229
scripts.org
229
scripts.org
|
|
@ -1,8 +1,44 @@
|
||||||
#+PROPERTY: header-args :mkdirp yes
|
#+PROPERTY: header-args :mkdirp yes
|
||||||
#+title:General-Use Scripts
|
#+title:General-Use Scripts
|
||||||
|
|
||||||
|
# Define interpreter paths
|
||||||
|
#+name: fish-shebang
|
||||||
|
#+begin_src emacs-lisp :results value raw :exports none
|
||||||
|
(format "%s"
|
||||||
|
(if (eq system-type 'darwin)
|
||||||
|
"#!/usr/local/bin/fish"
|
||||||
|
"#!/run/current-system/sw/bin/fish"))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS: fish-shebang
|
||||||
|
#!/run/current-system/sw/bin/fish
|
||||||
|
|
||||||
|
|
||||||
|
#+name: python-shebang
|
||||||
|
#+begin_src emacs-lisp :results raw :exports none
|
||||||
|
(if (eq system-type 'darwin)
|
||||||
|
"#!/usr/local/bin/python3"
|
||||||
|
"#!/run/current-system/sw/bin/python3")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+name: bash-shebang
|
||||||
|
#+begin_src emacs-lisp :results raw :exports none
|
||||||
|
(if (eq system-type 'darwin)
|
||||||
|
"#!/usr/local/bin/bash"
|
||||||
|
"#!/run/current-system/sw/bin/bash")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+name: sh-shebang
|
||||||
|
#+begin_src emacs-lisp :results raw :exports none
|
||||||
|
(if (eq system-type 'darwin)
|
||||||
|
"#!/usr/local/bin/sh"
|
||||||
|
"#!/run/current-system/sw/bin/sh")
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Purpose
|
* Purpose
|
||||||
This repo contains scripts that I like to have available from my $PATH
|
This repo contains scripts that I like to have available from my $PATH
|
||||||
#+TOC: headlines 2
|
#+TOC: headlines 2
|
||||||
|
|
||||||
* GUI-ish
|
* GUI-ish
|
||||||
- Glue scripts for sxhkd / bspwm / polybar
|
- Glue scripts for sxhkd / bspwm / polybar
|
||||||
** Dmenu_run_top
|
** Dmenu_run_top
|
||||||
|
|
@ -11,15 +47,8 @@ This repo contains scripts that I like to have available from my $PATH
|
||||||
- test monospace instead of bitstream
|
- test monospace instead of bitstream
|
||||||
- remove flavours placeholder (once flavours is ready)
|
- remove flavours placeholder (once flavours is ready)
|
||||||
- consider moving this to an alias
|
- consider moving this to an alias
|
||||||
#+begin_src sh :tangle ~/usr/local/bin/dmenu_run_top
|
#+begin_src sh :tangle /sudo::/usr/local/bin/dmenu_run_top :noweb yes :tangle-mode o755
|
||||||
#!/bin/sh
|
<<sh-shebang()>>
|
||||||
|
|
||||||
# start flavours
|
|
||||||
norm_fg="#C0C5CE"
|
|
||||||
norm_bg="#1B2B34"
|
|
||||||
sel_fg="#1B2B34"
|
|
||||||
sel_bg="#99C794"
|
|
||||||
# end flavours
|
|
||||||
|
|
||||||
dmenu_run \
|
dmenu_run \
|
||||||
-i \
|
-i \
|
||||||
|
|
@ -36,8 +65,8 @@ dmenu_run \
|
||||||
*** TODO
|
*** TODO
|
||||||
- make work on mac
|
- make work on mac
|
||||||
- recreate the emojis file and test
|
- recreate the emojis file and test
|
||||||
#+begin_src sh :tangle ~/usr/local/bin/dmenuunicode
|
#+begin_src sh :tangle /sudo::/usr/local/bin/dmenuunicode :noweb yes :tangle-mode o755
|
||||||
#!/bin/sh
|
<<sh-shebang()>>
|
||||||
|
|
||||||
# Get user selection via dmenu from emoji file.
|
# Get user selection via dmenu from emoji file.
|
||||||
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//")
|
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//")
|
||||||
|
|
@ -60,8 +89,8 @@ dmenu_run \
|
||||||
- Better handled through polybar probably
|
- Better handled through polybar probably
|
||||||
*** TODO
|
*** TODO
|
||||||
- Add support for 3+ languages
|
- Add support for 3+ languages
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/languagecycle
|
#+begin_src fish :tangle /sudo::/usr/local/bin/languagecycle :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
|
|
||||||
if [ (xkblayout-state print "%n") = "Russian" ]
|
if [ (xkblayout-state print "%n") = "Russian" ]
|
||||||
setxkbmap -layout us
|
setxkbmap -layout us
|
||||||
|
|
@ -75,8 +104,8 @@ if [ (xkblayout-state print "%n") = "Russian" ]
|
||||||
*** TODO
|
*** TODO
|
||||||
- Currently this adds layouts to an endless list of layouts which can cause lag
|
- Currently this adds layouts to an endless list of layouts which can cause lag
|
||||||
- This should be fixed but I'm not sure if I even like using alternate layouts
|
- This should be fixed but I'm not sure if I even like using alternate layouts
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/layoutcycle
|
#+begin_src fish :tangle /sudo::/usr/local/bin/layoutcycle :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
|
|
||||||
bsp-layout next --layouts tall,grid,rgrid,tiled
|
bsp-layout next --layouts tall,grid,rgrid,tiled
|
||||||
|
|
||||||
|
|
@ -113,20 +142,18 @@ else if [ $layout = "tiled" ]
|
||||||
" | | | | \n" \
|
" | | | | \n" \
|
||||||
" |________|__|_| " )
|
" |________|__|_| " )
|
||||||
end
|
end
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Appearance
|
* Appearance
|
||||||
** Colors
|
** Colors
|
||||||
> Taken from https://stackoverflow.com/questions/69138165/how-to-get-the-rgb-values-of-a-256-color-palette-terminal-color
|
> Taken from https://stackoverflow.com/questions/69138165/how-to-get-the-rgb-values-of-a-256-color-palette-terminal-color
|
||||||
- Returns a representation of your currently set color scheme
|
- Returns a representation of your currently set color scheme
|
||||||
#+begin_src sh :tangle ~/usr/local/bin/colors
|
#+begin_src sh :tangle /sudo::/usr/local/bin/colors :noweb yes :tangle-mode o755
|
||||||
#!/bin/sh
|
<<sh-shebang()>>
|
||||||
|
|
||||||
xdef="$HOME/.Xresources"
|
xdef="$HOME/.Xresources"
|
||||||
|
|
||||||
colors=( $( sed -re '/^!/d; /^$/d; /^#/d; s/(\*color)([0-9]):/\10\2:/g;' $xdef | grep 'color[01][0-9]:' | sort | sed 's/^.*: *//g' )
|
colors=( $( sed -re '/^!/d; /^$/d; /^#/d; s/(\*color)([0-9]):/\10\2:/g;' $xdef | grep 'color[01][0-9]:' | sort | sed 's/^.*: *//g' ) )
|
||||||
)
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
for i in {0..7}; do echo -en "\e[$((30+$i))m ${colors[i]} \u2588\u2588 \e[0m\n"; done
|
for i in {0..7}; do echo -en "\e[$((30+$i))m ${colors[i]} \u2588\u2588 \e[0m\n"; done
|
||||||
|
|
@ -135,33 +162,10 @@ for i in {8..15}; do echo -en "\e[1;$((22+$i))m ${colors[i]} \u2588\u2588 \e[0m\
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Gapcycle
|
|
||||||
- Cycle between 3 window gap sizes I find aesthetic
|
|
||||||
*** TODO
|
|
||||||
- This is broken
|
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/gapcycle
|
|
||||||
#!/usr/bin/fish
|
|
||||||
|
|
||||||
set gap (bspc config window_gap)
|
|
||||||
|
|
||||||
if [ $gap = 40 ]
|
|
||||||
set new_gap 18
|
|
||||||
else if [ $gap = 18 ]
|
|
||||||
set new_gap 12
|
|
||||||
else if [ $gap = 12 ]
|
|
||||||
set new_gap 0
|
|
||||||
else if [ $gap = 0 ]
|
|
||||||
set new_gap 40
|
|
||||||
end
|
|
||||||
|
|
||||||
bspc config window_gap $new_gap
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Themepick
|
** Themepick
|
||||||
- Broken in nix until I find an equivalent base16 theme setter and / or setup flavours
|
- Broken in nix until I find an equivalent base16 theme setter and / or setup flavours
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/themepick
|
#+begin_src fish :tangle /sudo::/usr/local/bin/themepick :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
|
|
||||||
set theme (flavours list | tr ' ' '\n' | dmenu)
|
set theme (flavours list | tr ' ' '\n' | dmenu)
|
||||||
|
|
||||||
flavours apply $theme &&
|
flavours apply $theme &&
|
||||||
|
|
@ -171,16 +175,17 @@ echo -e "\n"
|
||||||
** Opaque-windows
|
** Opaque-windows
|
||||||
*** TODO
|
*** TODO
|
||||||
- Handle this through lemonbar instead
|
- Handle this through lemonbar instead
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/opaque-windows
|
#+begin_src fish :tangle /sudo::/usr/local/bin/opaque-windows :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
if ps -aux | grep picom | grep -v grep
|
if ps -aux | grep picom | grep -v grep
|
||||||
pkill picom
|
pkill picom
|
||||||
end
|
end
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Transparent-windows
|
** Transparent-windows
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/transparent-windows
|
#+begin_src fish :tangle /sudo::/usr/local/bin/transparent-windows :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
|
|
||||||
if ps -aux | grep picom | grep -v grep
|
if ps -aux | grep picom | grep -v grep
|
||||||
pkill picom
|
pkill picom
|
||||||
end
|
end
|
||||||
|
|
@ -188,7 +193,7 @@ echo -e "\n"
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
picom \
|
picom \
|
||||||
--conf /dev/null \
|
--conf /dev/null \
|
||||||
-i 0.8 \
|
-i 0. \
|
||||||
--active-opacity 1.0 \
|
--active-opacity 1.0 \
|
||||||
--focus-exclude "x = 0 && y = 0 && override_redirect = true" &
|
--focus-exclude "x = 0 && y = 0 && override_redirect = true" &
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
@ -200,14 +205,15 @@ echo -e "\n"
|
||||||
- I prefer this for passwords I might have to type manually occasionally
|
- I prefer this for passwords I might have to type manually occasionally
|
||||||
*** TODO
|
*** TODO
|
||||||
- This may be better as an alias
|
- This may be better as an alias
|
||||||
#+begin_src bash :tangle ~/usr/local/bin/generate-passphrase
|
#+begin_src bash :tangle /sudo::/usr/local/bin/generate-passphrase :noweb yes :tangle-mode o755
|
||||||
#!/bin/bash
|
<<bash-shebang()>>
|
||||||
shuf -n3 /usr/share/dict/words | tr -d '\n'
|
shuf -n3 /usr/share/dict/words | tr -d '\n'
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Passphrase
|
** Passphrase
|
||||||
- This more specifically inserts the generated passphrase into gnu pass
|
- This more specifically inserts the generated passphrase into gnu pass
|
||||||
#+begin_src fish :tangle ~/usr/local/bin/passphrase
|
#+begin_src fish :tangle /sudo::/usr/local/bin/passphrase :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/fish
|
<<fish-shebang()>>
|
||||||
generate-passphrase | pass insert -e $argv
|
generate-passphrase | pass insert -e $argv
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
@ -215,8 +221,8 @@ echo -e "\n"
|
||||||
** Prune_local_branches
|
** Prune_local_branches
|
||||||
*** TODO
|
*** TODO
|
||||||
- Don't do this. Use a git alias.
|
- Don't do this. Use a git alias.
|
||||||
#+begin_src bash :tangle ~/usr/local/bin/passphrase
|
#+begin_src bash :tangle /sudo::/usr/local/bin/prune_local_branches :noweb yes :tangle-mode o755
|
||||||
#!/bin/bash
|
<<bash-shebang()>>
|
||||||
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -r -n 1 git branch -D
|
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -r -n 1 git branch -D
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
@ -227,8 +233,9 @@ git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs
|
||||||
*** TODO
|
*** TODO
|
||||||
- Remove lemobar, test with polybar
|
- Remove lemobar, test with polybar
|
||||||
- Handle API endpoint as a secret
|
- Handle API endpoint as a secret
|
||||||
#+begin_src python :tangle ~/usr/local/bin/sugar
|
#+begin_src python :tangle /sudo::/usr/local/bin/sugar :noweb yes :tangle-mode o755
|
||||||
#!/usr/bin/python3
|
<<python-shebang()>>
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
@ -253,7 +260,6 @@ git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs
|
||||||
|
|
||||||
sugar = res.json()[0]
|
sugar = res.json()[0]
|
||||||
|
|
||||||
|
|
||||||
delta = sugar['delta']
|
delta = sugar['delta']
|
||||||
sgv = sugar['sgv']
|
sgv = sugar['sgv']
|
||||||
direction = sugar['direction']
|
direction = sugar['direction']
|
||||||
|
|
@ -298,10 +304,111 @@ git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs
|
||||||
** Jbrowse
|
** Jbrowse
|
||||||
*** TODO
|
*** TODO
|
||||||
- Probably handle these as aliases
|
- Probably handle these as aliases
|
||||||
#+begin_src sh :tangle ~/usr/local/bin
|
#+begin_src sh :tangle /sudo::/usr/local/bin/jbrowse :noweb yes :tangle-mode o755
|
||||||
/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser "https://everblue.atlassian.net/browse/"$1 &
|
/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser "https://everblue.atlassian.net/browse/"$1 &
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** NotifyMe
|
** NotifyMe
|
||||||
#+begin_src sh :tangle ~/usr/local/bin
|
#+begin_src sh :tangle /sudo::/usr/local/bin/notifyme :noweb yes :tangle-mode o755
|
||||||
osascript -e 'display notification "done!" with title "Notification"'
|
osascript -e 'display notification "done!" with title "Notification"'
|
||||||
#+end_src
|
#+end_src
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#+begin_src sh :tangle /sudo::/usr/local/bin/demnu_run :noweb yes :tangle-mode o755
|
||||||
|
<<sh-shebang()>>
|
||||||
|
|
||||||
|
dmenu_run \
|
||||||
|
-i \
|
||||||
|
-fn BitstreamVeraSansMono:size=11 \
|
||||||
|
-l 15 \
|
||||||
|
-nf "$norm_fg" \
|
||||||
|
-nb "$norm_bg" \
|
||||||
|
-sf "$sel_fg" \
|
||||||
|
-sb "$sel_bg"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Dmenuunicode
|
||||||
|
- Get emojis from dmenu
|
||||||
|
*** TODO
|
||||||
|
- make work on mac
|
||||||
|
- recreate the emojis file and test
|
||||||
|
#+begin_src sh :tangle /sudo::usr/local/bin/dmenuunicode :noweb yes :tangle-mode o755
|
||||||
|
<<sh-shebang()>>
|
||||||
|
|
||||||
|
# Get user selection via dmenu from emoji file.
|
||||||
|
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 30 | sed "s/ .*//")
|
||||||
|
|
||||||
|
# Exit if none chosen.
|
||||||
|
[ -z "$chosen" ] && exit
|
||||||
|
|
||||||
|
# If you run this command with an argument, it will automatically insert the
|
||||||
|
# character. Otherwise, show a message that the emoji has been copied.
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
xdotool type "$chosen"
|
||||||
|
else
|
||||||
|
printf "$chosen" | xclip -selection clipboard
|
||||||
|
notify-send "'$chosen' copied to clipboard." &
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Languagecycle
|
||||||
|
- Cycle between a couple languages
|
||||||
|
- Better handled through polybar probably
|
||||||
|
*** TODO
|
||||||
|
- Add support for 3+ languages
|
||||||
|
#+begin_src fish :tangle /sudo::usr/local/bin/languagecycle :noweb yes :tangle-mode o755
|
||||||
|
<<fish-shebang()>>
|
||||||
|
|
||||||
|
if [ (xkblayout-state print "%n") = "Russian" ]
|
||||||
|
setxkbmap -layout us
|
||||||
|
else
|
||||||
|
setxkbmap -layout ru
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Layoutcycle
|
||||||
|
- Cycle windows between different layouts
|
||||||
|
*** TODO
|
||||||
|
- Currently this adds layouts to an endless list of layouts which can cause lag
|
||||||
|
- This should be fixed but I'm not sure if I even like using alternate layouts
|
||||||
|
#+begin_src fish :tangle /sudo::usr/local/bin/layoutcycle :noweb yes :tangle-mode o755
|
||||||
|
<<fish-shebang()>>
|
||||||
|
|
||||||
|
bsp-layout next --layouts tall,grid,rgrid,tiled
|
||||||
|
|
||||||
|
set layout (bsp-layout get)
|
||||||
|
|
||||||
|
if ps -aux | grep layoutcycle | grep -v grep
|
||||||
|
exit
|
||||||
|
else if [ $layout = "tall" ]
|
||||||
|
notify-send -t 1000 "Layout: Tall" (echo \
|
||||||
|
" ______________ \n" \
|
||||||
|
" | |____| \n" \
|
||||||
|
" | |____| \n" \
|
||||||
|
" | |____| \n" \
|
||||||
|
" |________|____| " )
|
||||||
|
else if [ $layout = "grid" ]
|
||||||
|
notify-send -t 1000 "Layout: hGrid" (echo \
|
||||||
|
" ____________ \n" \
|
||||||
|
" | | | | \n" \
|
||||||
|
" |___|___|___| \n" \
|
||||||
|
" | | | | \n" \
|
||||||
|
" |___|___|___| " )
|
||||||
|
else if [ $layout = "rgrid" ]
|
||||||
|
vgrid
|
||||||
|
notify-send -t 1000 "Layout: vGrid" (echo \
|
||||||
|
" ____________ \n" \
|
||||||
|
" |_____|_____| \n" \
|
||||||
|
" |_____|_____| \n" \
|
||||||
|
" |_____|_____| " )
|
||||||
|
else if [ $layout = "tiled" ]
|
||||||
|
notify-send -t 1000 "Layout: Tiled" (echo \
|
||||||
|
" ______________ \n" \
|
||||||
|
" | | | \n" \
|
||||||
|
" | |____| \n" \
|
||||||
|
" | | | | \n" \
|
||||||
|
" |________|__|_| " )
|
||||||
|
end
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue