-------------- rc.lua using shifty and vicious --------------
-- wriites the beginning of rc.lua to stdout or log
print("Entered rc.lua: " .. os.time())
----------------------Loading libraries----------------------
-- Standard awesome library
require("awful")
-- Your clients will not have focus at tag switching without this:
require("awful.autofocus")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- shifty - dynamic tagging library
require("shifty")
--Widget library
--Important! After Lua 5.1 you need to use this format to load vicious:
vicious = require("vicious")
--require("wicked")
--bashets are not compatible with my awesome...
--require("bashets")
local scratch = require("scratch")
--------------------------- Modkey --------------------------
-- Set the modkey to be the Windows key.
modkey = "Mod4"
--------------------------- Themes --------------------------
beautiful.init(".config/awesome/themes/cuh/theme.lua")
--------------- Naughty notification properties -------------
naughty.config.default_preset.timeout = 5
naughty.config.default_preset.screen = 1
naughty.config.default_preset.position = "top_right"
naughty.config.default_preset.margin = 10
--naughty.config.default_preset.height = 50
--naughty.config.default_preset.width = 100
naughty.config.default_preset.gap = 1
naughty.config.default_preset.ontop = true
naughty.config.default_preset.icon_size = 16
naughty.config.default_preset.fg = beautiful.fg_focus
naughty.config.default_preset.bg = beautiful.bg_normal
naughty.config.presets.normal.border_color = beautiful.fg_focus
naughty.config.default_preset.border_width = 2
naughty.config.default_preset.hover_timeout = nil
--------------------- Layout definitions --------------------
-- Layouts I use, order matters.
layouts =
{
awful.layout.suit.tile,
-- awful.layout.suit.tile.left,
-- awful.layout.suit.tile.bottom,
-- awful.layout.suit.tile.top,
awful.layout.suit.fair,
-- awful.layout.suit.fair.horizontal,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier,
awful.layout.suit.floating
}
---------------------- Tags and rules -----------------------
-- Shifty: default properties of tags
shifty.config.defaults = {
layout = awful.layout.suit.tile.bottom,
layout = awful.layout.suit.tile,
mwfact = 0.55,
ncol = 1,
exclusive = true,
floatBars = true,
guess_name = true,
guess_position = true,
screen = 1,
}
-- Shifty: configured tags
shifty.config.tags = {
log = {
layout = awful.layout.suit.fair,
exclusive = true,
position = 0,
screen = 2,
},
www = {
layout = awful.layout.suit.magnifier,
exclusive = false,
position = 1,
screen = 1,
slave = true,
},
mail = {
layout = awful.layout.suit.max,
exclusive = false,
position = 2,
screen = 1,
},
IM = {
layout = awful.layout.suit.fair,
exclusive = false,
position = 3,
screen = 1,
slave = true
},
term = {
layout = awful.layout.suit.tile,
position = 4,
screen = 1,
},
win = {
layout = awful.layout.suit.fair,
position = 5,
screen = 1,
},
draw = {
layout = awful.layout.suit.floating,
position = 6,
screen = 1,
},
open = {
layout = awful.layout.suit.magnifier,
exclusive = false,
position = 7,
screen = 1,
},
pdf = {
layout = awful.layout.suit.magnifier,
exclusive = false,
position = 8,
screen = 1,
},
}
-- Shifty: application matching rules
-- order matters, early rules will be applied first
-- more on this: http://awesome.naquadah.org/wiki/Shifty
shifty.config.apps = {
{
match = {
"Navigator",
"Firefox",
"Chromium",
},
tag = "www",
},
{
match = {
"Thunderbird",
"Mail",
},
tag = "mail",
float = true
},
{
match = {
"Mozilla Thunderbird",
},
float = false,
},
{
match = { --chat windows always get focus
"Chat",
"Pidgin",
"Skype",
},
nofocus = false,
tag = "IM"
},
{
match = { --pidgin buddy list and skype contact list goes to IM tag
"buddy_list",
"cuh7b5", --my skype name goes here to match Skype contact windows
"(Beta)",
},
tag = "IM",
float = false,
nofocus = true,
},
{
match = {
"VirtualBox",
},
tag = "win",
border_width = 0, --my virtual Windows looks better without border and taskbar
skip_taskbar = true,
},
{
match = {
"gimp",
"Pinta",
"Picasa",
},
tag = "draw",
},
{
match = {
"term",
},
tag = "term",
honorsizehints = false --remove gaps between terminals
},
{
match = {
"xfe",
"Xfe",
"filezilla",
"Filezilla",
"sxiv",
"archiv",
},
tag = "open",
},
{
match = {
"messages.log",
"Xorg.0.log",
"xsession output",
"^top$",
},
tag = "log",
titlebar = true,
urgent = true
},
{
match = {
"zathura",
"evince",
},
tag = "pdf",
},
-- Drag and resize windows with mouse
{
match = {""},
buttons = awful.util.table.join(
awful.button({}, 1, function (c) client.focus = c; c:raise() end),
awful.button({modkey}, 1, function(c)
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({modkey}, 3, awful.mouse.client.resize)
)
},
}
-------------------------- Topbar -------------------------
-- My vicious ststusbar widget
-- /dev/shm/scripts/status is my status shell script
statwidget = widget({
type = 'textbox',
name = 'statwidget'
})
function run_script()
local filedescriptor = io.popen("/dev/shm/scripts/status")
local value = filedescriptor:read()
filedescriptor:close()
return {value}
end
vicious.register(statwidget, run_script, '$1', 10)
-- Bashet widget
--statwidget = wibox.widget.textbox()
--bashets.register("/dev/shm/scripts/status", {widget = statwidget, update_time = 10, external = true, format = ' $1'})
-- Create a textclock widget
--mytextclock = awful.widget.textclock({ align = "right" })
-- Create a systray
mysystray = widget({type = "systray", align = "right"})
-- Create a wibox for each screen and add it
topbar = {}
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))
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
-- Create an imagebox widget which will contains an icon indicating which
-- layout we're using. We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
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.new(s,
awful.widget.taglist.label.all,
mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist.new(function(c)
return awful.widget.tasklist.label.currenttags(c, s)
end,
mytasklist.buttons)
-- Create the wibox
topbar[s] = awful.wibox({position = "top", screen = s})
-- Add widgets to the topbar - order matters
topbar[s].widgets = {
{
mytaglist[s],
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s],
s == 1 and mysystray or nil,
statwidget,
-- mytextclock,
mytasklist[s],
layout = awful.widget.layout.horizontal.rightleft
}
end
------------------ Shifty initialisation --------------------
shifty.taglist = mytaglist
shifty.init()
----------------------- Key bindings ------------------------
-- Mouse bindings
root.buttons({
awful.button({}, 5, awful.tag.viewprev)
})
-- Global keybindings
globalkeys = awful.util.table.join(
-- Tags
awful.key({modkey,}, "Up", awful.tag.viewprev), --go to previous tag
awful.key({modkey,}, "Down", awful.tag.viewnext), --go to next tag
awful.key({modkey}, "Right", --raise next client within tag
function()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.key({modkey}, "Tab", --raise next client within tag
function()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({modkey}, "Left", --raise prev. client within tag
function()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "Tab", function () awful.screen.focus_relative(1) end), --go to next screen
awful.key({modkey,}, "u", awful.client.urgent.jumpto), --go to urgent client
awful.key({modkey, "Control"}, "space", function() awful.layout.inc(layouts, 1) end), --change layout
-- Shifty: keybindings for dynamic tagging
awful.key({modkey, "Control"}, "x", shifty.del), -- delete an empty tag
awful.key({modkey, }, "n", shifty.add), -- create a new tag
awful.key({modkey, "Control"}, "n", shifty.rename), -- rename a tag
awful.key({modkey, "Control"}, "Up", shifty.send_prev), -- client to prev tag
awful.key({modkey, "Control"}, "Down", shifty.send_next), -- client to next tag
-- Standard program bindings
awful.key({modkey, "Control"}, "q", awesome.quit),
awful.key({ modkey,}, "Return", function () awful.util.spawn("uxterm -maximized -bg black -fg green -b 3 -fn -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1", false) end),
awful.key({ modkey, "Control"}, "Return", function () awful.util.spawn("uxterm -maximized -bg black -fg green -b 3 -fn -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1 -e ranger", false) end),
awful.key({ modkey,}, "f", function () run_or_raise("firefox", { class = "Firefox" }) end),
awful.key({ modkey,}, "c", function () run_or_raise("chromium", { class = "Chromium" }) end),
awful.key({ modkey,}, "t", function () run_or_raise("thunderbird", { class = "Thunderbird" }) end),
awful.key({ modkey,}, "p", function () run_or_raise("pidgin", { class = "Pidgin" }) end),
awful.key({ modkey,}, "s", function () run_or_raise("/home/cuh/bin/skypestart", { name = "Skype" }) end),
awful.key({ modkey,}, "o", function () awful.util.spawn("xfe", false) end),
awful.key({ modkey,}, "g", function () awful.util.spawn("gimp", false) end),
awful.key({ modkey,}, "w", function () awful.util.spawn("/home/cuh/bin/winstart", false) end),
awful.key({ modkey,}, "l", function () awful.util.spawn("/home/cuh/bin/logstart", false) end),
awful.key({ }, "Print", function () awful.util.spawn_with_shell("scrot -e 'mv $f ~/Desktop/ 2>/dev/null && xfe ~/Desktop/ & sleep 1 && sxiv ~/Desktop/$f'") end),
-- Binding for calculator in scratchpad
awful.key({ modkey }, "q", function () scratch.drop("qalculate","top","center",250,300) end),
-- VGA hotplugging and restarting awesome. The dual-screen bash script runs an xrandr screen setup.
awful.key({ modkey, "Control"}, "r",
function ()
awful.util.spawn_with_shell("/home/cuh/bin/dual-screen")
awesome.restart()
end),
--Bindings for resizing clients
awful.key({modkey, "Control"}, "Right", function() awful.tag.incmwfact(0.05) end),
awful.key({modkey, "Control"}, "Left", function() awful.tag.incmwfact(-0.05) end),
-- Prompt
awful.key({modkey}, "r", function()
awful.prompt.run({prompt = "Run: "},
mypromptbox[mouse.screen]:run(),
awful.util.spawn, awful.completion.shell,
awful.util.getdir("cache") .. "/history")
end),
awful.key({modkey, "Control"}, "l", function()
awful.prompt.run({prompt = "Run Lua code: "},
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end)
)
-- Client keys
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "space", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, }, "x", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "f", awful.client.floating.toggle ),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
awful.key({ modkey, "Control" }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, }, "h",
function (c)
c.minimized = true
end),
awful.key({ modkey, }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-------------------- Shifty integration ---------------------
-- Shifty: assign client keys to shifty for use in
-- match() function(manage hook)
-- Set keys
root.keys(globalkeys)
shifty.config.globalkeys = globalkeys
shifty.config.clientkeys = clientkeys
shifty.config.modkey = modkey
-- Hook function to execute when focusing a client.
client.add_signal("focus", 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.
client.add_signal("unfocus", function(c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_normal
end
end)
---------------------- Autostart programs -------------------
--Autostart stuff after awesome (re)start
awful.screen.focus(1) --Always start working on screen 1 (on a dual head setup)
awful.util.spawn_with_shell("xset r rate 250 60")
awful.util.spawn_with_shell("xsetroot -cursor_name left_ptr")
-------------------- Run or raise script --------------------
-- Run or raise definition, see: http://awesome.naquadah.org/wiki/Run_or_raise
-- Spawns cmd if no client can be found matching properties
-- If such a client can be found, pop to first tag where it is visible, and give it focus
-- cmd: the command to execute
-- properties: a table of properties to match against clients. Possible entries: any properties of the client object
function run_or_raise(cmd, properties)
local clients = client.get()
local focused = awful.client.next(0)
local findex = 0
local matched_clients = {}
local n = 0
for i, c in pairs(clients) do
--make an array of matched clients
if match(properties, c) then
n = n + 1
matched_clients[n] = c
if c == focused then
findex = n
end
end
end
if n > 0 then
local c = matched_clients[1]
-- if the focused window matched switch focus to next in list
if 0 < findex and findex < n then
c = matched_clients[findex+1]
end
local ctags = c:tags()
if table.getn(ctags) == 0 then
-- ctags is empty, show client on current tag
local curtag = awful.tag.selected()
awful.client.movetotag(curtag, c)
else
-- Otherwise, pop to first tag client is visible on
awful.tag.viewonly(ctags[1])
end
-- And then focus the client
client.focus = c
c:raise()
return
end
awful.util.spawn(cmd)
end
-- Returns true if all pairs in table1 are present in table2
function match (table1, table2)
for k, v in pairs(table1) do
if table2[k] ~= v and not table2[k]:find(v) then
return false
end
end
return true
end
~/.config/awesome/themes/cuh/theme.lua
theme = {}
-- I do not need a wallpaper:
theme.wallpaper_cmd = { "xsetroot -bg 0" }
config = awful.util.getdir("config")
themes = config .. "/themes"
themename = "/cuh"
themedir = themes .. themename
theme.font = "sans 8"
theme.bg_normal = "#101010"
theme.bg_focus = "#212121"
theme.bg_urgent = "#ff0000"
theme.bg_minimize = "#121212"
theme.fg_normal = "#5fafff"
theme.fg_focus = "#ff8700"
theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ababab"
-- uncomment this if you want to make selected tags a
--bit different from selected clients in the top bar:
--theme.taglist_bg_focus = "#1b1b1b"
theme.border_width = "1"
theme.border_normal = "#515151"
theme.border_focus = "#ff8700"
theme.border_marked = "#ff0056"
-- There are other variable sets
-- overriding the default one when
-- defined, the sets are:
-- [taglist|tasklist]_[bg|fg]_[focus|urgent]
-- titlebar_[bg|fg]_[normal|focus]
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
-- mouse_finder_[color|timeout|animate_timeout|radius|factor]
-- Example:
--theme.taglist_bg_focus = "#ff0000"
theme.tasklist_floating_icon = themedir .. "/tasklist/floatingw.png"
-- Define the images to load
theme.titlebar_floating_button_normal_inactive = themedir .. "/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive = themedir .. "/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = themedir .. "/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active = themedir .. "/titlebar/floating_focus_active.png"
-- Layout icons:
theme.layout_fairh = themedir .. "/layouts/fairhw.png"
theme.layout_fairv = themedir .. "/layouts/fairvw.png"
theme.layout_floating = themedir .. "/layouts/floatingw.png"
theme.layout_magnifier = themedir .. "/layouts/magnifierw.png"
theme.layout_max = themedir .. "/layouts/maxw.png"
theme.layout_fullscreen = themedir .. "/layouts/fullscreenw.png"
theme.layout_tilebottom = themedir .. "/layouts/tilebottomw.png"
theme.layout_tileleft = themedir .. "/layouts/tileleftw.png"
theme.layout_tile = themedir .. "/layouts/tilew.png"
theme.layout_tiletop = themedir .. "/layouts/tiletopw.png"
theme.layout_spiral = themedir .. "/layouts/spiralw.png"
theme.layout_dwindle = themedir .. "/layouts/dwindlew.png"
No comments:
Post a Comment