+local function move_tag_to_target_screen(tag)
+ tag.screen = get_target_screen_for_tag(tag)
+end
+
+local function move_tags_to_target_screens()
+ for _,tag in ipairs(root.tags()) do
+ move_tag_to_target_screen(tag)
+ end
+end
+
+tag.connect_signal("request::screen", function(t)
+ -- throw the tag onto any other screen, it'll get reassigned later when
+ -- a new profile has been processed.
+ for s in screen do
+ if s ~= t.screen then
+ t.screen = s
+ t.selected = false
+ break
+ end
+ end
+ naughty.notify({
+ title = "Screen removed",
+ text = "Salvaged tab " .. t.name,
+ })
+end)
+
+function handle_new_autorandr_profile(newprofile)
+ -- The main idea here is that autorandr invokes this via awesome-client
+ -- after switching to a new profile. Awesome will have already set up all
+ -- the screens long before this function is called. Therefore, we just do
+ -- the necessary modifications to the existing screens, and move tags
+ -- around.
+
+ if not newprofile then
+ error("Missing new profile name")
+ end
+
+ naughty.notify({
+ preset = naughty.config.presets.low,
+ title = "New autorandr profile",
+ text = "Reconfiguring for profile <b>" .. newprofile .. "</b>",
+ })
+
+ for s in screen do
+ s:set_profile(newprofile)
+ end
+ move_tags_to_target_screens()
+end
+
+local function initialise_to_autorandr_profile()
+ local profile
+ profile = nil
+
+ local function process_line(line)
+ if profile then return end
+ local match = string.match(line, "^([^%s]+) %(detected%)")
+ if match then
+ profile = match
+ end
+ end
+
+ local function output_done()
+ if not profile then
+ error("autorandr detected no profile")
+ profile = "awesome"
+ end
+ handle_new_autorandr_profile(profile)
+ end
+
+ local function handle_exit(reason, code)
+ if not (reason == "exit" and code == 0) then
+ error("autorandr error: " .. reason .. ": " .. tostring(code))
+ end
+ end
+
+ awful.spawn.with_line_callback('autorandr', {
+ stdout = process_line,
+ output_done = output_done,
+ exit = handle_exit
+ })
+end
+awesome.connect_signal("startup", initialise_to_autorandr_profile)
+-- }}}
+
+-- }}}
+
+-- {{{ Tags
+
+local default_tag = {
+ name = nil,
+ init = true,
+ layout = layouts.default,
+ fallback = true,
+ targets = "primary",
+}
+local default_tags = {}
+for i = 1, 9 do
+ default_tags[i] = {}
+ for k,v in pairs(default_tag) do
+ default_tags[i][k] = v
+ end
+ default_tags[i].name = tostring(i)
+end
+default_tags[1].selected = true
+
+default_tags = gears.table.join(default_tags, {
+ {
+ name = "irc",
+ init = true,
+ exclusive = true,
+ master_width_factor = 0.33,
+ layout = layouts.tiled,
+ selected = true,
+ exec_once = { terminal .. " -name irc -e env MOSH_TITLE_NOPREFIX=true mosh -4 -- irc-host tmux new -As irc irssi" },
+ instance = { "irc" },
+ targets = { "catalyst/eDP1", "mtvic/eDP1", "gauting/eDP1", "lehel/DisplayPort-2" },
+ },
+ {
+ name = "[m]",
+ init = true,
+ exclusive = true,
+ master_width_factor = 0.67,
+ layout = layouts.tiled,
+ selected = true,
+ exec_once = { "revolt" },
+ instance = { "Revolt" },
+ targets = { "catalyst/eDP1", "mtvic/eDP1", "gauting/eDP1", "lehel/DisplayPort-2" },
+ },
+ {
+ name = "dflt",
+ init = false,
+ fallback = true,
+ layout = layouts.floating,
+ volatile = true,
+ selected = true,
+ },
+ {
+ name = "cal",
+ init = true,
+ exclusive = true,
+ layout = layouts.default,
+ exec_once = { "thunderbird" },
+ class = { "thunderbird" },
+ targets = { "catalyst/DP2-1", "mtvic/eDP1", "gauting/eDP1", "lehel/DisplayPort-1" },
+ },
+ {
+ name = "chr",
+ init = true,
+ exclusive = true,
+ layout = layouts.default,
+ exec_once = { "chromium" },
+ class = { "Chromium" },
+ targets = { "catalyst/DP2-1", "mtvic/eDP1", "gauting/eDP1", "lehel/DisplayPort-1", "present/HDMI.*" },
+ },
+ {
+ name = "ffx",
+ init = true,
+ exclusive = true,
+ layout = layouts.default,
+ exec_once = { "firefox" },
+ class = { "Firefox" },
+ targets = { "catalyst/DP2-1", "mtvic/eDP1", "gauting/eDP1", "lehel/DisplayPort-1", "present/HDMI.*" },
+ },
+})
+
+if not tyrannical then
+
+for _,t in ipairs(default_tags) do
+ if t.init then
+ t.screen = t.screen or screen.primary
+ t.layout = t.layout or layouts.default
+ local newt = th.add_tag(t.name, t, false)
+ end
+end
+
+else -- {{{ tyrannical is loaded
+tyrannical.settings.default_layout = layouts.default
+tyrannical.settings.master_width_factor = 0.5
+tyrannical.settings.block_children_focus_stealing = true
+tyrannical.settings.group_children = true
+
+tyrannical.tags = default_tags
+
+tyrannical.properties.size_hints_honor = { URxvt = false }
+
+--XX---- Ignore the tag "exclusive" property for the following clients (matched by classes)
+--XX--tyrannical.properties.intrusive = {
+--XX-- "ksnapshot" , "pinentry" , "gtksu" , "kcalc" , "xcalc" ,
+--XX-- "feh" , "Gradient editor", "About KDE" , "Paste Special", "Background color" ,
+--XX-- "kcolorchooser" , "plasmoidviewer" , "Xephyr" , "kruler" , "plasmaengineexplorer",
+--XX--}
+--XX--
+--XX---- Ignore the tiled layout for the matching clients
+--XX--tyrannical.properties.floating = {
+--XX-- "MPlayer" , "pinentry" , "ksnapshot" , "pinentry" , "gtksu" ,
+--XX-- "xine" , "feh" , "kmix" , "kcalc" , "xcalc" ,
+--XX-- "yakuake" , "Select Color$" , "kruler" , "kcolorchooser", "Paste Special" ,
+--XX-- "New Form" , "Insert Picture" , "kcharselect", "mythfrontend" , "plasmoidviewer"
+--XX--}
+--XX--
+--XX---- Make the matching clients (by classes) on top of the default layout
+--XX--tyrannical.properties.ontop = {
+--XX-- "Xephyr" , "ksnapshot" , "kruler"
+--XX--}
+--XX--
+--XX---- Force the matching clients (by classes) to be centered on the screen on init
+--XX--tyrannical.properties.centered = {
+--XX-- "kcalc"
+--XX--}
+end -- }}}
+