You are not logged in.

#1 2019-08-28 07:59:43

karlospv94
Member
Registered: 2016-10-12
Posts: 101

[SOLVED] Disable laptop screen when switching activity

Hi!

I am using KDE Plasma with the following xrandr output:

Screen 0: minimum 320 x 200, current 4480 x 1440, maximum 8192 x 8192
eDP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     60.10*+  60.01    59.97    59.96    59.93  
   1680x1050     59.95    59.88  
   1400x1050     59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     60.02  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   700x450       59.96    59.88  
   640x480       60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   640x400       59.88    59.98  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32  
DP-1 connected primary 2560x1440+1920+0 (normal left inverted right x axis y axis) 600mm x 340mm
   3840x2160     60.00 +  30.00  
   2560x1440     59.95* 
   1920x1080     60.00    60.00    59.94  
   1600x900      60.00  
   1280x1024     60.02  
   1280x800      59.81  
   1152x864      59.97  
   1280x720      60.00    60.00    59.94  
   1024x768      60.00  
   800x600       60.32  
   720x480       60.00    59.94  
   640x480       60.00    59.94    59.94  
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)

What I want is to get the eDP-1 disconnected when moving to another KDE activity or Desktop, and restored when coming back to the main one. Is there any way to get this?
I have been reading about xrandr scripting but that point doesn't seem to be explained.

Thanks in advance!

Last edited by karlospv94 (2019-08-29 10:49:26)

Offline

#2 2019-08-29 10:49:11

karlospv94
Member
Registered: 2016-10-12
Posts: 101

Re: [SOLVED] Disable laptop screen when switching activity

For those who are interested in this I have finally arrived to a solution:

#!/bin/bash

service=org.kde.ActivityManager
interface=$service.Activities
path=/ActivityManager/Activities
signal=CurrentActivityChanged

dbus-monitor --profile "type=signal,path=$path,interface=$interface,member=$signal" | \
  while read -r type timestamp serial sender destination path interface member; do
  # dbus-monitor always has some noise output in the beginning, so filter it at the start of the event handler.
  [ "$member" == "$signal" ] || continue

  curact=$(qdbus $service "$path" "$interface".CurrentActivity)
  name="$(qdbus "$service" "$path" "$interface.ActivityName" "$curact")"

  echo "Switched to activity $name"

  case "$name" in
    "Por omisión")
      xrandr --output eDP-1 --auto --size 1920x1080 --pos 0x0 --output DP-1 --primary --size 1280x1024 --pos 1920x0
      ;;
    "Extendida")
      xrandr --output eDP-1 --off
      ;;
  esac
done

In this case, when I move to the activity with name "Extendida", the eDP-1 is disabled. Then, when returning to the activity with name "Por omisión" it is restored with the position and size I prefer.

This might be in a systemd service to be executed always, but that is out of scope.

Offline

Board footer

Powered by FluxBB