Hi all,
Apologies if this question has been asked before (I'm fairly sure it
has from trawling the archives) but I can't seem to get a fix that
works for me.
The problem:
I have a multiscreen(nvidia - proprietry) setup (laptop and big screen).
If I launch some gtk (or qt apps) instead of starting on the current
mouse screen, they will *sometimes* appear on the 'main' screen. Things
that are tagged to appear on a certain screen/tag work fine.
In my awful.hooks.manage.register hook I have tried putting in a call to
awful.placement.under_mouse(c) right before it does the tag mapping,
but this doesn't seem to work, although it does seem to work about half
the time, and with some applications. It's rather frustrating!
I have a theory that awesome is losing track of where the mouse pointer
is and then defaults to spawning the window at 0,0. But thats just a
'rectal pluck' so to speak.
I've noticed it with the following applications, but I'm sure it it not
restricted to these, rather is a sample of what I use day to day:
firefox
gvim
grip
k3b
songbird
Also it doesn't seem to make a difference whether I spawn from a menu,
awesome.spawn or from a terminal.
Apps that always behave seem to be ones not tied to a toolkit (no
surprises eh) such as xterm.
I'm using awesome-git PKGBUILDS from AUR (on Arch Linux obv) as well as
wicked-git. All are 64-bit. I have also tried the current awesome 3.3-2
builds and experience the same behaviour.
I have a multi-screen setup with an Nvidia mobile card using the
proprietry drivers.
from lspci:
01:00.0 VGA compatible controller: nVidia Corporation GeForce 8400M GS
(rev a1)
from pacman -Qs nvidia:
local/nvidia 185.18.14-1
NVIDIA drivers for kernel26.
local/nvidia-utils 185.18.14-1
NVIDIA drivers utilities and libraries.
Attached is my rc.lua in case it's of interest.
Appreciate any help I can get,
Thanks,
Dave Burley
-- Standard awesome library
require("awful")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
require("wicked")
require("tabulous")
cardid = 0
channel = "Master"
function volume (mode, widget)
if mode == "update" then
local fd = io.popen("amixer -c " .. cardid .. " -- sget " .. channel)
local status = fd:read("*all")
fd:close()
local volume = string.match(status, "(%d?%d?%d)%%")
volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
if string.find(status, "on", 1, true) then
volume = volume .. "%"
else
volume = volume .. "M"
end
widget.text = volume
elseif mode == "up" then
awful.util.spawn("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%+")
volume("update", widget)
elseif mode == "down" then
awful.util.spawn("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%-")
volume("update", widget)
else
awful.util.spawn("amixer -c " .. cardid .. " sset " .. channel .. " toggle")
volume("update", widget)
end
end
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
-- The default is a dark theme
theme_path = "/usr/share/awesome/themes/default/theme.lua"
-- Uncommment this for a lighter theme
--theme_path = "/usr/share/awesome/themes/sky/theme"
-- Actually load theme
beautiful.init(theme_path)
-- This is used later as the default terminal and editor to run.
--terminal = "urxvt"
terminal = "xterm"
browser = "firefox"
--email = "thunderbird"
email = "claws-mail"
pidgin = "pidgin"
nmapp = "nm-applet"
editor = os.getenv("EDITOR") or "nano"
editor_cmd = terminal .. " -e " .. editor
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
--table.insert(globalkeys, key({ modkey, "Control"}, "g", function () awful.util.spawn("gvim rocksoft/git_local") end))
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.tile,
awful.layout.suit.fair,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair.horizontal,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier,
awful.layout.suit.floating
}
-- Table of clients that should be set floating. The index may be either
-- the application class or instance. The instance is useful when running
-- a console app in a terminal like (Music on Console)
-- xterm -name mocp -e mocp
floatapps =
{
["MPlayer"] = true,
["pinentry"] = true,
["gimp"] = true,
["mocp"] = true,
["Thunderbird-bin"] = true,
["meld"] = true,
["claws-mail"] = true,
["nvidia-settings"] = true,
["main.py"] = true,
["xcalc"] = true,
["Songbird"] = true,
["kdbg"] = true,
["kdbgio"] = true
-- ["navigator"] = true,
-- ["Gran Paradiso"] = true
}
-- Applications to be moved to a pre-defined tag by class or instance.
-- Use the screen and tags indices.
apptags =
{
["claws-mail"] = { screen = 1, tag = 1 },
["pidgin"] = { screen = 1, tag = 2 },
-- This was annoying!
-- ["Gran Paradiso"] = { screen = 1, tag = 3},
["deluge"] = { screen = 1, tag = 5}
}
-- Define if we want to use titlebar on all applications.
use_titlebar = false
---- Define tags table.
-- see mytags.lua
tags = {}
require("mytags")
-- {{{ Wibox
-- Create a textbox widget
mytextbox = widget({ type = "textbox", align = "right" })
-- Set the default text in textbox
mytextbox.text = ""
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "terminal", terminal },
{ "firefox", browser },
{ "claws", email },
{ "pidgin", pidgin },
{ "nm-applet", nmapp },
{ "songbird", "songbird"},
{ "eclipse", "eclipse" },
{ "grip", "grip" },
{ "deluge", "deluge" }
}
})
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
menu = mymainmenu })
-- Create a systray
mysystray = widget({ type = "systray", align = "right" })
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag),
awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
)
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
client.focus = c
c:raise()
end),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ width=250 })
end
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end)
)
tb_volume = widget({ type = "textbox", name = "tb_volume", align = "right" })
tb_volume:buttons({
button({ }, 4, function () volume("up", tb_volume) end),
button({ }, 5, function () volume("down", tb_volume) end),
button({ }, 1, function () volume("mute", tb_volume) end)
})
volume("update", tb_volume)
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({ align = "left" })
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(function(c)
return awful.widget.tasklist.label.currenttags(c, s)
end, mytasklist.buttons)
-- Create the wibox
mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
-- Add widgets to the wibox - order matters
mywibox[s].widgets = { mylauncher,
mytaglist[s],
mytasklist[s],
mypromptbox[s],
mytextbox,
tb_volume,
mylayoutbox[s],
s == 1 and mysystray or nil }
mywibox[s].screen = s
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
awful.key({ modkey, "Control" }, "Left", awful.tag.viewprev ),
awful.key({ modkey, "Control" }, "Right", awful.tag.viewnext ),
-- Client focus keys
awful.key({ modkey, }, "w",
function ()
mymainmenu:show(true)
end),
awful.key({ modkey, }, "Down",
function ()
awful.client.focus.bydirection("down")
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "Up",
function ()
awful.client.focus.bydirection("up")
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "Left",
function ()
awful.client.focus.bydirection("left")
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "Right",
function ()
awful.client.focus.bydirection("right")
if client.focus then client.focus:raise() end
end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
-- TAB hotkey bindings
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.byidx(1)
if client.focus then
client.focus:raise()
end
end),
-- rotate clients and focus master...
awful.key({ modkey, "Control" }, "Tab",
function ()
local allclients = awful.client.visible(client.focus.screen)
for i,v in ipairs(allclients) do
if allclients[i+1] then
allclients[i+1]:swap(v)
end
end
awful.client.focus.byidx(-1)
end),
-- Standard program
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit),
-- Application spawn hotkeys
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "f", function () awful.util.spawn(browser) end),
awful.key({ modkey, "Control" }, "e", function () awful.util.spawn(email) end),
awful.key({ modkey, "Control" }, "p", function () awful.util.spawn(pidgin) end),
awful.key({ modkey, }, "F11", function () awful.util.spawn("sudo s2ram") end),
awful.key({ modkey, }, "F12", function () awful.util.spawn("xlock") end),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Prompt
awful.key({ modkey }, "F1",
function ()
mypromptbox[mouse.screen]:run()
end),
awful.key({ modkey }, "F4",
function ()
awful.prompt.run({ prompt = "Run Lua code: " },
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end),
-- Keyboard multimedia keys
awful.key({ }, "XF86AudioRaiseVolume",
function ()
volume("up", tb_volume)
end),
awful.key({ }, "XF86AudioLowerVolume",
function ()
volume("down", tb_volume)
end),
awful.key({ }, "XF86AudioMute",
function ()
volume("mute", tb_volume)
end)
)
-- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
awful.key({ modkey }, "t", awful.client.togglemarked ),
awful.key({ modkey, }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
tags[screen][i].selected = not tags[screen][i].selected
end
end),
awful.key({ modkey, "Shift" }, i,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Control", "Shift" }, i,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Shift" }, "F" .. i,
function ()
local screen = mouse.screen
if tags[screen][i] then
for k, c in pairs(awful.client.getmarked()) do
awful.client.movetotag(tags[screen][i], c)
end
end
end))
end
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Hooks
-- Hook function to execute when focusing a client.
awful.hooks.focus.register(function (c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_focus
end
end)
-- Hook function to execute when unfocusing a client.
awful.hooks.unfocus.register(function (c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_normal
end
end)
-- Hook function to execute when marking a client
awful.hooks.marked.register(function (c)
c.border_color = beautiful.border_marked
end)
-- Hook function to execute when unmarking a client.
awful.hooks.unmarked.register(function (c)
c.border_color = beautiful.border_focus
end)
-- Hook function to execute when the mouse enters a client.
awful.hooks.mouse_enter.register(function (c)
-- Sloppy focus, but disabled for magnifier layout
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
-- Hook function to execute when a new client appears.
awful.hooks.manage.register(function (c, startup)
-- If we are not managing this application at startup,
-- move it to the screen where the mouse is.
-- We only do it for filtered windows (i.e. no dock, etc).
if not startup and awful.client.focus.filter(c) then
c.screen = mouse.screen
end
if use_titlebar then
-- Add a titlebar
awful.titlebar.add(c, { modkey = modkey })
end
-- Add mouse bindings
c:buttons(awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize)
))
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c.border_width = beautiful.border_width
c.border_color = beautiful.border_normal
-- Check if the application should be floating.
local cls = c.class
local inst = c.instance
if floatapps[cls] then
awful.client.floating.set(c, floatapps[cls])
elseif floatapps[inst] then
awful.client.floating.set(c, floatapps[inst])
end
-- Place under mouse for now. If we tag it to a screen it will be moved.
awful.placement.under_mouse(c)
awful.placement.no_offscreen(c)
awful.placement.no_overlap(c)
-- Check application->screen/tag mappings.
local target
if apptags[cls] then
target = apptags[cls]
elseif apptags[inst] then
target = apptags[inst]
end
if target then
c.screen = target.screen
awful.client.movetotag(tags[target.screen][target.tag], c)
end
-- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
client.focus = c
-- Set key bindings
c:keys(clientkeys)
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Honor size hints: if you want to drop the gaps between windows, set this to false.
c.size_hints_honor = false
end)
-- Hook function to execute when arranging the screen.
-- (tag switch, new client, etc)
awful.hooks.arrange.register(function (screen)
local layout = awful.layout.getname(awful.layout.get(screen))
if layout and beautiful["layout_" ..layout] then
mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
else
mylayoutbox[screen].image = nil
end
-- Give focus to the latest client in history if no window has focus
-- or if the current window is a desktop or a dock one.
if not client.focus then
local c = awful.client.focus.history.get(screen, 0)
if c then client.focus = c end
end
end)
-- Hook called every minute
awful.hooks.timer.register(60, function ()
mytextbox.text = os.date(" %a %b %d, %H:%M ")
end)
-- 10 Second timer.
awful.hooks.timer.register(10, function () volume("update", tb_volume) end)
-- Autostart
function autostart(dir)
if not dir then
do return nil end
end
local fd = io.popen("ls -1 -F " .. dir)
if not fd then
do return nil end
end
for file in fd:lines() do
local c= string.sub(file,-1) -- last char
if c=='*' then -- executables
executable = string.sub( file, 1,-2 )
print("Awesome Autostart: Executing: " .. executable)
os.execute(dir .. "/" .. executable .. " &") -- launch in bg
elseif c=='@' then -- symbolic links
print("Awesome Autostart: Not handling symbolic links: " .. file)
else
print ("Awesome Autostart: Skipping file " .. file .. " not executable.")
end
end
io.close(fd)
end
autostart_dir = os.getenv("HOME") .. "/.config/autostart"
autostart(autostart_dir)