Skip to content

Commit

Permalink
Added auto-presel script for BSPWM and .switchoutputs
Browse files Browse the repository at this point in the history
  • Loading branch information
notthebee committed Jan 4, 2019
1 parent 4b1fb98 commit a5e1b52
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bspwm/.config/bspwm/scripts/autopresel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/sh

fwid=$(bspc query -N -n focused.automatic)
wid=$1
class=$2
instance=$3
title=$(xtitle "$wid")
receptacle=$(bspc query -N -n ".leaf.!window.local" | awk NR==1)
#floats=$(bspc query -N -n .local.floating | wc -l)

if bspc query -N -n "@/.!automatic" > /dev/null ; then
echo "node=@/"
fi

if [ -n "$receptacle" ] > /dev/null ; then
echo "node=$receptacle"
elif [ -n "$fwid" ] ; then
wattr wh $fwid | {
read width height
if [ $width -gt $height ] ; then
echo "split_dir=east"
else
echo "split_dir=south"
fi
# echo "split_ratio=0.5"
}
fi
wmctrl -i -r "$wid" -b add,maximized_vert,maximized_horz &>/dev/null &
#window-placer $floats $wid
63 changes: 63 additions & 0 deletions scripts/.switchoutputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#! /bin/sh
# A script that switches between external and internal monitor
# It is launched when AC power is connected

export DISPLAY=:0
export XAUTHORITY=/home/notthebee/.Xauthority

# default monitor is LVDS1
MONITOR=LVDS1

# functions to switch from HDMI to VGA and vice versa
connect() {
echo "Switching to HDMI2"
xrandr --output LVDS1 --off --output HDMI2 --auto --dpi 96
/home/notthebee/.config/bspwm/bspwmrc
MONITOR=HDMI2
}
disconnect() {
echo "Switching to LVDS1"
xrandr --output HDMI2 --off --output LVDS1 --auto --dpi 96
/home/notthebee/.config/bspwm/bspwmrc
MONITOR=LVDS1
}


# functions to check if HDMI2 is connected and in use

active() {
[ $MONITOR = "HDMI2" ]
}

connected() {
! xrandr | grep "^HDMI2" | grep disconnected
}

# switch to LVDS1 if HDMI2 is disconnected
if ! connected
then
disconnect
fi

# switch between monitors, do it 15 times just to make sure.
# yes, i am serious. i've been trying to find a reliable way
# to do that for half a year, and nothing worked. apart from
# this. the absolute state of linux!

for i in {1..15}; do
if ! active && connected
then
connect
fi

if active && ! connected
then
disconnect
fi
sleep 0.5s
done


# set the xkb options. again. because they always reset
setxkbmap de,ru -option caps:escape -option grp:shifts_toggle
xset r rate 280 35

0 comments on commit a5e1b52

Please sign in to comment.