{"action":"created","issue":{"url":"https://api.github.com/repos/i3/i3/issues/2276","repository_url":"https://api.github.com/repos/i3/i3","labels_url":"https://api.github.com/repos/i3/i3/issues/2276/labels{/name}","comments_url":"https://api.github.com/repos/i3/i3/issues/2276/comments","events_url":"https://api.github.com/repos/i3/i3/issues/2276/events","html_url":"https://github.com/i3/i3/issues/2276","id":144616879,"number":2276,"title":"Crash at startup with multiple monitors.","user":{"login":"layus","id":632767,"avatar_url":"https://avatars.githubusercontent.com/u/632767?v=3","gravatar_id":"","url":"https://api.github.com/users/layus","html_url":"https://github.com/layus","followers_url":"https://api.github.com/users/layus/followers","following_url":"https://api.github.com/users/layus/following{/other_user}","gists_url":"https://api.github.com/users/layus/gists{/gist_id}","starred_url":"https://api.github.com/users/layus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/layus/subscriptions","organizations_url":"https://api.github.com/users/layus/orgs","repos_url":"https://api.github.com/users/layus/repos","events_url":"https://api.github.com/users/layus/events{/privacy}","received_events_url":"https://api.github.com/users/layus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/i3/i3/labels/4.12","name":"4.12","color":"009800"},{"url":"https://api.github.com/repos/i3/i3/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2016-03-30T14:50:21Z","updated_at":"2016-04-14T05:58:14Z","closed_at":null,"body":"Output of `i3 --moreversion 2>&- || i3 --version`:\r\n\r\nBinary i3 version:  4.12-17-g84c39a1 (2016-03-30, branch \"next\") © 2009 Michael Stapelberg and contributors\r\nRunning i3 version: 4.12-17-g84c39a1 (2016-03-30, branch \"next\") (pid 989)\r\nLoaded i3 config: /home/gmaudoux/.i3/config (Last modified: mer 30 mar 2016 16:16:31 CEST, 648 seconds ago)\r\n\r\nThe i3 binary you just called: /usr/bin/i3\r\nThe i3 binary you are running: i3\r\n\r\n\r\nURL to a logfile as per http://i3wm.org/docs/debugging.html: \r\n\r\nhttp://logs.i3wm.org/logs/5718016125829120.bz2\r\n\r\n**What I did:**\r\n\r\nBoot and exec `startx`.\r\n\r\n**What I saw:**\r\n\r\ni3 crashed, the small \"i3 crashed\" popup appearing, but with no text, just a black box.\r\n\r\n**What I expected instead:**\r\n\r\nHmm... i3 starting normally :-).\r\n\r\n**Extra info:**\r\n\r\nMy laptop is docked an plugged to an external monitor.\r\nTo manage docking and external monitors/projectors, i use autorandr, which is called automatically when drm events are noticed. This is done by my monitormonitors script.\r\n\r\nMy feeling is that i3 crashes because my postswitch script (see below) tries to send messages to i3 just when i3 is comping with the new monitor layout notified by xrandr.\r\n\r\nNote that autorandr is always called once to check the disposition at the begining:\r\n\r\n```\r\n#!/usr/bin/env python\r\n\r\nimport functools\r\nimport os.path\r\nimport pyudev\r\nimport subprocess\r\nfrom pprint import pprint\r\nfrom threading import Timer\r\n\r\n\r\ndef main():\r\n    BASE_PATH = os.path.abspath(os.path.dirname(__file__))\r\n    path = functools.partial(os.path.join, BASE_PATH)\r\n    call = lambda x, *args: subprocess.call([x] + list(args))\r\n    autorandr = lambda: call('/usr/bin/autorandr', '-c', '--default', 'presentation')\r\n\r\n    context = pyudev.Context()\r\n    monitor = pyudev.Monitor.from_netlink(context)\r\n    monitor.filter_by(subsystem='drm')\r\n    monitor.start()\r\n\r\n    timer = Timer(0.5, autorandr)\r\n    timer.start()\r\n\r\n    for device in iter(monitor.poll, None):\r\n        pprint(device)\r\n        pprint(device.attributes)\r\n        # I can add more logic here, to run only certain kinds of devices are plugged.\r\n\r\n        # This ensures that we fire only one call to autorandr for multiple events occuring within some interval.\r\n        timer.cancel()\r\n        timer.join()\r\n        timer = Timer(0.5, autorandr)\r\n        timer.start()\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n\r\nCalling autorandr modifies the displays layout, just like calling xrandr directly with predefined options.\r\nIt also calls a custom hook (called postswitch) to move the workspaces to the right displays/monitors:\r\n\r\n```\r\n#!/bin/bash -x\r\n\r\nconfig=\"$1\"\r\n\r\nprimary=\"eDP1\"\r\nsecondary=\"eDP1\"\r\n\r\ncase \"$config\" in\r\n    docked)\r\n        primary=\"DP1-1\"\r\n        secondary=\"eDP1\"\r\n        ;;\r\n    pr*)\r\n        secondary=\"DP1-3\"\r\n        ;;\r\nesac\r\n\r\nmove_workspace () {\r\n    workspace=\"$1\"\r\n    output=\"$2\"\r\n\r\n    sed -i \"/workspace $workspace output/ c \\\\workspace $workspace output $output\" $HOME/.i3/config\r\n\r\n    # is this needed ? yes !\r\n    i3-msg workspace \"$workspace\"\r\n    i3-msg move workspace to output \"$output\"\r\n    i3-msg workspace 1\r\n}\r\nexport -f move_workspace\r\n\r\n# worspace 0 is on secondary screen\r\nmove_workspace 0 \"$secondary\"\r\n# all other workspaces are on the primary display\r\n# this is just a 'for i in 1 2 ... 10' loop ;)\r\nparallel -kj1 move_workspace \"{}\" \"$primary\" ::: $(seq 1 10)\r\n\r\n# got to sane default after moving everything\r\ni3-msg workspace 1\r\n\r\n# Is reload sufficient to remap workspaces ? Yes\r\n# ! Neither reload nor restart do change the worspace location.\r\n# ! Reload does not create missing (i3)bars.\r\n#i3-msg reload\r\ni3-msg restart\r\n```\r\n\r\nHere is my .xinitrc, just in case:\r\n\r\n```\r\n#!/bin/sh\r\n#\r\n# ~/.xinitrc\r\n#\r\n# Executed by startx (run your window manager from here)\r\n\r\n# Make sure this is before the 'exec' command or it won't be sourced.\r\n[ -f /etc/xprofile ] && source /etc/xprofile\r\n[ -f ~/.xprofile ] && source ~/.xprofile\r\n\r\nif [ -d /etc/X11/xinit/xinitrc.d ]; then\r\n  for f in /etc/X11/xinit/xinitrc.d/*; do\r\n    [ -x \"$f\" ] && . \"$f\"\r\n  done\r\n  unset f\r\nfi\r\n\r\nxrdb -query > ~/xrdb_dump\r\n[ -f ~/.Xresources ] && xrdb -global ~/.Xresources\r\nif [ -d ~/.Xresources.d ]; then\r\n  for f in ~/.Xresources.d/*; do\r\n    [ -f \"$f\" ] && xrdb -global -merge \"$f\"\r\n  done\r\n  unset f\r\nfi\r\n\r\nxsetroot -solid '#fdf6e3'\r\n\r\n#/home/layus/bin/blackout\r\nsleep 1\r\nexec i3 -d all -V >> ~/.i3/i3log 2>&1\r\n```\r\n\r\nI tried with the current i3 version in ArchLinux, then tried a build from the \"next\" branch, same issue.\r\n\r\n\r\nAnother small annoyance: When typing \"r\" (restart), firefox still runs but no window are visible, no window is capured by the (re)loaded layout either."},"comment":{"url":"https://api.github.com/repos/i3/i3/issues/comments/209774491","html_url":"https://github.com/i3/i3/issues/2276#issuecomment-209774491","issue_url":"https://api.github.com/repos/i3/i3/issues/2276","id":209774491,"user":{"login":"Airblader","id":2392216,"avatar_url":"https://avatars.githubusercontent.com/u/2392216?v=3","gravatar_id":"","url":"https://api.github.com/users/Airblader","html_url":"https://github.com/Airblader","followers_url":"https://api.github.com/users/Airblader/followers","following_url":"https://api.github.com/users/Airblader/following{/other_user}","gists_url":"https://api.github.com/users/Airblader/gists{/gist_id}","starred_url":"https://api.github.com/users/Airblader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Airblader/subscriptions","organizations_url":"https://api.github.com/users/Airblader/orgs","repos_url":"https://api.github.com/users/Airblader/repos","events_url":"https://api.github.com/users/Airblader/events{/privacy}","received_events_url":"https://api.github.com/users/Airblader/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T05:58:14Z","updated_at":"2016-04-14T05:58:14Z","body":"I think we need to investigate this more instead. If I add that check to `con_focus`, a lot of tests start failing because, I assume, they expect it to set `focused`. This means a lot of tests set the focus on a weird container. We should fix this."}}