sync/skel/.i3/i3/run.sh

160 lines
4.7 KiB
Bash
Raw Normal View History

2017-10-10 17:24:36 -04:00
#!/usr/bin/env zsh
if [ "$1" = "lock" ];then
2015-07-22 16:28:39 -04:00
#!/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 [ "$1" = "pass" ];then
2015-09-30 19:01:42 -04:00
pass -c $(ls ~/.password-store/*/*|cut -b-37 --complement|rofi -dmenu|sed -e 's/\.gpg//')
fi
if [ "$1" = "screensaver" ];then
cat /tmp/noss||i3lock -di `shuf -n1 -e ~/.i3/wall/*`
fi
if [ "$1" = "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;
2016-02-05 00:18:49 -05:00
#feh --bg-scale "$(shuf -n1 -e ~/.i3/wallOM/*)"
2016-08-18 15:47:09 -04:00
#feh --bg-scale ~/.i3/image.png
2017-10-10 17:24:36 -04:00
feh --bg-scale "$(shuf -n1 <(realpath /home/stonewareslord/sync/wallpaper/"$(hostname)"/*))"
fi
if [ "$1" = "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
2015-06-23 20:26:25 -04:00
if [ "$1" = "boot" ];then
2016-08-01 18:36:24 -04:00
test -f ~/.screenlayout/default.sh && ~/.screenlayout/default.sh
2015-06-23 20:26:25 -04:00
/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
2016-08-18 15:47:09 -04:00
if [ "$(hostname)" = "MMLin" ]; then
xrandr --output HDMI1 --primary
2016-09-09 12:01:04 -04:00
xmodmap <(echo pointer = 3 2 1)
2016-08-18 15:47:09 -04:00
elif [ "$(hostname)" = "G2" ]; then
#TODO: Figure out what the display is called
xrandr --output eDP1 --primary
2016-09-09 12:01:04 -04:00
xmodmap <(echo pointer = 1 2 3)
2016-08-18 15:47:09 -04:00
fi
feh --bg-scale $(shuf -n1 <(realpath /home/stonewareslord/owncloud/wallpaper/$(hostname)))
2016-08-09 18:22:16 -04:00
xinput --set-prop 'Logitech USB Optical Mouse' 'Device Accel Constant Deceleration' 3
2016-08-01 18:36:24 -04:00
$(which ck-launch-session 2>/dev/null) $(which i3)
2015-06-23 20:26:25 -04:00
fi
2016-07-01 13:47:08 -04:00
if [ "$1" = "screen-lock" ];then
revert(){
xset dpms 0 0 0
}
trap revert SIGHUP SIGINT SIGTERM
xset +dpms dpms 5 5 5
slock
revert
fi
if [ "$1" = "paste" ]; then
2017-08-29 11:42:06 -04:00
sleep 2
DISPLAY=:0.0 xdotool type --clearmodifiers --file <(xsel)
fi
2017-04-30 13:14:50 -04:00
if [ "$1" = "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 "$1" "$2" >& /dev/null && RET=1
# check if nc has --transfer (-x)
elif nc -h |& grep -q -- --transfer; then
nc -w 1 -4 "$1" "$2" -x </dev/null >& /dev/null && RET=1
fi
echo $RET
fi
2016-09-20 13:23:08 -04:00
if [ "$1" = "ip" ]; then
shift
local RET=0
if [ "$(hostname)" = "MMLin" ]; then
if grep -q "$1" < <(ifconfig enp2s0f0); then
RET=1
fi
elif [ "$(hostname)" = "G2" ]; then
if grep -q "$1" < <(ifconfig enp1s0;ifconfig wlp2s0); then
RET=1
fi
2016-09-27 13:48:54 -04:00
elif [ "$(hostname)" = "SGen" ]; then
if grep -q "$1" < <(ifconfig enp0s25); then
RET=1
fi
2016-09-20 13:23:08 -04:00
fi
echo $RET
fi
2016-11-13 02:17:55 -05:00
if [ "$1" = "copy" ]; then
(printf '-chegg ';xsel | perl -pe 's/[^a-zA-Z ]//g;chomp()') | xsel && notify-send "Copied" || notify-send "Error"
fi
2017-01-24 15:54:05 -05:00
if [ "$1" = "screenshot" ]; then
2017-10-10 17:24:36 -04:00
\rm -f ~/last-photo/*(N)
2017-11-19 23:14:12 -05:00
sleep .2
2017-10-10 17:24:36 -04:00
#DISPLAY=:0.0 xfce4-screenshooter -r -s ~/last-photo
2018-03-15 10:42:18 -04:00
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}"
2017-11-19 23:14:12 -05:00
#DISPLAY=:0.0 scrot -s "$HOME/last-photo/$(date +'%Y-%m-%d_%T').png"
2017-10-10 17:24:36 -04:00
\cp ~/last-photo/* ~/Pictures
2017-01-24 15:54:05 -05:00
fi
2017-08-29 11:42:06 -04:00
if [ "$1" = "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 [ "$1" = "run" ]; then
2017-10-10 17:24:36 -04:00
PATH="$HOME/bin:/usr/games/bin:$PATH" rofi -show run
fi
if [ "$1" = "window" ]; then
rofi -show window
2017-08-29 11:42:06 -04:00
fi
2017-11-19 23:14:12 -05:00
if [ "$1" = "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