Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- kquitapp plasma-desktop
- xtvga=$(xrandr | grep -c "VGA-0 connected")
- xthdmi=$(xrandr | grep -c "HDMI-0 connected")
- xtmon=$(($xtvga + $xthdmi))
- restartArg=1 #If 1, plasma-desktop is up for a restart.
- doBackup=0
- isTest=0
- lastused="single"
- function checkExistence {
- if [ ! -d "/home/tamius-han/.kde/share/config/last" ]; then
- mkdir "/home/tamius-han/.kde/share/config/last"
- mkdir "/home/tamius-han/.kde/share/config/last/single"
- fi
- for f in "left-of" "right-of" "above" "below" "same-as" "off" "single" ; do
- if [ ! -d "/home/tamius-han/.kde/share/config/configs/$f" ]; then
- mkdir /home/tamius-han/.kde/share/config/configs/$f
- cp /home/tamius-han/.kde/share/config/* /home/tamius-han/.kde/share/config/configs/$f
- fi
- done
- }
- function backup {
- lastused=single
- for f in "left-of" "right-of" "above" "below" "same-as" "off" "single" ; do
- if [ -d "/home/tamius-han/.kde/share/config/last/$f" ]; then
- lastused=$f
- fi
- done
- rm -rf "/home/tamius-han/.kde/share/config/last/$lastused"
- mkdir "/home/tamius-han/.kde/share/config/last/$1"
- cp /home/tamius-han/.kde/share/config/* /home/tamius-han/.kde/share/config/configs/$lastused
- }
- function recfg-multi { #Reconfigures monitors and restarts that shit.
- checkExistence
- backup $1 #$1 tells backup which config we're importing so it gets backed up properly next time we run this script.
- # $1 — tells location of the secondary monitor (left, right, upwards, downwards of LVDS, duplicate of LVDS, etc.)
- # $2 — tells if it's primary monitor (not yet implemented)
- # $3 — tells if it's mirror over x (not even close ti implementing)
- if [ $xtvga == 1 ] ; then
- loldefined="VGA-0"
- echo "We detected secondary output on VGA-0."
- fi
- if [ $xthdmi == 1 ] ; then
- loldefined="HDMI-0"]
- echo "We detected secondary output on HDMI-0."
- fi
- xrandr --output LVDS --auto
- xrandr --output $loldefined --$1 LVDS --auto
- # if [ $2 == "primary" ] ; then
- xrandr --output $loldefined --primary
- # fi
- echo "New display has been placed $1 the previous one. Resolution has been set on prefered value."
- rm /home/tamius-han/.kde/share/config/* #Deleting old configs
- cp /home/tamius-han/.kde/share/config/configs/$1/* /home/tamius-han/.kde/share/config
- echo "Copying = finito"
- }
- echo "-----------------------------------"
- echo "Number of external monitors: $xtmon"
- echo "VGA-0: $xtvga"
- echo "HDMI-0: $xthdmi"
- echo "restartArg: $restartArg"
- echo "doBackup: $doBackup"
- echo "whoami: tamius-han"
- echo "-----------------------------------"
- if [ $xtmon == 1 ] ; then
- #default values
- echo "xtmon = 1"
- monlayout="left-of"
- for f in "left-of" "right-of" "above" "below" "same-as" "off" "last" "single" ; do
- if [ "$1" = "$f" ] ; then
- monlayout=$f
- fi
- done
- #if [ "$monlayout" = "$(ls /home/tamius-han/.kde/share/config/last/)" ] ; then
- #exit 0
- #fi
- recfg-multi $monlayout
- fi
- if [ $xtmon == 0 ] ; then
- #if [ "single" = "$(ls /home/tamius-han/.kde/share/config/last/)" ] ; then
- #exit 0
- #fi
- backup single
- echo "No external monitors are connected."
- xrandr --output VGA-0 --off
- xrandr --output HDMI-0 --off
- xrandr --output LVDS --auto
- echo "All displays have been removed."
- cp /home/tamius-han/.kde/share/config/configs/single/* /home/tamius-han/.kde/share/config
- echo "Single monitor configuration pulled from the storage."
- fi
- # echo "Chown to all!"
- # chown -R tamius-han /home/tamius-han/.kde/share/
- kstart plasma-desktop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement