Browse Source

Cleaned up scripts and added autorandr support

Signed-off-by: Micah Halter <micah@balena.io>
master
Micah Halter 8 months ago
parent
commit
ce1e7599d7
Signed by: mehalter GPG Key ID: 91C3B7AA970B3213
  1. 1
      Makefile
  2. 4
      autorandr/.config/autorandr/postswitch
  3. 1
      etc/udev/rules.d/00-makerdiary-m60.rules
  4. 14
      i3/.config/i3/config
  5. 2
      neovim/.config/nvim/init.vim
  6. 6
      scripts/.local/bin/bemenuaudiosink
  7. 7
      scripts/.local/bin/bemenuaudiosource
  8. 5
      scripts/.local/bin/bemenupass
  9. 3
      scripts/.local/bin/bemenushutdown
  10. 2
      scripts/.local/bin/bemenuyubiauth
  11. 5
      scripts/.local/bin/compiler
  12. 98
      scripts/.local/bin/displayctrl
  13. 6
      scripts/.local/bin/displayselect
  14. 3
      scripts/.local/bin/remaps
  15. 20
      scripts/.local/bin/texclear
  16. 4
      scripts/.local/bin/tmuxiplex
  17. 4
      scripts/.local/bin/vim-anywhere
  18. 2
      vdirsyncer/.config/systemd/user/vdirsyncer-oneshot.service
  19. 35
      zsh/.config/zsh/aliases

1
Makefile

@ -45,6 +45,7 @@ arch: pacman
alsa-utils \
aria2 \
asciinema \
autorandr \
bemenu \
biber \
ccid \

4
autorandr/.config/autorandr/postswitch

@ -0,0 +1,4 @@
#!/bin/sh
setbackground
remaps

1
etc/udev/rules.d/00-makerdiary-m60.rules

@ -0,0 +1 @@
ACTION=="add", ATTRS{idVendor}=="2886", ATTRS{idProduct}=="f002", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/run/user/1000/Xauthority", RUN+="/bin/bash -c 'xset r rate 300 50'"

14
i3/.config/i3/config

@ -102,7 +102,7 @@ for_window [instance="ncpamixer"] move scratchpad
# start weather in floating window
for_window [instance="weather"] floating enable
for_window [instance="weather"] resize set 1030 660
for_window [instance="weather"] resize set $smallwidth $smallheight
for_window [instance="weather"] move position center
for_window [instance="weather"] move scratchpad
@ -414,16 +414,16 @@ bindsym $mod+Shift+Control+space exec --no-startup-id echo "cycle pause"
# FUNCTION KEYBINDINGS #
########################
bindsym $mod+F1 exec --no-startup-id displayctrl HDMI-3
bindsym $mod+F1 exec --no-startup-id autorandr -l none
#bindsym $mod+Shift+F1
bindsym $mod+F2 exec --no-startup-id displayctrl HDMI-2
bindsym $mod+F2 exec --no-startup-id autorandr --change
#bindsym $mod+Shift+F2
bindsym $mod+F3 exec --no-startup-id displayctrl -r HDMI-2 HDMI-3
bindsym $mod+Shift+F3 exec --no-startup-id displayctrl -r HDMI-2 -p HDMI-3
#bindsym $mod+F3
#bindsym $mod+Shift+F3
bindsym $mod+F4 exec --no-startup-id displayctrl LVDS-1
#bindsym $mod+F4
#bindsym $mod+Shift+F4
bindsym $mod+F5 exec --no-startup-id bash -c "i3-powersaver && dunstbar -s powersaver -t 1000"
@ -468,7 +468,7 @@ bindsym $mod+Home exec --no-startup-id toggleservice micah
#bindsym $mod+Insert
#bindsym $mod+Shift+Insert
bindsym $mod+Delete exec --no-startup-id lock
bindsym $mod+Delete exec --no-startup-id systemctl suspend
#bindsym $mod+Shift+Delete
#bindsym $mod+Prior

2
neovim/.config/nvim/init.vim

@ -295,6 +295,8 @@ let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 20
let ghregex='\(^\|\s\s\)\zs\.\S\+'
let g:netrw_list_hide=ghregex
map <leader>nn :call ToggleNetrw()<CR>
let g:NetrwIsOpen=0
function! ToggleNetrw() abort

6
scripts/.local/bin/bemenuaudiosink

@ -13,7 +13,7 @@ SINK_NAMES=$(pactl list sinks | ag Name | cut --complement -c 1-7)
DEFAULT_INDEX=$(printf "%s" "$SINK_NAMES" | sed -n "/$SINK_DEFAULT/=" | sed 's/:.*//' )
# Get the audio sink descriptions
SINK_DESCRIPTIONS=$(pactl list sinks | ag Description | cut --complement -c 1-13 | sed 's/^ \+//' | sed 's/ \+$//')
SINK_DESCRIPTIONS=$(pactl list sinks | grep -e "Sink #.*" -e 'Description: .*' | sed 's/^Sink\s\+#//g; s/\s\+Description:\s\+//g' | paste -sd ':\n')
# Get all the programs that revieve the audio from the sinks
SINK_INPUTS=$(pactl list sink-inputs | ag "Sink Input #")
@ -22,9 +22,7 @@ SINK_DESCRIPTION=$(printf "%s" "$SINK_DESCRIPTIONS" | sed "${DEFAULT_INDEX}d" |
SINK_DESCRIPTION=$(printf "%s" "$SINK_DESCRIPTION" | sed 's/(/\\(/' | sed 's/)/\\)/')
# Get the index for the answer that the user wrote
DESCRIPTION_INDEX=$(printf "%s\n" "$SINK_DESCRIPTIONS" | sed -n "/$SINK_DESCRIPTION/=" | sed 's/:.*//')
DESCRIPTION_INDEX=$((DESCRIPTION_INDEX - 1)) # Correct the index hihi
echo $DESCRIPTION_INDEX
DESCRIPTION_INDEX=$(echo "$SINK_DESCRIPTION" | cut -d\: -f1)
# Set the default sink
pactl set-default-sink $DESCRIPTION_INDEX

7
scripts/.local/bin/bemenuaudiosource

@ -14,17 +14,16 @@ SOURCE_NAMES=$(pactl list sources | ag Name | cut --complement -c 1-7)
DEFAULT_INDEX=$(printf "%s" "$SOURCE_NAMES" | sed -n "/$SOURCE_DEFAULT/=" | sed 's/:.*//' )
# Get the audio source descriptions
SOURCE_DESCRIPTIONS=$(pactl list sources | ag Description | cut --complement -c 1-13 | sed 's/^ \+//' | sed 's/ \+$//')
SOURCE_DESCRIPTIONS=$(pactl list sources | grep -e "Source #.*" -e 'Description: .*' | sed 's/^Source\s\+#//g; s/\s\+Description:\s\+//g' | paste -sd ':\n')
# Get all the programs that revieve the audio from the sources
SOURCE_INPUTS=$(pactl list source-outputs | ag "Source Output #")
# Get the descriptions from the sources without the default source to display to the user and have the user pick a source
SOURCE_DESCRIPTION=$(printf "%s" "$SOURCE_DESCRIPTIONS" | sed "${DEFAULT_INDEX}d" | bemenucolor -i -p "Select source:")
SOURCE_DESCRIPTION=$(printf "%s" "$SOURCE_DESCRIPTIONS" | sed "${DEFAULT_INDEX}d" | grep -v "^[0-9]\+:Monitor\s\+of" | bemenucolor -i -p "Select source:")
SOURCE_DESCRIPTION=$(printf "%s" "$SOURCE_DESCRIPTION" | sed 's/(/\\(/' | sed 's/)/\\)/')
# Get the index for the answer that the user wrote
DESCRIPTION_INDEX=$(printf "%s\n" "$SOURCE_DESCRIPTIONS" | ag --number "$SOURCE_DESCRIPTION" | sed 's/:.*//')
DESCRIPTION_INDEX=$((DESCRIPTION_INDEX - 1)) # Correct the index hihi
DESCRIPTION_INDEX=$(echo "$SOURCE_DESCRIPTION" | cut -d\: -f1)
# Set the default source
pactl set-default-source $DESCRIPTION_INDEX

5
scripts/.local/bin/bemenupass

@ -8,10 +8,7 @@ if [[ $1 == "--type" ]]; then
shift
fi
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
password_files=$(gopass ls --flat)
password=$(printf '%s\n' "${password_files[@]}" | bemenucolor -p "Passwords:" -i "$@")

3
scripts/.local/bin/bemenushutdown

@ -1,10 +1,11 @@
#!/bin/env sh
ACTION="$(printf "lock\\nexit\\nreboot\\nshutdown\\n" | bemenucolor -i -p "Power:")"
ACTION="$(printf "lock\\nsleep\\nexit\\nreboot\\nshutdown\\n" | bemenucolor -i -p "Power:")"
case "$ACTION" in
"lock") lock ;;
"exit") i3-msg exit ;;
"sleep") systemctl suspend ;;
"reboot") systemctl reboot ;;
"shutdown") systemctl poweroff -i ;;
esac

2
scripts/.local/bin/bemenuyubiauth

@ -1,7 +1,5 @@
#!/bin/env sh
pgrep -x bemenu && exit
chosen=$(ykman oath list|awk -F':' '{print $1}'|bemenucolor -i -p "oauth:"|awk '{print $1}')
[ -n "$chosen" ] || exit

5
scripts/.local/bin/compiler

@ -27,7 +27,10 @@ case "$file" in
*\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
*\.rmd) echo "require(rmarkdown);rmarkdown::render('$file', quiet=TRUE)" | R -q --vanilla && pdfpcCleanup ;;
*\.tex) latexmk -synctex=1 --pdf "$file" && [ -e "$base".pdfpc ] && pdfpcCleanup ;;
*\.md) if [ -e "$base"_template.tex ] ; then pandoc --template "$base"_template.tex "$file" --filter pandoc-crossref --citeproc --variable urlcolor=blue -o "$base".pdf; else pandoc "$file" --filter pandoc-crossref --citeproc --variable urlcolor=blue -o "$base".pdf; fi ;;
*\.md) if [ -e "$base"_template.tex ] ; then
pandoc --template "$base"_template.tex "$file" --filter pandoc-crossref --citeproc --variable urlcolor=blue -o "$base".pdf;
else
pandoc "$file" -t ms --highlight-style=kate --filter pandoc-crossref --citeproc --variable urlcolor=blue -s -o "$base".pdf; fi ;;
*config.h) make && sudo make install ;;
*\.c) gcc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;;

98
scripts/.local/bin/displayctrl

@ -1,98 +0,0 @@
#!/bin/env bash
showusage() {
echo "Usage:"
echo " screen.sh [options] main-display"
echo ""
echo "Options:"
echo " -l <display> Display to be used to the left of main-display"
echo " -r <display> Display to be used to the right of main-display"
echo " -p Rotate the display on the sides of the main-display to portrait to the right"
echo " -P Rotate the display on the sides of the main-display to portrait to the left"
echo " -s <file> Use saved xrandr script"
echo " -h Show this screen."
}
disablerest() {
cmd=$1
for line in $(xrandr -q|grep '\bconnected\b'|cut -d' ' -f1); do
if [[ ("$line" != "$middle") && ("$line" != "$left") && ("$line" != "$right") ]]; then
cmd="$cmd --output $line --off"
fi
done
echo "$cmd"
}
rotate="normal"
while getopts "s:l:r:hpP" opt; do
case ${opt} in
s )
script="$OPTARG"
;;
l )
left="$OPTARG"
;;
r )
right="$OPTARG"
;;
p )
rotate="right"
;;
P )
rotate="left"
;;
h )
showusage
exit 0
;;
\? )
echo "Invalid Option: -$OPTARG" 1>&2
showusage
exit 1
;;
esac
done
shift $((OPTIND - 1))
middle="$1"
cmd="xrandr "
if [[ "$script" == "" ]]; then
if [[ ("$middle" != "") && ($(xrandr -q |grep "$middle"\ con)) ]]; then
cmd="$cmd --output $middle --auto --rotate normal"
if [[ ("$left" != "") && ($(xrandr -q |grep "$left"\ con)) ]]; then
cmd="$cmd --output $left --auto --rotate $rotate --left-of $middle"
fi
if [[ ("$right" != "") && ($(xrandr -q |grep "$right"\ con)) ]]; then
cmd="$cmd --output $right --auto --rotate $rotate --right-of $middle"
fi
cmd=$(disablerest "$cmd")
else
echo "Falling back to only laptop display" 1>&2
middle="LVDS-1"
cmd=$(disablerest "$cmd")
if [[ ("$left" != "") && ($(xrandr -q |grep "$left"\ con)) ]]; then
cmd="$cmd --output $left --off"
fi
if [[ ("$right" != "") && ($(xrandr -q |grep "$right"\ con)) ]]; then
cmd="$cmd --output $right --off"
fi
cmd="$cmd --output LVDS-1 --auto"
fi
echo "$cmd"
eval "$cmd"
else
bash "$script"
fi
setbackground
remaps

6
scripts/.local/bin/displayselect

@ -62,14 +62,16 @@ allposs=$(xrandr -q | grep "connected")
# Get all connected screens.
screens=$(echo "$allposs" | grep " connected" | awk '{print $1}')
layouts=$(find "$layoutloc" -type f -name "*.sh" -printf "%f\n")
profiles=$(autorandr | grep -v "(current)" | sed -e 's/\s\+(detected)//')
virtualprofiles=$(printf "off\ncommon\nclone-largest\nhorizontal\nvertical")
layouts=$(printf "%s\n%s" "$profiles" "$virtualprofiles" | sed 's/^/ar:/')
# Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection\\n%s\\n" "$screens" "$layouts" | bemenucolor -i -p "Display:") &&
case "$chosen" in
"manual selection") arandr ; exit ;;
"multi-monitor") multimon ;;
*.sh) "$layoutloc"/"$chosen" ;;
ar:*) autorandr -l "$(echo $chosen | cut -d: -f2)" ;;
*) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
esac

3
scripts/.local/bin/remaps

@ -2,4 +2,5 @@
xset r rate 300 50
setxkbmap -option ctrl:nocaps
killall xcape ; xcape -t 200 -e "Control_L=Escape"
killall xcape 2>/dev/null; xcape -t 200 -e "Control_L=Escape"
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock

20
scripts/.local/bin/texclear

@ -1,10 +1,12 @@
#!/bin/env bash
#!/bin/sh
[[ "$1" == *.tex ]] || exit
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
rm -rf $dir/_minted-main
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|tdo|bcf|run\.xml|synctex\.gz|blg|bbl|glo|glg|gls|ist)" -delete
case "$1" in
*.tex)
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyg|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|tdo|bcf|run\\.xml|synctex\\.gz|blg|bbl|glo|glg|gls|ist)" -delete
rm -rdf "$dir/_minted-$(basename -- $base)"
;;
*) printf "Give .tex file as argument.\\n" ;;
esac

4
scripts/.local/bin/tmuxiplex

@ -28,10 +28,6 @@ if [ "$s_name" = "scratchpad" ]; then
w1_name="default"
$tmux new-session -d -s "${s_name}" -n "${w1_name}"
w2_name="vpn"
$tmux new-window -d -t "=${s_name}" -n "${w2_name}"
$tmux send-keys -t "=${s_name}:=${w2_name}.1" " gtrivpn"
w3_name="music"
$tmux new-window -d -t "=${s_name}" -n "${w3_name}"
$tmux send-keys -t "=${s_name}:=${w3_name}.1" "cmus" Enter

4
scripts/.local/bin/vim-anywhere

@ -4,8 +4,8 @@ setclip() {
xclip -selection c
}
file=$(mktemp).md
$TERMINAL -e "i3-runner \"$EDITOR '$file'\"" # replace with your favorite terminal
file=$(mktemp --suffix=.md)
$TERMINAL i3-runner "$EDITOR '$file'" # replace with your favorite terminal
setclip <"$file"
rm "$file"

2
vdirsyncer/.config/systemd/user/vdirsyncer-oneshot.service

@ -3,7 +3,7 @@ Description=vdirsyncer Service (oneshot)
[Service]
Type=oneshot
ExecStart=vdirsyncer sync
ExecStart=vdirsyncer sync --max-workers=1
TimeoutStopSec=120
[Install]

35
zsh/.config/zsh/aliases

@ -71,14 +71,29 @@ alias arc='aria2c'
alias sc='scim'
# gopass aliases
alias pls='gopass ls'
alias pnew='gopass create'
alias pshow='gopass show'
alias pedit='gopass edit'
alias pupdate='gopass update -p'
alias ptail='gopass tail'
alias ptedit='gopass tailedit'
pnew() {
gopass cp template $1 && gopass edit $1
# remarkable
remouseusb() {
if [[ "$#" == 0 ]]; then
remouse --address 10.11.99.1 --orientation left --monitor 0
elif [[ "$#" == 1 ]]; then
remouse --address 10.11.99.1 --orientation left --monitor "$1"
elif [[ "$#" == 2 ]]; then
remouse --address 10.11.99.1 --orientation "$1" --monitor "$2"
else
remouse --address 10.11.99.1 ${@}
fi
}
alias restreamcam='modprobe v4l2loopback && restream -w'
alias remapy='$XDG_DOCUMENTS_DIR/remarkable/remapy/launch.sh'
alias rcu='pushd && cd $XDG_DOCUMENTS_DIR/remarkable/rcu && make run && popd'
# python aliases
alias pip='python -m pip'
@ -282,13 +297,27 @@ jlbuildsysimage() {
alias lg='lazygit'
alias g='git'
alias gb='git branch'
alias gcm='git commit -S --message'
# gcm - git commmit alias
# gcm "Commit title" -m "more optional commit paragraphs"
# gcm (patch|minor|major) "Commit title" -m "This adds the standard commit sign off"
gcm() {
change_type=""
title="${1}"
shift
if [[ "${title}" =~ ^(patch|minor|major)$ ]]; then
change_type=("-m" "Change-type: ${title}")
title="${1}"
shift
fi
git commit -S -s -m "${title}" ${@} ${change_type}
}
alias gco='git checkout'
alias gf='git fetch'
alias gfc='git clone'
alias gfm='git pull'
alias gia='git add'
alias gp='git push'
alias gp='git push --force-with-lease'
alias gr='git rebase'
alias gS='git submodule'
alias gSa='git submodule add'

Loading…
Cancel
Save