fd0 / grobi Goto Github PK
View Code? Open in Web Editor NEWAutomatically configure monitors/outputs for Xorg via RANDR
License: BSD 2-Clause "Simplified" License
Automatically configure monitors/outputs for Xorg via RANDR
License: BSD 2-Clause "Simplified" License
When grobi runs in the background, it should detect config changes and reload.
Config should only become active once the new config's yaml was verified to be valid.
Hi,
I haven't been able to find it but is there a way to mirror a display or will there be support for --same-as xrandr feature ?
Where do I need to put the config ?
» grobi update
error reading config file: could not find config file
These displays are detected by grobi:
--- ~ » grobi show
LVDS-1 LGD-728-0
HDMI-1 SAM-2537-1515804490
I use this config:
- name: blah
outputs_connected: [LVDS-1, HDMI-1-SAM-2537-1515804490]
primary: HDMI-1-SAM-2537-1515804490
configure_row:
- LVDS-1
- HDMI-1-SAM-2537-1515804490
But grobi fails to update the displays:
--- ~ » grobi update
warning: output HDMI-1-SAM-2537-1515804490 not found; ignoring
I’m trying to use grobi to automatically run xrandr
whenever I re-plug my monitor, which is required sometimes (sigh) for my monitor to sync with my GPU.
While using dry-run mode, I got this sequence of commands which grobi would have run:
% grobi watch --dry-run
xrandr --output DP-0 --auto --output DP-4 --auto --right-of DP-0
# <unplug monitor cables>
xrandr --output DP-0 --off --output DP-4 --off
xrandr --output DP-0 --off --output DP-4 --off
# <replug monitor cables>
xrandr --output DP-0 --auto --output DP-4 --auto --right-of DP-0
The first and last command are what I want it to run, but I don’t want it to turn off outputs. Turning off the output results in i3 re-arranging workspaces, which I don’t want in this scenario (I’m removing all outputs).
I had a brief look around, but couldn’t find any option to stop grobi from disabling outputs. Did I miss anything? Is there some rationale behind this behavior, or could an option be added to not turn off outputs?
In case it’s relevant, my grobi.conf reads:
# vim:ft=yaml
rules:
- name: UP3218K
outputs_connected: [DP-0, DP-4]
configure_row:
- DP-0
- DP-4
atomic: true
Thanks,
It would be very helpful if grobi could react to resume events, e.g. when resuming from a different state (docked / undocked) as the laptop was suspended in.
Probably from systemd/dbus?
YAML is tedious to figure out the correct structure, switch the configuration file to use HCL
My current usecase for identifying specific mointors is the following. I attach my second monitor via my HDMI output. Grobi detects this correctly and configures it correctly.
Now I also have a TV, to which I connect my laptop frequently as well and with the same HDMI port.
For the TV however I want to have another configuration (for example clone the output to both monitors). But currently I do not see a way in grobi to distinguishing the two setups, as they are connected to the same HDMI port.
I dug around and found the EDID, which includes a serial number and thus should identify every monitor specifically.
xrandr can even report the EDID, when using the --verbose
or the --props
flag.
Implementationwise this could be straight forward, as the --props
flag only adds more information to the standard xrandr call, as you can see in the following diff of the calls xrandr --query
and xrandr --query --props
:
2a3,21
> EDID:
> 00ffffffffffff000daeb11400000000
> 0c190104951f117802ff359255529529
> 25505400000001010101010101010101
> 010101010101b43b804a71383440503c
> 680034ad10000018000000fe004e3134
> 304843452d4541410a20000000fe0043
> 4d4e0a202020202020202020000000fe
> 004e3134304843452d4541410a2000a2
> BACKLIGHT: 143
> range: (0, 852)
> Backlight: 143
> range: (0, 852)
> scaling mode: Full aspect
> supported: None, Full, Center, Full aspect
> Broadcast RGB: Automatic
> supported: Automatic, Full, Limited 16:235
> audio: auto
> supported: force-dvi, off, auto, on
18a38,41
> Broadcast RGB: Automatic
> supported: Automatic, Full, Limited 16:235
> audio: auto
> supported: force-dvi, off, auto, on
19a43,46
> Broadcast RGB: Automatic
> supported: Automatic, Full, Limited 16:235
> audio: auto
> supported: force-dvi, off, auto, on
20a48,53
> aspect ratio: Automatic
> supported: Automatic, 4:3, 16:9
> Broadcast RGB: Automatic
> supported: Automatic, Full, Limited 16:235
> audio: auto
> supported: force-dvi, off, auto, on
21a55,60
> aspect ratio: Automatic
> supported: Automatic, 4:3, 16:9
> Broadcast RGB: Automatic
> supported: Automatic, Full, Limited 16:235
> audio: auto
> supported: force-dvi, off, auto, on
I am interested in your feedback and if you are interested in the feature I could also try to implement it, but this might take some time, as this would be my first time coding in Go.
It would be nice to have a cmd like grobi save PROFILENAME
or sth like this that would take current xrandr settings and create a config profile for those. If no config file exist it should get created.
The cmd_version.go
file hard codes the version number as 0.5.2-dev
. Therefore using the version
command with grobi compiled from the v0.6.0
tag produces:
grobi 0.5.2-dev
compiled with go1.14.9 on linux
I'm not sure how golang programs normally deal with this. If you point me in the right direction I'm happy to open a PR.
I tried building grobi 0.6.0 with Go 1.15 but got:
./randr.go:224:19: conversion from uint16 to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
FAIL github.com/fd0/grobi [build failed]
This looks pretty nice on my quick look. I'd love to have --dpi
, --rotate
, --scale
and --pos
support also. I'll see if I can make some time to implement, but if you want to beat me to it by all means ;).
Now i had to use this hack:
- name: Dockhome
outputs_connected:
- eDP-1
- DP-2-1
- DP-2-8-LEN-25065*
configure_row:
- eDP-1
- DP-2-1@1920x1080 #hack since we cannot set hz in grobi
- DP-2-8
atomic: true
execute_after:
- "xrandr --output DP-2-1 --mode 2560x1440 --rate 60 --right-of eDP-1 --output DP-2-8 --right-of DP-2-1" #hack to set refreshrate
I have 2 suggestions.
1
Implement DP-2-1@1920x1080@60
and then we just change the SplitN to be 3 and take the last one as --rate.
2
Implement environment variables that is sent to execute_after. Then we can add for example GROBI_ROW_1=eDP-1 , GROBI_ROW_1=DP-2-1 , GROBI_ROW_3=DP-2-8
The execute_after could then look like this:
- "xrandr --output $GROBI_ROW_2 --mode 2560x1440 --rate 60 --right-of $GROBI_ROW_1 --output $GROBI_ROW_3 --right-of $GROBI_ROW_2"
Then we can always customize our xrandr in the execute_after. Which means stuff like i saw discussed in #8 like --pos can also be solved like this.
I can implement ether solution and make a PR!
Dez 06 08:24:40 NOTEBOOK023 sh[2189]: grobi: 08:24:40.868321 reading config from /home/inf/.config/grobi.conf
Dez 06 08:24:40 NOTEBOOK023 sh[2189]: grobi: 08:24:40.869037 grobi 0.5.1 (v0.5.1-19-gdaa886b), compiled with go1.12.7 on linux
Dez 06 08:24:40 NOTEBOOK023 sh[2189]: grobi: 08:24:40.869068 successfully subscribed to X RANDR change events
Dez 06 08:24:40 NOTEBOOK023 sh[2189]: unknown state "unknown"
$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 290mm x 170mm
1920x1080 59.93*+ 59.93
1680x1050 59.88
1400x1050 59.98
1600x900 60.00 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
DP1 disconnected (normal left inverted right x axis y axis)
DP1-1 unknown connection (normal left inverted right x axis y axis)
1368x768 59.88
1280x800 59.81
1280x720 59.86
1024x768 60.00
1024x576 59.90
960x540 59.63
800x600 60.32
640x480 59.94
DP1-2 unknown connection primary (normal left inverted right x axis y axis)
1368x768 59.88
1280x800 59.81
1280x720 59.86
1024x768 60.00
1024x576 59.90
960x540 59.63
800x600 60.32
640x480 59.94
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
cat ~/.config/grobi.conf
# vim:ft=yaml
rules:
- name: Display Extender
# grobi takes the list of all the
# outputs xrandr returns and verifies that HDMI2 and HDMI3 are connected, and
# DP2-2 is present (but may be disconnected).
outputs_connected: [eDP1, DP1-1, DP1-2]
outputs_present: [DP1-1, DP1-2]
# when this rule matches, HDMI2 and HDMI3 are activated in their default
# resolution and set besides each other in a typical dual-monitor
# configuration: left is HDMI2, right is HDMI3
configure_row:
# - eDP1
- DP1-1
- DP1-2
# atomic instructs grobi to only call xrandr once and configure all the
# outputs. This does not always work with all graphic cards.
atomic: false
# For the output HDMI3, the flag --primary will be added to the xrandr
# call, so that e.g. the tray icons are displayed on this monitor (requires
# the window manager to do this).
primary: DP1-2
# Additional commands can be specified per rule, in this case we make sure
# that xautolock is enabled and locks the screen after a while.
# execute_after:
# - python3 /usr/share/xfpanel-switch/xfpanel-switch/panelconfig.py load /home/inf/.local/share/xfpanel-switch/displaylink.tar.bz2
# This is a rule for mobile computing, i.e. outside of the docking station defined above.
- name: Mobile
# In order to match, the outputs HDMI2 and HDMI3 may be present, but must be disconnected.
outputs_disconnected:
- DP1-1
- DP1-2
# Here, only the internal LCD panel is activated.
configure_single: eDP1
# execute_after:
# - python3 /usr/share/xfpanel-switch/xfpanel-switch/panelconfig.py load /home/inf/.local/share/xfpanel-switch/laptop.tar.bz2
- name: Fallback
configure_single: eDP1
Currently the Go i3 library is used to listen to output change events via i3. This means that it is currently not possible to run grobi with another window manager. In addition, the i3 library does not survive a restart of i3.
@fd0 Are there any plans to tag a new versioned release in the near future? I would like to get an up-to-date version of grobi into https://github.com/NixOS/nixpkgs, but from my experience it is not as welcomed to reference a plain SHA instead of a tagged version.
i3 wm allows to specify that the icon tray should be displayed on primary screen with configuration of:
tray_output primary
grobi should have an option to define primary screen that executes something like:
$ xrandr --output $OUTPUT --primary
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.