awful: add beautiful support
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f28fac6107
commit
1755dd51fe
|
@ -5,12 +5,10 @@ require("awful")
|
|||
require("tabulous")
|
||||
require("beautiful")
|
||||
|
||||
beautiful.init("@AWESOME_THEMES_PATH@/default")
|
||||
|
||||
-- Uncomment this to activate autotabbing
|
||||
-- tabulous.autotab_start()
|
||||
|
||||
-- {{{ Variable definitions
|
||||
-- This is a file path to a theme file which will defines colors.
|
||||
theme_path = "@AWESOME_THEMES_PATH@/default"
|
||||
|
||||
-- This is used later as the default terminal to run.
|
||||
terminal = "xterm"
|
||||
|
||||
|
@ -35,24 +33,37 @@ layouts =
|
|||
"floating"
|
||||
}
|
||||
|
||||
-- Table of clients that should be set floating
|
||||
-- Table of clients that should be set floating.
|
||||
floatings =
|
||||
{
|
||||
["mplayer"] = true,
|
||||
["pinentry"] = true
|
||||
}
|
||||
|
||||
-- Define if we want to use titlebar on all applications
|
||||
-- Define if we want to use titlebar on all applications.
|
||||
use_titlebar = false
|
||||
-- }}}
|
||||
|
||||
-- {{{ Initialization
|
||||
-- Initialize theme (colors).
|
||||
beautiful.init(theme_path)
|
||||
|
||||
-- Register theme in awful.
|
||||
-- This allows to not pass plenty of arguments to each function
|
||||
-- to inform it about colors we want it to draw.
|
||||
awful.beautiful.register(beautiful)
|
||||
|
||||
-- Uncomment this to activate autotabbing
|
||||
-- tabulous.autotab_start()
|
||||
-- }}}
|
||||
|
||||
-- {{{ Tags
|
||||
-- Define tags table
|
||||
-- Define tags table.
|
||||
tags = {}
|
||||
for s = 1, screen.count() do
|
||||
-- Each screen has its own tag table
|
||||
-- Each screen has its own tag table.
|
||||
tags[s] = {}
|
||||
-- Create 9 tags per screen
|
||||
-- Create 9 tags per screen.
|
||||
for tagnumber = 1, 9 do
|
||||
tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
|
||||
-- Add tags to screen one by one
|
||||
|
@ -73,14 +84,14 @@ mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.s
|
|||
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
|
||||
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
|
||||
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
|
||||
function mytaglist.label(t) return awful.widget.taglist.label.all(t, beautiful.bg_focus, beautiful.fg_focus, beautiful.bg_urgent, beautiful.fg_urgent) end
|
||||
mytaglist.label = awful.widget.taglist.label.all
|
||||
|
||||
-- Create a tasklist widget
|
||||
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
|
||||
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
|
||||
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
|
||||
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
|
||||
function mytasklist.label(c, screen) return awful.widget.tasklist.label.currenttags(c, screen, beautiful.bg_focus, beautiful.fg_focus, beautiful.bg_urgent, beautiful.fg_urgent) end
|
||||
mytasklist.label = awful.widget.tasklist.label.currenttags
|
||||
|
||||
-- Create a textbox widget
|
||||
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
|
||||
|
@ -210,10 +221,10 @@ keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -
|
|||
|
||||
-- Prompt
|
||||
keybinding({ modkey }, "F1", function ()
|
||||
awful.prompt({ prompt = "Run: ", cursor_fg = beautiful.fg_focus, cursor_bg = beautiful.bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
|
||||
awful.prompt({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash)
|
||||
end):add()
|
||||
keybinding({ modkey }, "F4", function ()
|
||||
awful.prompt({ prompt = "Run Lua code: ", cursor_fg = beautiful.fg_focus, cursor_bg = beautiful.bg_focus }, mypromptbox, awful.eval)
|
||||
awful.prompt({ prompt = "Run Lua code: " }, mypromptbox, awful.eval)
|
||||
end):add()
|
||||
|
||||
--- Tabulous, tab manipulation
|
||||
|
@ -315,11 +326,7 @@ function hook_manage(c)
|
|||
c.floating_placement = "smart"
|
||||
if use_titlebar then
|
||||
-- Add a titlebar
|
||||
awful.titlebar.add(c, { fg = beautiful.fg_normal,
|
||||
bg = beautiful.bg_normal,
|
||||
fg_focus = beautiful.fg_focus,
|
||||
bg_focus = beautiful.bg_focus,
|
||||
modkey = modkey })
|
||||
awful.titlebar.add(c, { modkey = modkey })
|
||||
end
|
||||
-- Add mouse bindings
|
||||
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
|
||||
|
|
101
lib/awful.lua.in
101
lib/awful.lua.in
|
@ -48,7 +48,11 @@ function ObjectTable.new()
|
|||
return o
|
||||
end
|
||||
|
||||
-- Various structure
|
||||
-- Local variable handling theme
|
||||
local theme = {}
|
||||
|
||||
-- Various public structures
|
||||
beautiful = {}
|
||||
hooks = {}
|
||||
hooks.user = {}
|
||||
prompt = {}
|
||||
|
@ -783,18 +787,18 @@ local function prompt_text_with_cursor(text, text_color, cursor_color, cursor_po
|
|||
end
|
||||
|
||||
--- Run a prompt in a box.
|
||||
-- @param args A table with optional arguments: cursor_fg, cursor_bg, prompt.
|
||||
-- @param args A table with optional arguments: fg_cursor, bg_cursor, prompt.
|
||||
-- @param textbox The textbox to use for the prompt.
|
||||
-- @param exe_callback The callback function to call with command as argument when finished.
|
||||
-- @param completion_callback The callback function to call to get completion.
|
||||
function prompt(args, textbox, exe_callback, completion_callback)
|
||||
if not args then return end
|
||||
if not args then args = {} end
|
||||
local command = ""
|
||||
local command_before_comp
|
||||
local cur_pos_before_comp
|
||||
local prompt = args.prompt or ""
|
||||
local inv_col = args.cursor_fg or "black"
|
||||
local cur_col = args.cursor_bg or "white"
|
||||
local inv_col = args.fg_cursor or theme.fg_focus or "black"
|
||||
local cur_col = args.bg_cursor or theme.bg_focus or "white"
|
||||
-- The cursor position
|
||||
local cur_pos = 1
|
||||
-- The completion element to use on completion request.
|
||||
|
@ -967,12 +971,18 @@ end
|
|||
-- It returns the tag name and set a special
|
||||
-- foreground and background color for selected tags.
|
||||
-- @param t The tag.
|
||||
-- @param bg_focus The background color for selected tag.
|
||||
-- @param fg_focus The foreground color for selected tag.
|
||||
-- @param bg_urgent The background color for urgent tags.
|
||||
-- @param fg_urgent The foreground color for urgent tags.
|
||||
-- @param args The arguments table.
|
||||
-- bg_focus The background color for selected tag.
|
||||
-- fg_focus The foreground color for selected tag.
|
||||
-- bg_urgent The background color for urgent tags.
|
||||
-- fg_urgent The foreground color for urgent tags.
|
||||
-- @return A string to print.
|
||||
function widget.taglist.label.all(t, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
function widget.taglist.label.all(t, args)
|
||||
if not args then args = {} end
|
||||
local fg_focus = args.fg_focus or theme.fg_focus
|
||||
local bg_focus = args.bg_focus or theme.bg_focus
|
||||
local fg_urgent = args.fg_urgent or theme.fg_urgent
|
||||
local bg_urgent = args.bg_urgent or theme.bg_urgent
|
||||
local text
|
||||
local background = ""
|
||||
local sel = capi.client.focus_get()
|
||||
|
@ -1003,7 +1013,12 @@ function widget.taglist.label.all(t, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
|||
return text
|
||||
end
|
||||
|
||||
local function widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
local function widget_tasklist_label_common(c, args)
|
||||
if not args then args = {} end
|
||||
local fg_focus = args.fg_focus or theme.fg_focus
|
||||
local bg_focus = args.bg_focus or theme.bg_focus
|
||||
local fg_urgent = args.fg_urgent or theme.fg_urgent
|
||||
local bg_urgent = args.bg_urgent or theme.bg_urgent
|
||||
local text = ""
|
||||
if c.floating then
|
||||
text = "<bg image=\"@AWESOME_ICON_PATH@/tasklist/floatingw.png\" align=\"right\"/>"
|
||||
|
@ -1024,13 +1039,14 @@ end
|
|||
-- It also puts a special icon for floating windows.
|
||||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @param bg_focus The background color for focused client.
|
||||
-- @param fg_focus The foreground color for focused client.
|
||||
-- @param bg_urgent The background color for urgent clients.
|
||||
-- @param fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to pring.
|
||||
function widget.tasklist.label.allscreen(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
-- @param args The arguments table.
|
||||
-- bg_focus The background color for focused client.
|
||||
-- fg_focus The foreground color for focused client.
|
||||
-- bg_urgent The background color for urgent clients.
|
||||
-- fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to print.
|
||||
function widget.tasklist.label.allscreen(c, screen, args)
|
||||
return widget_tasklist_label_common(c, args)
|
||||
end
|
||||
|
||||
--- Return labels for a tasklist widget with clients from all tags.
|
||||
|
@ -1039,15 +1055,16 @@ end
|
|||
-- It also puts a special icon for floating windows.
|
||||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @param bg_focus The background color for focused client.
|
||||
-- @param fg_focus The foreground color for focused client.
|
||||
-- @param bg_urgent The background color for urgent clients.
|
||||
-- @param fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to pring.
|
||||
function widget.tasklist.label.alltags(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
-- @param args The arguments table.
|
||||
-- bg_focus The background color for focused client.
|
||||
-- fg_focus The foreground color for focused client.
|
||||
-- bg_urgent The background color for urgent clients.
|
||||
-- fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to print.
|
||||
function widget.tasklist.label.alltags(c, screen, args)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return end
|
||||
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
return widget_tasklist_label_common(c, args)
|
||||
end
|
||||
|
||||
--- Return labels for a tasklist widget with clients from currently selected tags.
|
||||
|
@ -1056,17 +1073,18 @@ end
|
|||
-- It also puts a special icon for floating windows.
|
||||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @param bg_focus The background color for focused client.
|
||||
-- @param fg_focus The foreground color for focused client.
|
||||
-- @param bg_urgent The background color for urgent clients.
|
||||
-- @param fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to pring.
|
||||
function widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
-- @param args The arguments table.
|
||||
-- bg_focus The background color for focused client.
|
||||
-- fg_focus The foreground color for focused client.
|
||||
-- bg_urgent The background color for urgent clients.
|
||||
-- fg_urgent The foreground color for urgent clients.
|
||||
-- @return A string to print.
|
||||
function widget.tasklist.label.currenttags(c, screen, args)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return end
|
||||
for k, t in pairs(capi.tag.get(screen)) do
|
||||
if t.selected and c:istagged(t) then
|
||||
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||
return widget_tasklist_label_common(c, args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1079,12 +1097,13 @@ end
|
|||
-- fg_focus: the foreground color for focused window.
|
||||
-- fg_focus: the background color for focused window.
|
||||
function titlebar.add(c, args)
|
||||
if not args then args = {} end
|
||||
-- Store colors
|
||||
titlebar.data[c] = {}
|
||||
titlebar.data[c].fg = args.fg
|
||||
titlebar.data[c].bg = args.bg
|
||||
titlebar.data[c].fg_focus = args.fg_focus
|
||||
titlebar.data[c].bg_focus = args.bg_focus
|
||||
titlebar.data[c].fg = args.fg or theme.fg_normal
|
||||
titlebar.data[c].bg = args.bg or theme.bg_normal
|
||||
titlebar.data[c].fg_focus = args.fg_focus or theme.fg_focus
|
||||
titlebar.data[c].bg_focus = args.bg_focus or theme.bg_focus
|
||||
|
||||
-- Built args
|
||||
local targs = {}
|
||||
|
@ -1139,6 +1158,16 @@ function titlebar.remove(c)
|
|||
titlebar.data[c] = nil
|
||||
end
|
||||
|
||||
--- Set the beautiful theme if any.
|
||||
-- @param The beautiful theme.
|
||||
function beautiful.register(btheme)
|
||||
if btheme then
|
||||
theme = btheme
|
||||
else
|
||||
theme = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Register standards hooks
|
||||
hooks.arrange.register(tag.history.update)
|
||||
|
||||
|
|
Loading…
Reference in New Issue