Add example script to switch primary and secondary display applications
also don't run detect-second-display multiple times during a session.
This commit is contained in:
		
							
								
								
									
										974
									
								
								Manual.html
									
									
									
									
									
								
							
							
						
						
									
										974
									
								
								Manual.html
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										25
									
								
								Manual.org
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								Manual.org
									
									
									
									
									
								
							@@ -2950,6 +2950,14 @@ exit 0
 | 
				
			|||||||
    owner: '{{ vdr.user }}'
 | 
					    owner: '{{ vdr.user }}'
 | 
				
			||||||
    group: '{{ vdr.group }}'
 | 
					    group: '{{ vdr.group }}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: create switch-displays script
 | 
				
			||||||
 | 
					  template:
 | 
				
			||||||
 | 
					    src: templates/bin/switch-displays.j2
 | 
				
			||||||
 | 
					    dest: '{{ vdr.home }}/bin/switch-displays'
 | 
				
			||||||
 | 
					    mode: 0755
 | 
				
			||||||
 | 
					    owner: '{{ vdr.user }}'
 | 
				
			||||||
 | 
					    group: '{{ vdr.group }}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: create openbox-second.service for the session
 | 
					- name: create openbox-second.service for the session
 | 
				
			||||||
  template:
 | 
					  template:
 | 
				
			||||||
    src: templates/systemd/user/openbox-second.service.j2
 | 
					    src: templates/systemd/user/openbox-second.service.j2
 | 
				
			||||||
@@ -4763,11 +4771,28 @@ Description=Detect second DISPLAY using xrandr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[Service]
 | 
					[Service]
 | 
				
			||||||
Type=oneshot
 | 
					Type=oneshot
 | 
				
			||||||
 | 
					RemainAfterExit=yes
 | 
				
			||||||
ExecStart=%h/bin/detect-second-display
 | 
					ExecStart=%h/bin/detect-second-display
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Install]
 | 
					[Install]
 | 
				
			||||||
WantedBy=yavdr-desktop.target
 | 
					WantedBy=yavdr-desktop.target
 | 
				
			||||||
#+END_SRC
 | 
					#+END_SRC
 | 
				
			||||||
 | 
					***** switch-displays
 | 
				
			||||||
 | 
					:PROPERTIES:
 | 
				
			||||||
 | 
					:ID:       67d8bc4f-64c6-4433-98f7-d76430fb9f20
 | 
				
			||||||
 | 
					:END:
 | 
				
			||||||
 | 
					This script exchanges the primary and secondary screen. It needs access to the systemd user session.
 | 
				
			||||||
 | 
					#+BEGIN_SRC shell :tangle roles/yavdr-desktop/templates/bin/switch-displays.j2 :mkdirp yes :padline no
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					source <(systemctl --user show-environment)
 | 
				
			||||||
 | 
					[[ "$DISPLAY" =~ \.1$ ]] && DISPLAY="${DISPLAY%.1}.0" || DISPLAY="${DISPLAY%.0}.1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					frontend-dbus-send stop
 | 
				
			||||||
 | 
					systemctl --user stop osd2web
 | 
				
			||||||
 | 
					frontend-dbus-send setDisplay "$DISPLAY"
 | 
				
			||||||
 | 
					systemctl --user start osd2web
 | 
				
			||||||
 | 
					frontend-dbus-send start
 | 
				
			||||||
 | 
					#+END_SRC
 | 
				
			||||||
***** openbox-second.service
 | 
					***** openbox-second.service
 | 
				
			||||||
:PROPERTIES:
 | 
					:PROPERTIES:
 | 
				
			||||||
:ID:       4473c272-7b60-4159-b2a9-8198cff98770
 | 
					:ID:       4473c272-7b60-4159-b2a9-8198cff98770
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,6 +103,14 @@
 | 
				
			|||||||
    owner: '{{ vdr.user }}'
 | 
					    owner: '{{ vdr.user }}'
 | 
				
			||||||
    group: '{{ vdr.group }}'
 | 
					    group: '{{ vdr.group }}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: create switch-displays script
 | 
				
			||||||
 | 
					  template:
 | 
				
			||||||
 | 
					    src: templates/bin/switch-displays.j2
 | 
				
			||||||
 | 
					    dest: '{{ vdr.home }}/bin/switch-displays'
 | 
				
			||||||
 | 
					    mode: 0755
 | 
				
			||||||
 | 
					    owner: '{{ vdr.user }}'
 | 
				
			||||||
 | 
					    group: '{{ vdr.group }}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: create openbox-second.service for the session
 | 
					- name: create openbox-second.service for the session
 | 
				
			||||||
  template:
 | 
					  template:
 | 
				
			||||||
    src: templates/systemd/user/openbox-second.service.j2
 | 
					    src: templates/systemd/user/openbox-second.service.j2
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								roles/yavdr-desktop/templates/bin/switch-displays.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								roles/yavdr-desktop/templates/bin/switch-displays.j2
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					source <(systemctl --user show-environment)
 | 
				
			||||||
 | 
					[[ "$DISPLAY" =~ \.1$ ]] && DISPLAY="${DISPLAY%.1}.0" || DISPLAY="${DISPLAY%.0}.1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					frontend-dbus-send stop
 | 
				
			||||||
 | 
					systemctl --user stop osd2web
 | 
				
			||||||
 | 
					frontend-dbus-send setDisplay "$DISPLAY"
 | 
				
			||||||
 | 
					systemctl --user start osd2web
 | 
				
			||||||
 | 
					frontend-dbus-send start
 | 
				
			||||||
@@ -3,6 +3,7 @@ Description=Detect second DISPLAY using xrandr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[Service]
 | 
					[Service]
 | 
				
			||||||
Type=oneshot
 | 
					Type=oneshot
 | 
				
			||||||
 | 
					RemainAfterExit=yes
 | 
				
			||||||
ExecStart=%h/bin/detect-second-display
 | 
					ExecStart=%h/bin/detect-second-display
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Install]
 | 
					[Install]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user