Here's the deal: when I login into my KDE environment, I want system to check if my large monitor is connected and to switch to this monitor if it's found. The laptop screen I want to turn OFF (the system heats up enough with only one screen used; besides, I couldn't find any real use for 2nd monitor, probably because of lack of imagination).
After playing a bit with systemd, I gave up and simply added a script to KDE's autostart.
Here's some information one need to get before you write such a script for your configuration:
1. Connnect your big monitor and then run `xrandr` command in console. You should get output like this:
TODO: put my output here
Notice the following:
- Names of your book and big screens' outputs. In my case they are "LVDS" and "VGA-0";
- Check if native resolution for your big monitor is in the list. If not, you should add it first, as explained here: https://wiki.archlinux.org/index.php/xrandr#Adding_undetected_resolutions Then follow these hints to save this mode persistently: https://wiki.ubuntu.com/X/Config/Resolution#Setting_xrandr_changes_persistently
2. Run the following command: `ls -1 /sys/class/drm/*/status`. The output will be something like this:
/sys/class/drm/card0-HDMI-A-1/status /sys/class/drm/card0-LVDS-1/status /sys/class/drm/card0-VGA-1/status
You should write down the file, which is appropriate to your big screen. It can't be "built" by knowing the output name from `xrandr`, as you can see. In my example, xrandr says "VGA-0", but here I get "VGA-1". You don't have to understand it, just accept.
3. Now, we're all good to write the script. I've put it into $HOME/bin/ directory, for example:
#!/bin/sh # Define some configuration first export BOOK_OUTPUT="LVDS" export BOOK_MODE-"1366x768" export BIG_BROTHER="VGA-0" export BROTHER_MODE="1920x1080" export BROTHER_STATUS_FILE="/sys/class/drm/card0-VGA-1/status" # These vars are required for the script to access user display export DISPLAY=:0 export XAUTHORITY=/home/$USER/.Xauthority [[ $(< $BROTHER_STATUS_FILE) == 'connected' ]] && xrandr --output $BIG_BROTHER --mode $BROTHER_MODE --output $BOOK_OUTPUT --off [[ $(< $BROTHER_STATUS_FILE) == 'disconnected' ]] && xrandr --output $BIG_BROTHER --off --output $BOOK_OUTPUT --mode $BOOK_MODE exit 0
4. Final step: go to KDE's System Settings :: Autostart and add Script file (chose yours) nad setup is to runt "On startup".
Комментариев нет:
Отправить комментарий