aboutsummaryrefslogtreecommitdiffstats
path: root/xorg-xrandr
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xxorg-xrandr/setres/__main__.py320
-rwxr-xr-xxorg-xrandr/setres/__main__.py.gpp4
2 files changed, 2 insertions, 322 deletions
diff --git a/xorg-xrandr/setres/__main__.py b/xorg-xrandr/setres/__main__.py
deleted file mode 100755
index 94a2db1..0000000
--- a/xorg-xrandr/setres/__main__.py
+++ /dev/null
@@ -1,320 +0,0 @@
-#!/usr/bin/env python3
-
-import sys, os, pwd
-from subprocess import Popen, PIPE
-
-from get import *
-from set import *
-
-args = sys.argv[1:]
-home = os.environ['HOME'] if 'HOME' in os.environ else pwd.getpwuid(os.getuid()).pw_dir
-session_ = os.environ['SESSION_'] if 'SESSION_' in os.environ else ''
-hostname = os.uname().nodename.lower()
-
-t = lambda lopt, sopt : any(arg in args for arg in (lopt, '-' + lopt, '--' + lopt, sopt, '-' + sopt))
-
-mirror = t('mirror', 'm')
-swap = t('swap', 's')
-tv = t('tv', 't')
-wide = t('wide', 'w')
-crt = t('crt', 'c')
-large = t('large', 'l')
-single = t('single', '1')
-pretend = t('pretend', 'P')
-
-[screen] = get_setup()
-ok = False
-
-if pretend:
- def apply_setup(display):
- print(repr(display.to_xrandr()))
- return True
-
-phonies = []
-
-
-
-### Configurations
-
-if hostname == 'zenith':
- prime = screen['DisplayPort-1' if not swap else 'DisplayPort-1']
- sec = screen['DisplayPort-0' if not swap else 'DisplayPort-0']
- embed = None
-
- prime_alt = None
- sec_alt = None
-
- prime.want_mode = '1920x1200'
- sec.want_mode = '1920x1200'
-
- sec_position = 'left'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-else:
- print('%s: no configurations found for this machine (%s)' % (sys.argv[0], hostname),
- file = sys.stderr)
- sys.exit(1)
-
-if prime is not None and not prime.connected and prime_alt is not None:
- prime, prime_alt = prime_alt, prime
-if sec is not None and not sec.connected and sec_alt is not None:
- sec, sec_alt = sec_alt, sec
-
-
-if large:
- prime.want_mode = '1792x1344'
- sec.want_mode = '1792x1344'
-
-if crt:
- prime.want_mode = '800x600'
- sec.want_mode = '800x600'
-
-if wide:
- prime.want_mode = '1920x1080'
- sec.want_mode = '1920x1080'
-
-if tv:
- sec.want_mode = '1920x1080'
-
-
-if prime is not None:
- prime.want_rate = prime.best_rate(prime.want_mode)
-if sec is not None:
- sec.want_rate = sec.best_rate(sec.want_mode)
-if embed is not None:
- embed.want_rate = embed.best_rate(embed.want_mode)
-
-
-
-
-if '+prime' in args:
- prime.connected = True
-if '+sec' in args:
- sec.connected = True
-if '+embed' in args:
- embed.connected = True
-
-if '-prime' in args:
- prime.connected = False
-if '-sec' in args:
- sec.connected = False
-if '-embed' in args:
- embed.connected = False
-
-
-
-
-### Apply
-
-if prime is not None and prime.connected and sec is not None and sec.connected and not single:
- display = Display()
- ok = True
-
- output = Output(prime.name)
- display.outputs.append(output)
- output.mode = prime.want_mode
- output.rate = prime.want_rate
- output.primary = True
- output.relpos = None
- output.relto = None
-
- output = Output(sec.name)
- display.outputs.append(output)
- output.mode = sec.want_mode
- output.rate = sec.want_rate
- output.primary = False
- output.relpos = (sec_position + '-of') if not mirror else 'same-as'
- output.relto = prime.name
-
- if embed is not None:
- output = Output(embed.name)
- display.outputs.append(output)
- if embed.want_mode == prime.want_mode:
- output.mode = embed.want_mode
- output.rate = embed.want_rate
- output.primary = False
- output.off = False
- output.relpos = 'same-as'
- output.relto = prime.name
- else:
- output.off = True
-
-
-elif prime is not None and prime.connected:
- display = Display()
- ok = True
-
- output = Output(prime.name)
- display.outputs.append(output)
- output.mode = prime.want_mode
- output.rate = prime.want_rate
- output.primary = True
-
- if sec is not None:
- output = Output(sec.name)
- display.outputs.append(output)
- output.off = True
-
- if embed is not None:
- output = Output(embed.name)
- display.outputs.append(output)
- if embed.want_mode == prime.want_mode:
- output.mode = embed.want_mode
- output.rate = embed.want_rate
- output.primary = False
- output.off = False
- output.relpos = 'same-as'
- output.relto = prime.name
- else:
- output.off = True
-
-
-elif sec is not None and sec.connected:
- display = Display()
- ok = True
-
- output = Output(sec.name)
- display.outputs.append(output)
- output.mode = sec.want_mode
- output.rate = sec.want_rate
- output.primary = True
-
- if prime is not None:
- output = Output(prime.name)
- display.outputs.append(output)
- output.off = True
-
- if embed is not None:
- output = Output(embed.name)
- display.outputs.append(output)
- if embed.want_mode == sec.want_mode:
- output.mode = embed.want_mode
- output.rate = embed.want_rate
- output.primary = False
- output.off = False
- output.relpos = 'same-as'
- output.relto = sec.name
- else:
- output.off = True
-
-
-elif embed is None or not embed.connected:
- print('%s: don\'t know how to configure' % sys.argv[0], file = sys.stderr)
-
-
-else:
- display = Display()
- ok = True
-
- output = Output(embed.name)
- display.outputs.append(output)
- output.mode = embed.want_mode
- output.rate = embed.want_rate
- output.primary = True
-
- if prime is not None:
- output = Output(prime.name)
- display.outputs.append(output)
- output.off = True
-
- if sec is not None:
- output = Output(sec.name)
- display.outputs.append(output)
- output.off = True
-
-
-if ok:
- if prime_alt is not None:
- output = Output(prime_alt.name)
- display.outputs.append(output)
- output.off = True
-
- if sec_alt is not None:
- output = Output(sec_alt.name)
- display.outputs.append(output)
- output.off = True
-
- for phony in phonies:
- output = Output(phony.name)
- display.outputs.append(output)
- output.off = True
-
- ok = apply_setup(display)
-
-
-
-### Epilogue
-
-if not ok:
- sys.exit(1)
-if pretend:
- sys.exit(0)
-
-reschargs = []
-for output in (prime, sec):
- if output is not None:
- output = screen[output.name]
- reschargs.extend(output.size)
- reschargs.extend(output.position)
-[screen] = get_setup()
-prime = screen[True]
-if prime.position[0] > 0:
- print(prime.position[0], flush = True)
-
-file = '%s/.config/resolution-changed' % home
-if os.path.exists(file):
- try:
- os.execlp(file, file, *reschargs)
- except:
- pass
-
-for file in ('%s/.config/background.%s' % (home, session_), '%s/.config/background' % home):
- if os.path.exists(file):
- try:
- os.execlp('xwallpaper', 'xwallpaper', '--zoom', file)
- except:
- pass
diff --git a/xorg-xrandr/setres/__main__.py.gpp b/xorg-xrandr/setres/__main__.py.gpp
index d34b85c..f5200c8 100755
--- a/xorg-xrandr/setres/__main__.py.gpp
+++ b/xorg-xrandr/setres/__main__.py.gpp
@@ -50,12 +50,12 @@ if hostname == 'zenith':
sec_position = 'left'
%%>hostname="$(hostname | tr '[A-Z]' '[a-z]')"
-%%>file="${HOME}/.dotfiles/xorg-xrandr/setres/${hostname}"
+%%>file="${HOME}/.dotfiles/private/setres/${hostname}"
%%>if test -r "${file}"; then
elif hostname == '%%{hostname}':
connectors = {con.edid: con.name for con in screen.connectors if con.connected and con.edid and con.name}
-%%>cat -- "${file}"
+%%>sed 's/^[[:space:]]*\([^[:space:]]\)/ \1/' < "${file}"
primes = [(home_prime, '1920x1200'),
(work_prime, '1920x1080')]