This utility is for users using i3wm on their laptops who frequently jump between multiple (multi-)monitor setups.
For example single display output when you are on road, triple-monitor setup at work and two-monitor setup at home.
i3-workscreen executable provided by this package should be triggered by udev rule which will listen for specific events caused by plugging/unplugging display output cable(s) (eg.: HDMI). The utility will then enable configured display outputs and reassign existing workspaces based on your json configuration.
An example of the udev rule is provided in the root of the git repository and should be EDITED by the user and copied to /etc/udev/rules.d/98-monitor-hotplug.rules on you system.
You may also need to execute i3-workscreen in your .i3/config as the udev event is emitted way too early on a system startup before the X.org server is running.
exec --no-startup-id "i3-workscreen"/home/user> pip install git+https://github.com/fogine/i3-workscreen.git
# or
/home/user> pip install i3-workscreeni3-msgxrandr(xlib)python 3.5logger(write messages into the system log)
/home/user> i3-workscreen -h
usage: i3workscreen.py [-h] [--toggle]
Required configuration file is fetched from:
`$HOME/.config/i3-workscreen/config.json`
optional arguments:
-h, --help show this help message and exit
--toggle Toggles between mirrored & extended display modeThe bellow configuration example shows setup of maximum of three monitors. In this case eDP-1 is my laptop screen and HDMI-1 & DP-1 are external monitors.
Four scenarios may happen with the configuration:
eDP-1connected,HDMI-1&DP-1disconnectedIn this case all workspaces are assigned to the single screen
eDP-1connected,HDMI-1connected,DP-1disconnectedIn this case workspaces 1-5 belong to
eDP-1and workspaces 6-0 belong toHDMI-1eDP-1connected,HDMI-1disconnected,DP-1connectedIn this case workspaces 1-5 belong to
DP-1and workspaces 6-0 belong toeDP-1eDP-1connected,HDMI-1connected,DP-1connectedIn this case workspaces 1-5 belong to
DP-1and workspaces 6-0 belong toHDMI-1.eDP-1was stolen all workspaces by higher priority outputs and becausedisableEmptyOutputs=true,eDP-1display output will be disabled. if the option was set tofalse, the output would be enabled and you could interact with the connected monitor andi3would assign to it firstemptyworkspace (workspace without any windows in it)
{
"disableEmptyOutputs": true,
"outputs": [
{
"name": "eDP-1",
"workspaces": [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ]
},
{
"name": "HDMI-1",
"xrandr": ["--above", "eDP-1"],
"workspaces": [ "6", "7", "8", "9", "0" ]
},
{
"name": "DP-1",
"workspaces": ["1", "2", "3", "4", "5"]
}
]
}Output names of monitors connected through a dock or daisy-chained via DisplayPort MST (eg.: DP-7) are allocated dynamically and may change after the monitors or the computer are power-cycled. Such monitors can be matched by their EDID identification instead of the output name. An entry with edid matches the connected monitor whose model and/or serial equal the given values, regardless of the output it is connected to. Each entry matches one monitor at most, so two identical monitors without a serial are assigned to two entries in the configuration order.
List the model and serial of connected monitors with:
/home/user> python -c 'from i3workscreen.i3workscreen import d, get_outputs; [print(o["name"], o["edid"]) for o in get_outputs(d) if o["connected"]]'An xrandr argument of the form {reference} is replaced with the current output name of the connected monitor whose output name, EDID model or EDID serial equals reference. When no connected monitor matches, the argument is dropped together with the option preceding it.
{
"disableEmptyOutputs": true,
"outputs": [
{
"name": "eDP-1",
"workspaces": [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ]
},
{
"edid": { "model": "DELL P2423DE", "serial": "CNSVNR3" },
"xrandr": ["--right-of", "eDP-1"],
"workspaces": ["1", "2", "3", "4", "5"]
},
{
"edid": { "serial": "4Y9NL23" },
"xrandr": ["--right-of", "{CNSVNR3}"],
"workspaces": ["6", "7", "8", "9", "0"]
}
]
}
评论