From 3dc615964042b77bf5c0da07c5ff97e3bca569b0 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sun, 15 Mar 2020 12:05:01 -0400 Subject: [PATCH] Many fixes --- i3/.Xresources | 3 +- i3/.config/i3/config | 4 +- i3/.config/i3/run.sh | 336 +++++++++++++++++++++---------------------- 3 files changed, 165 insertions(+), 178 deletions(-) diff --git a/i3/.Xresources b/i3/.Xresources index 59d26b4..f1148b9 100644 --- a/i3/.Xresources +++ b/i3/.Xresources @@ -1,4 +1,5 @@ !URxvt.boldFont: -misc-fixed-medium-r-semicondensed--13-100-100-100-c-60-iso8859-1 +URxvt.font: xft:Less Perfect DOS VGA !URxvt.font: -*-*-*-*-*-*-*-*-*-*-*-*-*-* !URxvt.font: xft:Misc Fixed:size=14 !URxvt.boldFont: -*-*-*-*-*-*-*-*-*-*-*-*-*-* @@ -10,7 +11,7 @@ !URxvt.font: xft:Gohu GohuFont:size=12 !URxvt.font: xft:Misc Termsynu:size=13 !URxvt.font: xft:Unifont:size=13 -URxvt.font: xft:Monospace:size=11 +!URxvt.font: xft:Monospace:size=11 !URxvt.font: xft:FixedsysTTF Semi-Bold:size=11 !URxvt.faceName: -*-*-*-*-*-*-10-*-*-*-*-*-*-* !URxvt.font: xft:Fixed:style=SemiCondensed:size=16 diff --git a/i3/.config/i3/config b/i3/.config/i3/config index eb486b5..697a641 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -26,7 +26,7 @@ bindsym $mod+d exec "~/.config/i3/run.sh run" #bindsym $mod+shift+p exec "rofi-pass --last-used" # Misc shortcuts bindsym --release Num_Lock exec "xdotool key --clearmodifiers Shift+Insert;numlockx on" -bindsym Print exec "~/.config/i3/run.sh screenshot" +bindsym $mod+p exec "~/.config/i3/run.sh screenshot" # Split in vertical orientation bindsym $mod+v split h # Split in horizontal orientation @@ -230,4 +230,6 @@ exec --no-startup-id /bin/zsh -c 'pidof syncthing||screen -dmS syncthing ~/bin/s #exec --no-startup-id "~/bin/indicator-kdeconnect" # riot exec --no-startup-id riot-web --hidden +# setxkbmap +exec --no-startup-id setxkbmap -option caps:swapescape # vim: ts=2:sw=2:et diff --git a/i3/.config/i3/run.sh b/i3/.config/i3/run.sh index 0fec73c..a493fdf 100755 --- a/i3/.config/i3/run.sh +++ b/i3/.config/i3/run.sh @@ -1,179 +1,163 @@ #!/usr/bin/env bash ARG="$1" shift -if [ "$ARG" = "move" ]; then - shift - eval "$(xdotool getwindowfocus getwindowgeometry | grep Geometry: | perl -pe 's/^\s*Geometry: /WinH=/;s/x/\nWinW=/g')" - eval "$(xdotool getwindowfocus getwindowgeometry | grep Position: | perl -pe 's/^\s*Position: /WinY=/;s/,/\nWinX=/g;s/\s\(.+//')" - eval "$(xrandr | grep -w connected | perl -pe 's/.+?(\d+x\d+)\+\d+\+\d+.*/\1/g;s/^/MonH=/;s/x/\nMonW=/;' | head -n2)" - if [ "$ARG" = "top" ]; then - echo $((WinY)) - xdotool getwindowfocus windowmove $((WinY - 1)) 0 - elif [ "$ARG" = "right" ]; then - xdotool getwindowfocus windowmove $((MonH - WinH)) $((WinX - 1)) - elif [ "$ARG" = "left" ]; then - xdotool getwindowfocus windowmove 0 $((WinX - 1)) - elif [ "$ARG" = "bottom" ]; then - xdotool getwindowfocus windowmove $((WinY - 1)) $((MonW - WinW)) - fi -elif [ "$ARG" = "lock" ];then - #!/bin/bash - - declare -i ID - ID=`xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'` - declare -i STATE - STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'` - if [ $STATE -eq 1 ];then - xinput disable $ID - echo "Touchpad disabled." - else - xinput enable $ID - echo "Touchpad enabled." - fi -fi -if [ "$ARG" = "pass" ];then - pass -c $(ls ~/.password-store/*/*|cut -b-37 --complement|rofi -dmenu|sed -e 's/\.gpg//') -fi -if [ "$ARG" = "screensaver" ];then - cat /tmp/noss||i3lock -di `shuf -n1 -e ~/.i3/wall/*` -fi -if [ "$ARG" = "wall" ];then - #if [[ -d ~/.i3/wallOM ]];then feh --bg-scale "`shuf -n1 -e ~/.i3/wallOM/*`";else feh --bg-scale "`shuf -n1 -e ~/.i3/wall/*`";fi; - #feh --bg-scale "$(shuf -n1 -e ~/.i3/wallOM/*)" - #feh --bg-scale ~/.i3/image.png - feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/sync/wallpaper/"$(hostname)"/*))" -fi -if [ "$ARG" = "swap" ];then - python << EOF -import i3 -swap = [output for output in i3.get_outputs() if output['active']] -if len(swap) == 2: - for output in swap: - i3.workspace(output['current_workspace']) - i3.command('move', 'workspace to output right') -EOF -fi -if [ "$ARG" = "boot" ];then - test -f ~/.screenlayout/default.sh && ~/.screenlayout/default.sh - /usr/bin/xset -b - /usr/bin/xset +fp /usr/share/fonts/X11/misc - /usr/bin/xset +fp /usr/share/fonts/X11/Type1 - /usr/bin/xset +fp built-ins - /usr/bin/xset s off - /usr/bin/xset -dpms - # This will segfault and ruin your day - #/usr/bin/urxvtd -q -f -o - #if [ "$(hostname)" = "MMLin" ]; then - # xrandr --output HDMI1 --primary - # xmodmap <(echo pointer = 3 2 1) - #elif [ "$(hostname)" = "G2" ]; then - # #TODO: Figure out what the display is called - # xrandr --output eDP1 --primary - # xmodmap <(echo pointer = 1 2 3) - #fi - #feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/owncloud/wallpaper/$(hostname)))" - #xinput --set-prop 'Logitech USB Optical Mouse' 'Device Accel Constant Deceleration' 3 - if command -v ck-launch-session >/dev/null; then - ck-launch-session i3 - else - i3 - fi -fi -if [ "$ARG" = "screen-lock" ];then - revert(){ - xset dpms 0 0 0 - } - trap revert SIGHUP SIGINT SIGTERM - xset +dpms dpms 5 5 5 - slock - revert -fi -if [ "$ARG" = "paste" ]; then - sleep 2 - DISPLAY=:0.0 xdotool type --clearmodifiers --file <(xsel) -fi -if [ "$ARG" = "ping" ]; then - shift - # Return code - local RET=0 - # nc has some intense divergence. netcat6 has no -z, but netcat has no -x - # -w3: 3 second timeout - # -4 : ipv4 only - # check if nc has -z - if nc -h |& grep -q -- -z; then - nc -w 1 -z4 "$ARG" "$1" >& /dev/null && RET=1 - # check if nc has --transfer (-x) - elif nc -h |& grep -q -- --transfer; then - nc -w 1 -4 "$ARG" "$1" -x & /dev/null && RET=1 - fi - echo $RET -fi -if [ "$ARG" = "ip" ]; then - shift - local RET=0 - if [ "$(hostname)" = "MMLin" ]; then - if grep -q "$ARG" < <(ifconfig enp2s0f0); then - RET=1 - fi - elif [ "$(hostname)" = "G2" ]; then - if grep -q "$ARG" < <(ifconfig enp1s0;ifconfig wlp2s0); then - RET=1 - fi - elif [ "$(hostname)" = "SGen" ]; then - if grep -q "$ARG" < <(ifconfig enp0s25); then - RET=1 - fi - fi - echo $RET -fi -if [ "$ARG" = "copy" ]; then - (printf '-chegg ';xsel | perl -pe 's/[^a-zA-Z ]//g;chomp()') | xsel && notify-send "Copied" || notify-send "Error" -fi -if [ "$ARG" = "screenshot" ]; then - #\rm -f ~/last-photo/*(N) - #DISPLAY=:0.0 xfce4-screenshooter -r -s ~/last-photo - local FNAME="$HOME/last-photo/$(date +'%Y-%m-%d_%T').png" - DISPLAY=:0.0 import "${FNAME}" - DISPLAY=:0.0 xclip -selection clipboard -t image/png -i "${FNAME}" - #DISPLAY=:0.0 scrot -s "$HOME/last-photo/$(date +'%Y-%m-%d_%T').png" - \cp ~/last-photo/* ~/Pictures -fi -if [ "$ARG" = "shutdownprompt" ]; then - RESP=$(printf 'Sleep\nNMRestart\nShutdown\nRestart\nLogout\n' | rofi -i -dmenu 2>/dev/null) - if [[ ! -z "$RESP" ]]; then - case "$RESP" in - NMRestart) nmcli radio wifi off;sleep 1;nmcli radio wifi on;; - Restart) - sudo /sbin/shutdown -r now - ;; - Shutdown) - sudo /sbin/poweroff - ;; - Logout) - i3-msg exit - ;; - Sleep) - amixer set Master 0% mute - slock&until echo mem|sudo tee /sys/power/state>/dev/null;do sleep 1;done - sleep 4 - nmcli radio wifi off - sleep 3 - nmcli radio wifi on - ;; - esac - fi -fi -if [ "$ARG" = "run" ]; then - PATH="$HOME/bin:/usr/games/bin:$PATH" rofi -show run -fi -if [ "$ARG" = "window" ]; then - rofi -show window -fi -if [ "$ARG" = "clip" ]; then - # Get the rofi-selected index of what to paste - local INDEX="$(gpaste-client --oneline | colrm 80 | rofi -dmenu | perl -pe 's/:.*//')" - # If they made a selection, select it - if [[ ! -z "$INDEX" ]]; then - gpaste-client select "$INDEX" - fi -fi +case "${ARG}" in + move) + eval "$(xdotool getwindowfocus getwindowgeometry | grep Geometry: | perl -pe 's/^\s*Geometry: /WinH=/;s/x/\nWinW=/g')" + eval "$(xdotool getwindowfocus getwindowgeometry | grep Position: | perl -pe 's/^\s*Position: /WinY=/;s/,/\nWinX=/g;s/\s\(.+//')" + eval "$(xrandr | grep -w connected | perl -pe 's/.+?(\d+x\d+)\+\d+\+\d+.*/\1/g;s/^/MonH=/;s/x/\nMonW=/;' | head -n2)" + if [[ "$ARG" = "top" ]]; then + echo $((WinY)) + xdotool getwindowfocus windowmove $((WinY - 1)) 0 + elif [[ "$ARG" = "right" ]]; then + xdotool getwindowfocus windowmove $((MonH - WinH)) $((WinX - 1)) + elif [[ "$ARG" = "left" ]]; then + xdotool getwindowfocus windowmove 0 $((WinX - 1)) + elif [[ "$ARG" = "bottom" ]]; then + xdotool getwindowfocus windowmove $((WinY - 1)) $((MonW - WinW)) + fi + ;; + lock) + declare -i ID + ID=`xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'` + declare -i STATE + STATE=`xinput list-props "${ID}"|grep 'Device Enabled'|awk '{print $4}'` + if [[ $STATE -eq 1 ]];then + xinput disable "${ID}" + echo "Touchpad disabled." + else + xinput enable "${ID}" + echo "Touchpad enabled." + fi + ;; + pass) + pass -c "$(ls ~/.password-store/*/*|cut -b-37 --complement|rofi -dmenu|sed -e 's/\.gpg//')" + ;; + screensaver) + cat /tmp/noss||i3lock -di `shuf -n1 -e ~/.i3/wall/*` + ;; + wall) + #if [[ -d ~/.i3/wallOM ]];then feh --bg-scale "`shuf -n1 -e ~/.i3/wallOM/*`";else feh --bg-scale "`shuf -n1 -e ~/.i3/wall/*`";fi; + #feh --bg-scale "$(shuf -n1 -e ~/.i3/wallOM/*)" + #feh --bg-scale ~/.i3/image.png + feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/sync/wallpaper/"$(hostname)"/*))" + ;; + swap) + python <<-EOF + import i3 + swap = [output for output in i3.get_outputs() if output['active']] + if len(swap) == 2: + for output in swap: + i3.workspace(output['current_workspace']) + i3.command('move', 'workspace to output right') + EOF + ;; + boot) + test -f ~/.screenlayout/default.sh && ~/.screenlayout/default.sh + /usr/bin/xset -b + /usr/bin/xset +fp /usr/share/fonts/X11/misc + /usr/bin/xset +fp /usr/share/fonts/X11/Type1 + /usr/bin/xset +fp built-ins + /usr/bin/xset s off + /usr/bin/xset -dpms + # This will segfault and ruin your day + #/usr/bin/urxvtd -q -f -o + #if [[ "$(hostname)" = "MMLin" ]]; then + # xrandr --output HDMI1 --primary + # xmodmap <(echo pointer = 3 2 1) + #elif [[ "$(hostname)" = "G2" ]]; then + # #TODO: Figure out what the display is called + # xrandr --output eDP1 --primary + # xmodmap <(echo pointer = 1 2 3) + #fi + #feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/owncloud/wallpaper/$(hostname)))" + #xinput --set-prop 'Logitech USB Optical Mouse' 'Device Accel Constant Deceleration' 3 + if command -v ck-launch-session >/dev/null; then + ck-launch-session i3 + else + i3 + fi + ;; + screen-lock) + revert(){ + xset dpms 0 0 0 + } + trap revert SIGHUP SIGINT SIGTERM + xset +dpms dpms 5 5 5 + slock + revert + ;; + paste) + sleep 2 + DISPLAY=:0.0 xdotool type --clearmodifiers --file <(xsel) + ;; + ping) + # Return code + RET=0 + # nc has some intense divergence. netcat6 has no -z, but netcat has no -x + # -w3: 3 second timeout + # -4 : ipv4 only + # check if nc has -z + if nc -h |& grep -q -- -z; then + nc -w 1 -z4 "$ARG" "$1" >& /dev/null && RET=1 + # check if nc has --transfer (-x) + elif nc -h |& grep -q -- --transfer; then + nc -w 1 -4 "$ARG" "$1" -x & /dev/null && RET=1 + fi + echo $RET + ;; + screenshot) + #\rm -f ~/last-photo/*(N) + find ~/last-photo/ -type f -delete + #DISPLAY=:0.0 xfce4-screenshooter -r -s ~/last-photo + FNAME="$HOME/last-photo/$(date +'%Y-%m-%d_%T').png" + DISPLAY=:0.0 import "${FNAME}" + DISPLAY=:0.0 xclip -selection clipboard -t image/png -i "${FNAME}" + #DISPLAY=:0.0 scrot -s "$HOME/last-photo/$(date +'%Y-%m-%d_%T').png" + \cp ~/last-photo/* ~/Pictures + ;; + shutdownprompt) + RESP=$(printf 'Sleep\nNMRestart\nShutdown\nRestart\nLogout\n' | rofi -i -dmenu 2>/dev/null) + if [[ ! -z "$RESP" ]]; then + case "$RESP" in + NMRestart) + nmcli radio wifi off;sleep 1;nmcli radio wifi on + ;; + Restart) + sudo /sbin/shutdown -r now + ;; + Shutdown) + sudo /sbin/poweroff + ;; + Logout) + i3-msg exit + ;; + Sleep) + amixer set Master 0% mute + slock & + until sudo tee /sys/power/state <<<"mem" >/dev/null; do + sleep 1 + done + sleep 4 + nmcli radio wifi off + sleep 3 + nmcli radio wifi on + ;; + esac + fi + ;; + run) + PATH="$HOME/bin:/usr/games/bin:$PATH" rofi -show run + ;; + window) + rofi -show window + ;; + clip) + # Get the rofi-selected index of what to paste + INDEX="$(gpaste-client --oneline | colrm 80 | rofi -dmenu | perl -pe 's/:.*//')" + # If they made a selection, select it + if [[ ! -z "$INDEX" ]]; then + gpaste-client select "$INDEX" + fi + ;; +esac