1
0
Fork 0
mirror of https://github.com/kastdeur/dotfiles.git synced 2024-12-22 09:13:33 +01:00

Added awesome support

This commit is contained in:
Eric Teunis de Boone 2016-10-05 01:39:07 +02:00
parent 061f80b9b9
commit eefbcce0d9
10 changed files with 981 additions and 0 deletions

1
awesome/alttab Submodule

@ -0,0 +1 @@
Subproject commit d6bc60007e4071ec79ae76935576d26c2fdfca76

113
awesome/calendar2.lua Normal file
View file

@ -0,0 +1,113 @@
-- original code made by Bzed and published on http://awesome.naquadah.org/wiki/Calendar_widget
-- modified by Marc Dequènes (Duck) <Duck@DuckCorp.org> (2009-12-29), under the same licence,
-- and with the following changes:
-- + transformed to module
-- + the current day formating is customizable
local string = string
--local print = print
local tostring = tostring
local os = os
local capi = {
mouse = mouse,
screen = screen
}
local awful = require("awful")
local naughty = require("naughty")
module("calendar2")
local calendar = {}
local current_day_format = "<u>%s</u>"
function displayMonth(month,year,weekStart)
local t,wkSt=os.time{year=year, month=month+1, day=0},weekStart or 1
local d=os.date("*t",t)
local mthDays,stDay=d.day,(d.wday-d.day-wkSt+1)%7
--print(mthDays .."\n" .. stDay)
local lines = " "
for x=0,6 do
lines = lines .. os.date("%a ",os.time{year=2006,month=1,day=x+wkSt})
end
lines = lines .. "\n" .. os.date(" %V",os.time{year=year,month=month,day=1})
local writeLine = 1
while writeLine < (stDay + 1) do
lines = lines .. " "
writeLine = writeLine + 1
end
for d=1,mthDays do
local x = d
local t = os.time{year=year,month=month,day=d}
if writeLine == 8 then
writeLine = 1
lines = lines .. "\n" .. os.date(" %V",t)
end
if os.date("%Y-%m-%d") == os.date("%Y-%m-%d", t) then
x = string.format(current_day_format, d)
end
if (#(tostring(d)) == 1) then
x = " " .. x
end
lines = lines .. " " .. x
writeLine = writeLine + 1
end
local header = os.date("%B %Y\n",os.time{year=year,month=month,day=1})
return header .. "\n" .. lines
end
function switchNaughtyMonth(switchMonths)
if (#calendar < 3) then return end
local swMonths = switchMonths or 1
calendar[1] = calendar[1] + swMonths
calendar[3].box.widgets[2].text = string.format('<span font_desc="%s">%s</span>', "monospace", displayMonth(calendar[1], calendar[2], 2))
end
function addCalendarToWidget(mywidget, custom_current_day_format)
if custom_current_day_format then current_day_format = custom_current_day_format end
mywidget:add_signal('mouse::enter', function ()
local month, year = os.date('%m'), os.date('%Y')
calendar = { month, year,
naughty.notify({
text = string.format('<span font_desc="%s">%s</span>', "monospace", displayMonth(month, year, 2)),
timeout = 0,
hover_timeout = 0.5,
screen = capi.mouse.screen
})
}
end)
mywidget:add_signal('mouse::leave', function () naughty.destroy(calendar[3]) end)
mywidget:buttons(awful.util.table.join(
awful.button({ }, 1, function()
switchNaughtyMonth(-1)
end),
awful.button({ }, 3, function()
switchNaughtyMonth(1)
end),
awful.button({ }, 4, function()
switchNaughtyMonth(-1)
end),
awful.button({ }, 5, function()
switchNaughtyMonth(1)
end),
awful.button({ 'Shift' }, 1, function()
switchNaughtyMonth(-12)
end),
awful.button({ 'Shift' }, 3, function()
switchNaughtyMonth(12)
end),
awful.button({ 'Shift' }, 4, function()
switchNaughtyMonth(-12)
end),
awful.button({ 'Shift' }, 5, function()
switchNaughtyMonth(12)
end)
))
end

134
awesome/diskusage.lua Normal file
View file

@ -0,0 +1,134 @@
-- @author Peter J. Kranz (Absurd-Mind, peter@myref.net)
-- Any questions, criticism or praise just drop me an email
-- {{{ init environment
local M = {}
local capi = {
mouse = mouse,
screen = screen
}
units = {"KB", "MB", "GB", "TB", "PB", "EB"}
local usage = {}
-- }}}
-- {{{ local functions
-- {{{ Unit formatter
-- formats a value to the corresponding unit
local function uformat(value)
local ret = tonumber(value)
for i, u in pairs(units) do
if ret < 1024 then
return string.format("%.1f" .. u, ret)
end
ret = ret / 1024;
end
return "N/A"
end
-- }}}
-- {{{ getData
-- gets the required data from df
local function getData(onlyLocal)
-- Fallback to listing local filesystems
local warg = ""
if onlyLocal == true then
warg = "-l"
end
local fs_info = {} -- Get data from df
local f = io.popen("LC_ALL=C df -kP " .. warg)
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
local s = string.match(line, "^.-[%s]([%d]+)")
local u,a,p = string.match(line, "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%")
local m = string.match(line, "%%[%s]([%p%w]+)")
if u and m then -- Handle 1st line and broken regexp
fs_info[m] = {}
fs_info[m]["size"] = s
fs_info[m]["used"] = u
fs_info[m]["avail"] = a
fs_info[m]["used_p"] = tonumber(p)
fs_info[m]["avail_p"] = 100 - tonumber(p)
end
end
f:close()
return fs_info
end
-- }}}
-- {{{ display
-- formats the lines for the notify
local function display(orange, red, onlyLocal)
data = getData(onlyLocal)
local lines = "<u>diskusage:</u>\n"
local longest = 0
local longestSize = 0;
local longestUsed = 0;
for i, m in pairs(data) do
if i:len() > longest then
longest = i:len()
end
local s = uformat(m["size"])
if s:len() > longestSize then
longestSize = s:len()
end
local u = uformat(m["used"])
if u:len() > longestUsed then
longestUsed = u:len()
end
end
longest = longest + 8
for i, m in pairs(data) do
local u = uformat(m["used"])
local s = uformat(m["size"])
if m["used_p"] >= red then
lines = lines .. "<span color='red'>"
elseif m["used_p"] >= orange then
lines = lines .. "<span color='orange'>"
else
lines = lines .. "<span color='green'>"
end
lines = lines
.. "\n"
.. i
.. string.rep(" ", longest + longestSize - i:len() - u:len())
.. u
.. " / "
.. s
.. string.rep(" ", longestUsed - s:len())
.. " ("
.. m["used_p"]
.. "%)</span>"
end
return lines
end
-- }}}
-- }}}
-- {{{ global functions
function M.addToWidget(mywidget, orange, red, onlyLocal)
mywidget:add_signal('mouse::enter', function ()
usage = naughty.notify({
text = string.format('<span font_desc="%s">%s</span>', "monospace", display(orange, red, onlyLocal)),
timeout = 0,
hover_timeout = 0.5,
screen = capi.mouse.screen
})
end)
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
end
-- }}}
return M

53
awesome/power.lua Normal file
View file

@ -0,0 +1,53 @@
local wibox = require("wibox")
local awful = require("awful")
powercfg = {}
powercfg.widget = wibox.widget.textbox()
powercfg.widget:set_align("right");
powercfg.update = function ()
local fd = io.popen("acpi | cut -d ':' -f 2")
local status = fd:read("*all")
fd:close()
local power = tonumber(string.match(status, "%d+"))
stats = string.match(status,"(%s+),")
-- local charging = false
--
--
local colour = 'blue'
-- -- colours (start and end)
-- local sr, sg, sb = 0x3F,0x3F,0x3F
-- local er, eg, eb = 0xDC, 0xDC, 0xDC
--
-- -- make colour
-- local ir = math.floor(power * (er - sr) + sr)
-- local ib = math.floor(power * (eg - sg) + sg)
-- local ig = math.floor(power * (eb - sb) + sb)
-- --interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
interpol_colour = '3f4f3f'
--
-- if charging then
-- colour = 'green'
-- elseif power < 50 then
-- colour = 'yellow'
-- elseif power < 25 then
-- colour = 'orange'
-- elseif power < 10 then
-- colour = 'red'
-- end
--power = status
text = "<span color='" .. colour .. "' background='#" .. interpol_colour .. "'> " .. power .. "% </span>" .. status
powercfg.widget.text = text
powercfg.widget:set_markup(text)
end
-- start updating it
powercfg.update()
powercfg.timer = timer({ timeout = 1})
powercfg.timer:connect_signal("timeout", function () powercfg.update() end)
powercfg.timer:start()

Binary file not shown.

View file

@ -0,0 +1,52 @@
local awful = require('awful')
local util = require('awful.util')
local wibox = require('wibox')
filedir = (...):match("(.-)[^%.]+$") .. "/quick_launch/"
-- Quick launch bar widget BEGINS
function find_icon(icon_name, icon_dirs)
if string.sub(icon_name, 1, 1) == '/' then
if util.file_readable(icon_name) then
return icon_name
else
return nil
end
end
if icon_dirs then
for _, v in ipairs(icon_dirs) do
if util.file_readable(v .. '/' .. icon_name) then
return v .. '/' .. icon_name
end
end
end
return nil
end
function getValue(t, key)
_, _, res = string.find(t, 'key' .. ' *= *([^%c]+)%c')
return res
end
launchbar = { layout = wibox.layout.horizontal }
local items = {}
local files = io.popen('ls ' .. filedir .. ' *.desktop')
for f in files:lines() do
local t = io.open(f):read('*all')
table.insert(items, { image = find_icon(getValue(t,Icon), { "/usr/share/icons/hicolor/22x22/apps" }),
command = getValue(t,Exec),
tooltip = getValue(t,Name),
position = tonumber(getValue(t,Position)) or 255 })
end
table.sort(items, function(a,b) return a.position < b.position end)
for i = 1, table.getn(items) do
launchbar[i] = awful.widget.launcher(items[i])
-- local txt = launchbar[i].tooltip
-- local tt = awful.tooltip ({ objects = { launchbar[i] } })
-- tt:set_text (txt)
-- tt:set_timeout (0)
end
-- Quick launch bar widget ENDS
return launchbar

502
awesome/rc.lua Normal file
View file

@ -0,0 +1,502 @@
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local menubar = require("menubar")
-- Alt-Tab
local alttab = require("alttab")
alttab.settings.preview_box = true -- display preview-box
alttab.settings.preview_box_bg = "#ddddddaa" -- background color
alttab.settings.preview_box_border = "#22222200" -- border-color
alttab.settings.preview_box_fps = 30 -- refresh framerate
alttab.settings.preview_box_delay = 150 -- delay in ms
alttab.settings.client_opacity = false -- set opacity for unselected clients
alttab.settings.client_opacity_value = 0.5 -- alpha-value
alttab.settings.client_opacity_delay = 150 -- delay in ms
-- Widgets
--launchbar = require("quick_launch")
require("volume")
require("power")
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = err })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
-- This is used later as the default terminal and editor to run.
terminal = "terminology"
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e " .. editor
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- 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.
local layouts =
{
-- awful.layout.suit.floating,
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.spiral,
-- awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
--awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
-- }}}
-- {{{ Wallpaper
if beautiful.wallpaper then
for s = 1, screen.count() do
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end
end
-- }}}
-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {"main", "web", "tmux",4,5,"sxc","ru",8,9}
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag(tags, s, layouts[1])
end
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
mypowermenu = {
{ "suspend", terminal .. " -e systemctl suspend"},
{ "lock", terminal .. " -e xscreensavercmd -lock"}
}
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "powermenu", mypowermenu },
{ "open terminal", terminal },
{ "filemanager", function () os.execute("nemo") end }
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu },
{ image = filebrowser, command = function() os.execute("nemo &") end },
{ image = firefox, command = function () os.execute("firefox") end })
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}
-- {{{ Wibox
-- Create a textclock widget
mytextclock = awful.widget.textclock()
-- 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, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
)
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end
end),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({
theme = { 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))
--require("volume2")
--require("diskusage")
--diskwidget = widget({ type = 'imagebox' })
--diskwidget.image = image("/home/username/.config/awesome/du.png")
--disk = require("diskusage")
-- the first argument is the widget to trigger the diskusage
-- -- the second/third is the percentage at which a line gets orange/red
-- -- true = show only local filesystems
--disk.addToWidget(diskwidget, 75, 90, false)
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt()
-- 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(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(mytaglist[s])
left_layout:add(mypromptbox[s])
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
-- right_layout:add(diskwidget)
--right_layout:add(launchbar)
right_layout:add(powercfg.widget)
right_layout:add(volumecfg.widget)
-- right_layout:add(volume_widget)
right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
-- Now bring it all together (with the tasklist in the middle)
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(mytasklist[s])
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
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, "Shift" }, "s", function () os.execute("systemctl suspend") end ),
awful.key({ modkey, "Shift" }, "a", function () os.execute("sleep 1s; xset dpms force off") end ),
-- Volume keys
awful.key({ }, "XF86AudioRaiseVolume", function () volumecfg.up() end),
awful.key({ }, "XF86AudioLowerVolume", function () volumecfg.down() end),
awful.key({ }, "XF86AudioMute", function () volumecfg.toggle() end),
-- Alt-Tab
awful.key({ "Mod1", }, "Tab", function ()
alttab.switch(1, "Alt_L", "Tab", "ISO_Left_Tab")
end),
awful.key({ "Mod1", "Shift" }, "Tab", function ()
alttab.switch(-1, "Alt_L", "Tab", "ISO_Left_Tab")
end),
-- Standard
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
awful.key({ modkey, }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "k",
function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "w", function () mymainmenu:show() 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_relative( 1) end),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
-- Standard program
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit),
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),
awful.key({ modkey, "Control" }, "n", awful.client.restore),
-- Prompt
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
awful.key({ modkey }, "x",
function ()
awful.prompt.run({ prompt = "Run Lua code: " },
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end),
-- Menubar
awful.key({ modkey }, "p", function() menubar.show() end)
)
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, }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, }, "n",
function (c)
-- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus.
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)
)
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do
globalkeys = awful.util.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewonly(tag)
end
end),
-- Toggle tag.
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewtoggle(tag)
end
end),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i]
if tag then
awful.client.movetotag(tag)
end
end
end),
-- Toggle tag.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i]
if tag then
awful.client.toggletag(tag)
end
end
end))
end
clientbuttons = 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))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
-- Rules to apply to new clients (through the "manage" signal).
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
-- Set Firefox to always map on tags number 2 of screen 1.
{ rule = { class = "Firefox" },
properties = { tag = tags[1][2] } },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
local titlebars_enabled = false
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
-- buttons for the titlebar
local buttons = awful.util.table.join(
awful.button({ }, 1, function()
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
client.focus = c
c:raise()
awful.mouse.client.resize(c)
end)
)
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(awful.titlebar.widget.iconwidget(c))
left_layout:buttons(buttons)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
right_layout:add(awful.titlebar.widget.stickybutton(c))
right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local middle_layout = wibox.layout.flex.horizontal()
local title = awful.titlebar.widget.titlewidget(c)
title:set_align("center")
middle_layout:add(title)
middle_layout:buttons(buttons)
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c):set_widget(layout)
end
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}

74
awesome/volume.lua Normal file
View file

@ -0,0 +1,74 @@
-- Volume widget
local awful = require("awful")
local wibox = require("wibox")
volumecfg = {}
volumecfg.channel = "Master"
volumecfg.widget = wibox.widget.textbox()
volumecfg.widget:set_align("right")
volumecfg.widget.name = 'volumecfg.widget'
volumecfg_t = awful.tooltip({ objects = { volumecfg.widget },})
volumecfg_t:set_text("Volume")
-- command must start with a space!
volumecfg.mixercommand = function (command)
local fd = io.popen("amixer " .. command)
local status = fd:read("*all")
fd:close()
local volume = tonumber(string.match(status, "(%d?%d?%d)%%"))
-- volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
-- starting colour
local sr, sg, sb = 0x3F, 0x3F, 0x3F
-- ending colour
local er, eg, eb = 0xDC, 0xDC, 0xCC
if string.find(status, "on", 1, true) then
color = 'blue'
mute = ''
else
sr, sg, sb = 0xFF, 0x33, 0xAA
color = 'red'
mute = 'M'
end
local ir = math.floor(volume/100 * (er - sr) + sr)
local ig = math.floor(volume/100 * (eg - sg) + sg)
local ib = math.floor(volume/100 * (eb - sb) + sb)
interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
volume = " <span color='" .. color .. "' background='#" .. interpol_colour .. "'> ".. mute .. math.floor(volume) .. "% </span>"
-- volume = volume .. "%"
volumecfg.widget.text = volume
volumecfg.widget:set_markup(volume)
end
volumecfg.update = function ()
volumecfg.mixercommand(" sget " .. volumecfg.channel)
end
volumecfg.up = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%+")
end
volumecfg.down = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%-")
end
volumecfg.toggle = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle")
end
volumecfg.widget:buttons(awful.util.table.join(
awful.button({ }, 4, function () volumecfg.up() end),
awful.button({ }, 5, function () volumecfg.down() end),
awful.button({ }, 1, function () volumecfg.toggle() end),
awful.button({ }, 3, function () os.execute("pavucontrol &") end)
))
-- start updating
volumecfg.update()
mytimer = timer({ timeout = 1 })
mytimer:connect_signal("timeout", function () volumecfg.update() end)
mytimer:start()

51
awesome/volume2.lua Normal file
View file

@ -0,0 +1,51 @@
local wibox = require("wibox")
local awful = require("awful")
volume_widget = wibox.widget.textbox()
volume_widget:set_align("right")
function raise_volume()
os.execute("amixer sset Master 1%+")
end
function lower_volume ()
os.execute("amixer sset Master 1%-")
end
function toggle_volume ()
os.execute("amixer sset Master toggle")
end
function update_volume(widget)
local fd = io.popen("amixer sget Master")
local status = fd:read("*all")
fd:close()
local volume = tonumber(string.match(status, "(%d?%d?%d)%%"))
-- volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
-- starting colour
local sr, sg, sb = 0x3F, 0x3F, 0x3F
-- ending colour
local er, eg, eb = 0xDC, 0xDC, 0xCC
local ir = math.floor(volume/100 * (er - sr) + sr)
local ig = math.floor(volume/100 * (eg - sg) + sg)
local ib = math.floor(volume/100 * (eb - sb) + sb)
interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
if string.find(status, "on", 1, true) then
volume = " <span color='blue' background='#" .. interpol_colour .. "'> ".. math.floor(volume) .. "% </span>"
else
volume = " <span color='red' background='#" .. interpol_colour .. "'> M(".. math.floor(volume) .."%) </span>"
end
widget:set_markup(volume)
end
-- start updating
update_volume(volume_widget)
mytimer = timer({ timeout = 1 })
mytimer:connect_signal("timeout", function () update_volume(volume_widget) end)
mytimer:start()

View file

@ -15,6 +15,7 @@
~/.tmux.conf: tmux/tmux.conf ~/.tmux.conf: tmux/tmux.conf
~/.vimrc: vim/vimrc ~/.vimrc: vim/vimrc
~/.xinitrc: xinitrc ~/.xinitrc: xinitrc
~/.config/awesome: awesome
#- shell: #- shell:
# - git submodules update # after linking ~/.gitconfig # - git submodules update # after linking ~/.gitconfig