|
|
@ -5,7 +5,6 @@ |
|
|
|
# external commands: cat, cut, dmenu, grep, sed, xrandr |
|
|
|
# Released under GPLv2 |
|
|
|
# |
|
|
|
# TODO: add dpi support |
|
|
|
|
|
|
|
typeset XRANDR_TXT # readonly; stdout of running xrandr without any options |
|
|
|
typeset -A OUTPUT_CONFIGURED # key=connected output name |
|
|
@ -92,41 +91,6 @@ function main() { |
|
|
|
prompt='Select primary output:' |
|
|
|
output="$(menu_select "${prompt}" ${(k)=OUTPUT_CONFIGURED})" |
|
|
|
|
|
|
|
if [ "$(pidof x11vnc)" ]; then |
|
|
|
killvnc="$(printf "no\nyes" | dmenu -p "Would you like to kill existing vnc display?")" |
|
|
|
if [ "$killvnc" = "yes" ]; then |
|
|
|
xrandr --output HDMI2 --off |
|
|
|
killall -9 x11vnc |
|
|
|
vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect a remote display?")" |
|
|
|
fi |
|
|
|
else |
|
|
|
vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect a remote display?")" |
|
|
|
fi |
|
|
|
if [ "$vnc" = "yes" ]; then |
|
|
|
echo "1920x1080" | dmenu -p "Please enter resolution:" | read resolution |
|
|
|
[ "$resolution" ] || exit 1 |
|
|
|
printf "normal\nleft" | dmenu -p "Please enter rotation:" | read rotation |
|
|
|
[ "$rotation" ] || exit 1 |
|
|
|
xrandr --output HDMI2 --off |
|
|
|
h=$(echo "$resolution" | cut -d'x' -f1) |
|
|
|
w=$(echo "$resolution" | cut -d'x' -f2) |
|
|
|
modeline="$(gtf $h $w 60 | tail -n 2 | xargs | sed 's/Modeline [^ ]*//g'| xargs)" |
|
|
|
name="${h}x${w}_$$.00" |
|
|
|
wlan="$(ip -o -4 addr list wlan0 | awk '{print $4}' | cut -d/ -f1)" |
|
|
|
eth="$(ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)" |
|
|
|
bash -c "xrandr --newmode \"$name\" $modeline" |
|
|
|
if [ "$rotation" = "normal" ]; then |
|
|
|
clip="${h}x${w}+0+0" |
|
|
|
else |
|
|
|
clip="${w}x${h}+0+0" |
|
|
|
fi |
|
|
|
xrandr --addmode HDMI2 "$name" |
|
|
|
xrandr --output HDMI2 --rotation $rotation --mode $name --left-of $output && { x11vnc \ |
|
|
|
-repeat -clip $clip & } || notify-send -a "Display Manager" "An issue occured" |
|
|
|
pidof x11vnc && notify-send -t 60000 -a " Network info" "$(echo -e "wlan0: $wlan\neth0: $eth\nRunning on port 5900")" |
|
|
|
daily-update -f |
|
|
|
fi |
|
|
|
|
|
|
|
[ "$output" = "eDP1" ] && bail 1 |
|
|
|
|
|
|
|
position='--primary' |
|
|
@ -152,6 +116,22 @@ function main() { |
|
|
|
xrandr_cmd+=" --output ${output} ${position} ${rotation} ${mode}" |
|
|
|
done |
|
|
|
|
|
|
|
if [ "$(pidof x11vnc)" ]; then |
|
|
|
killvnc="$(printf "no\nyes" | dmenu -p "Would you like to kill existing vnc display?")" |
|
|
|
if [ "$killvnc" = "yes" ]; then |
|
|
|
xrandr --output HDMI2 --off |
|
|
|
killall -9 x11vnc |
|
|
|
vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect to your ipad?")" |
|
|
|
fi |
|
|
|
else |
|
|
|
vnc="$(printf "no\nyes" | dmenu -p "Would you like to connect to your ipad?")" |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$vnc" = "yes" ]; then |
|
|
|
$HOME/.local/bin/ipad_xrandr.sh |
|
|
|
pidof x11vnc && notify-send -t 60000 -a " Network info" "$(echo -e "wlan0: $wlan\neth0: $eth\nRunning on port 5900")" |
|
|
|
fi |
|
|
|
|
|
|
|
# forcibly '--off' disconnected outputs |
|
|
|
for output in ${DISCONNECTED_OUTPUTS}; do |
|
|
|
xrandr_cmd+=" --output ${output} --off" |
|
|
|