forked from notthebee/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added auto-presel script for BSPWM and .switchoutputs
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |