Tweaks and cleanup
This commit is contained in:
parent
3aad6fe631
commit
a6093d1758
@ -17,82 +17,82 @@ local margin = { x = 20, y = 20 }
|
|||||||
|
|
||||||
function add_icon(settings)
|
function add_icon(settings)
|
||||||
|
|
||||||
local s = settings.screen
|
local s = settings.screen
|
||||||
|
|
||||||
if not current_pos[s] then
|
if not current_pos[s] then
|
||||||
current_pos[s] = { x = (screen[s].geometry.width - iconsize.width - margin.x), y = 40 }
|
current_pos[s] = { x = (screen[s].geometry.width - iconsize.width - margin.x), y = 40 }
|
||||||
end
|
end
|
||||||
|
|
||||||
local totheight = (settings.icon and iconsize.height or 0) + (settings.label and labelsize.height or 0)
|
local totheight = (settings.icon and iconsize.height or 0) + (settings.label and labelsize.height or 0)
|
||||||
if totheight == 0 then return end
|
if totheight == 0 then return end
|
||||||
|
|
||||||
if current_pos[s].y + totheight > screen[s].geometry.height - 40 then
|
if current_pos[s].y + totheight > screen[s].geometry.height - 40 then
|
||||||
current_pos[s].x = current_pos[s].x - labelsize.width - iconsize.width - margin.x
|
current_pos[s].x = current_pos[s].x - labelsize.width - iconsize.width - margin.x
|
||||||
current_pos[s].y = 40
|
current_pos[s].y = 40
|
||||||
end
|
end
|
||||||
|
|
||||||
if (settings.icon) then
|
if (settings.icon) then
|
||||||
icon = awful.widget.button({ image = settings.icon })
|
icon = awful.widget.button({ image = settings.icon })
|
||||||
local newbuttons = icon:buttons()
|
local newbuttons = icon:buttons()
|
||||||
table.insert(newbuttons, button({}, 1, nil, settings.click));
|
table.insert(newbuttons, button({}, 1, nil, settings.click));
|
||||||
icon:buttons(newbuttons)
|
icon:buttons(newbuttons)
|
||||||
|
|
||||||
icon_container = wibox({ position = "floating", screen = s, bg = "#00000000" })
|
icon_container = wibox({ position = "floating", screen = s, bg = "#00000000" })
|
||||||
icon_container.widgets = { icon }
|
icon_container.widgets = { icon }
|
||||||
icon_container:geometry({
|
icon_container:geometry({
|
||||||
width = iconsize.width,
|
width = iconsize.width,
|
||||||
height = iconsize.height,
|
height = iconsize.height,
|
||||||
y = current_pos[s].y,
|
y = current_pos[s].y,
|
||||||
x = current_pos[s].x
|
x = current_pos[s].x
|
||||||
})
|
})
|
||||||
icon_container.screen = s
|
icon_container.screen = s
|
||||||
|
|
||||||
current_pos[s].y = current_pos[s].y + iconsize.height + 5
|
current_pos[s].y = current_pos[s].y + iconsize.height + 5
|
||||||
end
|
end
|
||||||
|
|
||||||
if (settings.label) then
|
if (settings.label) then
|
||||||
caption = widget({ type="textbox", align="right", width=labelsize.width })
|
caption = widget({ type="textbox", align="right", width=labelsize.width })
|
||||||
caption.ellipsize = "middle"
|
caption.ellipsize = "middle"
|
||||||
caption.text = settings.label
|
caption.text = settings.label
|
||||||
caption:buttons({
|
caption:buttons({
|
||||||
button({ }, 1, settings.click)
|
button({ }, 1, settings.click)
|
||||||
})
|
})
|
||||||
|
|
||||||
caption_container = wibox({ position = "floating", screen = s, bg = "#00000000" })
|
caption_container = wibox({ position = "floating", screen = s, bg = "#00000000" })
|
||||||
caption_container.widgets = { caption }
|
caption_container.widgets = { caption }
|
||||||
caption_container:geometry({
|
caption_container:geometry({
|
||||||
width = labelsize.width,
|
width = labelsize.width,
|
||||||
height = labelsize.height,
|
height = labelsize.height,
|
||||||
y = current_pos[s].y,
|
y = current_pos[s].y,
|
||||||
x = current_pos[s].x - labelsize.width + iconsize.width
|
x = current_pos[s].x - labelsize.width + iconsize.width
|
||||||
})
|
})
|
||||||
caption_container.screen = s
|
caption_container.screen = s
|
||||||
end
|
end
|
||||||
|
|
||||||
current_pos[s].y = current_pos[s].y + labelsize.height + margin.y
|
current_pos[s].y = current_pos[s].y + labelsize.height + margin.y
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds subdirs and files icons to the desktop
|
--- Adds subdirs and files icons to the desktop
|
||||||
-- @param dir The directory to parse, (default is ~/Desktop)
|
-- @param dir The directory to parse, (default is ~/Desktop)
|
||||||
-- @param showlabels Shows icon captions (default is false)
|
-- @param showlabels Shows icon captions (default is false)
|
||||||
function add_applications_icons(arg)
|
function add_applications_icons(arg)
|
||||||
for i, program in ipairs(utils.parse_desktop_files({
|
for i, program in ipairs(utils.parse_desktop_files({
|
||||||
dir = arg.dir or '~/Desktop/',
|
dir = arg.dir or '~/Desktop/',
|
||||||
icon_sizes = {
|
icon_sizes = {
|
||||||
iconsize.width .. "x" .. iconsize.height,
|
iconsize.width .. "x" .. iconsize.height,
|
||||||
"128x128", "96x96", "72x72", "64x64", "48x48",
|
"128x128", "96x96", "72x72", "64x64", "48x48",
|
||||||
"36x36", "32x32", "24x24", "22x22", "16x6"
|
"36x36", "32x32", "24x24", "22x22", "16x6"
|
||||||
}
|
}
|
||||||
})) do
|
})) do
|
||||||
if program.show then
|
if program.show then
|
||||||
add_icon({
|
add_icon({
|
||||||
label = arg.showlabels and program.Name or nil,
|
label = arg.showlabels and program.Name or nil,
|
||||||
icon = program.icon_path,
|
icon = program.icon_path,
|
||||||
screen = arg.screen,
|
screen = arg.screen,
|
||||||
click = function () awful.util.spawn(program.cmdline) end
|
click = function () awful.util.spawn(program.cmdline) end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds subdirs and files icons to the desktop
|
--- Adds subdirs and files icons to the desktop
|
||||||
@ -100,27 +100,27 @@ end
|
|||||||
-- @param showlabels Shows icon captions
|
-- @param showlabels Shows icon captions
|
||||||
-- @param open_with The program to use to open clicked files and dirs (i.e. xdg_open, thunar, etc.)
|
-- @param open_with The program to use to open clicked files and dirs (i.e. xdg_open, thunar, etc.)
|
||||||
function add_dirs_and_files_icons(arg)
|
function add_dirs_and_files_icons(arg)
|
||||||
arg.open_with = arg.open_width or 'thunar'
|
arg.open_with = arg.open_width or 'thunar'
|
||||||
for i, file in ipairs(utils.parse_dirs_and_files({
|
for i, file in ipairs(utils.parse_dirs_and_files({
|
||||||
dir = arg.dir or '~/Desktop/',
|
dir = arg.dir or '~/Desktop/',
|
||||||
icon_sizes = {
|
icon_sizes = {
|
||||||
iconsize.width .. "x" .. iconsize.height,
|
iconsize.width .. "x" .. iconsize.height,
|
||||||
"128x128", "96x96", "72x72", "64x64", "48x48",
|
"128x128", "96x96", "72x72", "64x64", "48x48",
|
||||||
"36x36", "32x32", "24x24", "22x22", "16x6"
|
"36x36", "32x32", "24x24", "22x22", "16x6"
|
||||||
}
|
}
|
||||||
})) do
|
})) do
|
||||||
if file.show then
|
if file.show then
|
||||||
add_icon({
|
add_icon({
|
||||||
label = arg.showlabels and file.filename or nil,
|
label = arg.showlabels and file.filename or nil,
|
||||||
icon = file.icon,
|
icon = file.icon,
|
||||||
screen = arg.screen,
|
screen = arg.screen,
|
||||||
click = function () awful.util.spawn(arg.open_with .. ' ' .. file.path) end
|
click = function () awful.util.spawn(arg.open_with .. ' ' .. file.path) end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_desktop_icons(args)
|
function add_desktop_icons(args)
|
||||||
add_applications_icons(args)
|
add_applications_icons(args)
|
||||||
add_dirs_and_files_icons(args)
|
add_dirs_and_files_icons(args)
|
||||||
end
|
end
|
||||||
|
@ -10,9 +10,9 @@ local pairs = pairs
|
|||||||
module("freedesktop.menu")
|
module("freedesktop.menu")
|
||||||
|
|
||||||
all_menu_dirs = {
|
all_menu_dirs = {
|
||||||
'/usr/share/applications/',
|
'/usr/share/applications/',
|
||||||
'/usr/local/share/applications/',
|
'/usr/local/share/applications/',
|
||||||
'~/.local/share/applications/'
|
'~/.local/share/applications/'
|
||||||
}
|
}
|
||||||
|
|
||||||
show_generic_name = false
|
show_generic_name = false
|
||||||
@ -21,77 +21,77 @@ show_generic_name = false
|
|||||||
-- @param menu_dirs A list of application directories (optional).
|
-- @param menu_dirs A list of application directories (optional).
|
||||||
-- @return A prepared menu w/ categories
|
-- @return A prepared menu w/ categories
|
||||||
function new(arg)
|
function new(arg)
|
||||||
-- the categories and their synonyms where shamelessly copied from lxpanel
|
-- the categories and their synonyms where shamelessly copied from lxpanel
|
||||||
-- source code.
|
-- source code.
|
||||||
local programs = {}
|
local programs = {}
|
||||||
local config = arg or {}
|
local config = arg or {}
|
||||||
|
|
||||||
programs['AudioVideo'] = {}
|
programs['AudioVideo'] = {}
|
||||||
programs['Development'] = {}
|
programs['Development'] = {}
|
||||||
programs['Education'] = {}
|
programs['Education'] = {}
|
||||||
programs['Game'] = {}
|
programs['Game'] = {}
|
||||||
programs['Graphics'] = {}
|
programs['Graphics'] = {}
|
||||||
programs['Network'] = {}
|
programs['Network'] = {}
|
||||||
programs['Office'] = {}
|
programs['Office'] = {}
|
||||||
programs['Settings'] = {}
|
programs['Settings'] = {}
|
||||||
programs['System'] = {}
|
programs['System'] = {}
|
||||||
programs['Utility'] = {}
|
programs['Utility'] = {}
|
||||||
programs['Other'] = {}
|
programs['Other'] = {}
|
||||||
|
|
||||||
for i, dir in ipairs(config.menu_dirs or all_menu_dirs) do
|
for i, dir in ipairs(config.menu_dirs or all_menu_dirs) do
|
||||||
local entries = utils.parse_desktop_files({dir = dir})
|
local entries = utils.parse_desktop_files({dir = dir})
|
||||||
for j, program in ipairs(entries) do
|
for j, program in ipairs(entries) do
|
||||||
-- check whether to include in the menu
|
-- check whether to include in the menu
|
||||||
if program.show and program.Name and program.cmdline then
|
if program.show and program.Name and program.cmdline then
|
||||||
if show_generic_name and program.GenericName then
|
if show_generic_name and program.GenericName then
|
||||||
program.Name = program.Name .. ' (' .. program.GenericName .. ')'
|
program.Name = program.Name .. ' (' .. program.GenericName .. ')'
|
||||||
end
|
end
|
||||||
local target_category = nil
|
local target_category = nil
|
||||||
if program.categories then
|
if program.categories then
|
||||||
for _, category in ipairs(program.categories) do
|
for _, category in ipairs(program.categories) do
|
||||||
if programs[category] then
|
if programs[category] then
|
||||||
target_category = category
|
target_category = category
|
||||||
break
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not target_category then
|
||||||
|
target_category = 'Other'
|
||||||
|
end
|
||||||
|
if target_category then
|
||||||
|
table.insert(programs[target_category], { program.Name, program.cmdline, program.icon_path })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if not target_category then
|
|
||||||
target_category = 'Other'
|
|
||||||
end
|
|
||||||
if target_category then
|
|
||||||
table.insert(programs[target_category], { program.Name, program.cmdline, program.icon_path })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- sort each submenu alphabetically case insensitive
|
-- sort each submenu alphabetically case insensitive
|
||||||
for k, v in pairs(programs) do
|
for k, v in pairs(programs) do
|
||||||
table.sort(v, function(a, b) return a[1]:lower() < b[1]:lower() end)
|
table.sort(v, function(a, b) return a[1]:lower() < b[1]:lower() end)
|
||||||
end
|
|
||||||
|
|
||||||
local menu = {
|
|
||||||
{ "Accessories", programs["Utility"], utils.lookup_icon({ icon = 'applications-accessories.png' }) },
|
|
||||||
{ "Development", programs["Development"], utils.lookup_icon({ icon = 'applications-development.png' }) },
|
|
||||||
{ "Education", programs["Education"], utils.lookup_icon({ icon = 'applications-science.png' }) },
|
|
||||||
{ "Games", programs["Game"], utils.lookup_icon({ icon = 'applications-games.png' }) },
|
|
||||||
{ "Graphics", programs["Graphics"], utils.lookup_icon({ icon = 'applications-graphics.png' }) },
|
|
||||||
{ "Internet", programs["Network"], utils.lookup_icon({ icon = 'applications-internet.png' }) },
|
|
||||||
{ "Multimedia", programs["AudioVideo"], utils.lookup_icon({ icon = 'applications-multimedia.png' }) },
|
|
||||||
{ "Office", programs["Office"], utils.lookup_icon({ icon = 'applications-office.png' }) },
|
|
||||||
{ "Other", programs["Other"], utils.lookup_icon({ icon = 'applications-other.png' }) },
|
|
||||||
{ "Settings", programs["Settings"], utils.lookup_icon({ icon = 'preferences-desktop.png' }) },
|
|
||||||
{ "System Tools", programs["System"], utils.lookup_icon({ icon = 'applications-system.png' }) },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Removing empty entries from menu
|
|
||||||
local cleanedMenu = {}
|
|
||||||
for index, item in ipairs(menu) do
|
|
||||||
itemTester = item[2]
|
|
||||||
if itemTester[1] then
|
|
||||||
table.insert(cleanedMenu, item)
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return cleanedMenu
|
local menu = {
|
||||||
|
{ "Accessories", programs["Utility"], utils.lookup_icon({ icon = 'applications-accessories.png' }) },
|
||||||
|
{ "Development", programs["Development"], utils.lookup_icon({ icon = 'applications-development.png' }) },
|
||||||
|
{ "Education", programs["Education"], utils.lookup_icon({ icon = 'applications-science.png' }) },
|
||||||
|
{ "Games", programs["Game"], utils.lookup_icon({ icon = 'applications-games.png' }) },
|
||||||
|
{ "Graphics", programs["Graphics"], utils.lookup_icon({ icon = 'applications-graphics.png' }) },
|
||||||
|
{ "Internet", programs["Network"], utils.lookup_icon({ icon = 'applications-internet.png' }) },
|
||||||
|
{ "Multimedia", programs["AudioVideo"], utils.lookup_icon({ icon = 'applications-multimedia.png' }) },
|
||||||
|
{ "Office", programs["Office"], utils.lookup_icon({ icon = 'applications-office.png' }) },
|
||||||
|
{ "Other", programs["Other"], utils.lookup_icon({ icon = 'applications-other.png' }) },
|
||||||
|
{ "Settings", programs["Settings"], utils.lookup_icon({ icon = 'preferences-desktop.png' }) },
|
||||||
|
{ "System Tools", programs["System"], utils.lookup_icon({ icon = 'applications-system.png' }) },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Removing empty entries from menu
|
||||||
|
local cleanedMenu = {}
|
||||||
|
for index, item in ipairs(menu) do
|
||||||
|
itemTester = item[2]
|
||||||
|
if itemTester[1] then
|
||||||
|
table.insert(cleanedMenu, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return cleanedMenu
|
||||||
end
|
end
|
||||||
|
@ -14,25 +14,25 @@ terminal = 'termite'
|
|||||||
icon_theme = nil
|
icon_theme = nil
|
||||||
|
|
||||||
all_icon_sizes = {
|
all_icon_sizes = {
|
||||||
'128x128',
|
'128x128',
|
||||||
'96x96',
|
'96x96',
|
||||||
'72x72',
|
'72x72',
|
||||||
'64x64',
|
'64x64',
|
||||||
'48x48',
|
'48x48',
|
||||||
'36x36',
|
'36x36',
|
||||||
'32x32',
|
'32x32',
|
||||||
'24x24',
|
'24x24',
|
||||||
'22x22',
|
'22x22',
|
||||||
'16x16'
|
'16x16'
|
||||||
}
|
}
|
||||||
all_icon_types = {
|
all_icon_types = {
|
||||||
'apps',
|
'apps',
|
||||||
'actions',
|
'actions',
|
||||||
'devices',
|
'devices',
|
||||||
'places',
|
'places',
|
||||||
'categories',
|
'categories',
|
||||||
'status',
|
'status',
|
||||||
'mimetypes'
|
'mimetypes'
|
||||||
}
|
}
|
||||||
all_icon_paths = { os.getenv("HOME") .. '/.icons/', '/usr/share/icons/' }
|
all_icon_paths = { os.getenv("HOME") .. '/.icons/', '/usr/share/icons/' }
|
||||||
|
|
||||||
@ -41,118 +41,118 @@ icon_sizes = {}
|
|||||||
local mime_types = {}
|
local mime_types = {}
|
||||||
|
|
||||||
function get_lines(...)
|
function get_lines(...)
|
||||||
local f = io.popen(...)
|
local f = io.popen(...)
|
||||||
return function () -- iterator
|
return function () -- iterator
|
||||||
local data = f:read()
|
local data = f:read()
|
||||||
if data == nil then f:close() end
|
if data == nil then f:close() end
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function file_exists(filename)
|
function file_exists(filename)
|
||||||
local file = io.open(filename, 'r')
|
local file = io.open(filename, 'r')
|
||||||
local result = (file ~= nil)
|
local result = (file ~= nil)
|
||||||
if result then
|
if result then
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function lookup_icon(arg)
|
function lookup_icon(arg)
|
||||||
if arg.icon:sub(1, 1) == '/' and (arg.icon:find('.+%.png') or arg.icon:find('.+%.xpm')) then
|
if arg.icon:sub(1, 1) == '/' and (arg.icon:find('.+%.png') or arg.icon:find('.+%.xpm')) then
|
||||||
-- icons with absolute path and supported (AFAICT) formats
|
-- icons with absolute path and supported (AFAICT) formats
|
||||||
return arg.icon
|
return arg.icon
|
||||||
else
|
else
|
||||||
local icon_path = {}
|
local icon_path = {}
|
||||||
local icon_themes = {}
|
local icon_themes = {}
|
||||||
local icon_theme_paths = {}
|
local icon_theme_paths = {}
|
||||||
if icon_theme and type(icon_theme) == 'table' then
|
if icon_theme and type(icon_theme) == 'table' then
|
||||||
icon_themes = icon_theme
|
icon_themes = icon_theme
|
||||||
elseif icon_theme then
|
elseif icon_theme then
|
||||||
icon_themes = { icon_theme }
|
icon_themes = { icon_theme }
|
||||||
end
|
|
||||||
for i, theme in ipairs(icon_themes) do
|
|
||||||
for j, path in ipairs(all_icon_paths) do
|
|
||||||
table.insert(icon_theme_paths, path .. theme .. '/')
|
|
||||||
end
|
|
||||||
-- TODO also look in parent icon themes, as in freedesktop.org specification
|
|
||||||
end
|
|
||||||
table.insert(icon_theme_paths, '/usr/share/icons/hicolor/') -- fallback theme cf spec
|
|
||||||
|
|
||||||
local isizes = icon_sizes
|
|
||||||
for i, sz in ipairs(all_icon_sizes) do
|
|
||||||
table.insert(isizes, sz)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
|
||||||
for j, size in ipairs(arg.icon_sizes or isizes) do
|
|
||||||
for k, icon_type in ipairs(all_icon_types) do
|
|
||||||
table.insert(icon_path, icon_theme_directory .. size .. '/' .. icon_type .. '/')
|
|
||||||
end
|
end
|
||||||
end
|
for i, theme in ipairs(icon_themes) do
|
||||||
end
|
for j, path in ipairs(all_icon_paths) do
|
||||||
-- lowest priority fallbacks
|
table.insert(icon_theme_paths, path .. theme .. '/')
|
||||||
table.insert(icon_path, '/usr/share/pixmaps/')
|
end
|
||||||
table.insert(icon_path, '/usr/share/icons/')
|
-- TODO also look in parent icon themes, as in freedesktop.org specification
|
||||||
table.insert(icon_path, '/usr/share/app-install/icons/')
|
end
|
||||||
|
table.insert(icon_theme_paths, '/usr/share/icons/hicolor/') -- fallback theme cf spec
|
||||||
|
|
||||||
for i, directory in ipairs(icon_path) do
|
local isizes = icon_sizes
|
||||||
if (arg.icon:find('.+%.png') or arg.icon:find('.+%.xpm')) and file_exists(directory .. arg.icon) then
|
for i, sz in ipairs(all_icon_sizes) do
|
||||||
return directory .. arg.icon
|
table.insert(isizes, sz)
|
||||||
elseif file_exists(directory .. arg.icon .. '.png') then
|
end
|
||||||
return directory .. arg.icon .. '.png'
|
|
||||||
elseif file_exists(directory .. arg.icon .. '.xpm') then
|
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||||
return directory .. arg.icon .. '.xpm'
|
for j, size in ipairs(arg.icon_sizes or isizes) do
|
||||||
end
|
for k, icon_type in ipairs(all_icon_types) do
|
||||||
|
table.insert(icon_path, icon_theme_directory .. size .. '/' .. icon_type .. '/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- lowest priority fallbacks
|
||||||
|
table.insert(icon_path, '/usr/share/pixmaps/')
|
||||||
|
table.insert(icon_path, '/usr/share/icons/')
|
||||||
|
table.insert(icon_path, '/usr/share/app-install/icons/')
|
||||||
|
|
||||||
|
for i, directory in ipairs(icon_path) do
|
||||||
|
if (arg.icon:find('.+%.png') or arg.icon:find('.+%.xpm')) and file_exists(directory .. arg.icon) then
|
||||||
|
return directory .. arg.icon
|
||||||
|
elseif file_exists(directory .. arg.icon .. '.png') then
|
||||||
|
return directory .. arg.icon .. '.png'
|
||||||
|
elseif file_exists(directory .. arg.icon .. '.xpm') then
|
||||||
|
return directory .. arg.icon .. '.xpm'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function lookup_file_icon(arg)
|
function lookup_file_icon(arg)
|
||||||
load_mime_types()
|
load_mime_types()
|
||||||
|
|
||||||
local extension = arg.filename:match('%a+$')
|
local extension = arg.filename:match('%a+$')
|
||||||
local mime = mime_types[extension] or ''
|
local mime = mime_types[extension] or ''
|
||||||
local mime_family = mime:match('^%a+') or ''
|
local mime_family = mime:match('^%a+') or ''
|
||||||
|
|
||||||
-- possible icons in a typical gnome theme (i.e. Tango icons)
|
-- possible icons in a typical gnome theme (i.e. Tango icons)
|
||||||
local possible_filenames = {
|
local possible_filenames = {
|
||||||
mime,
|
mime,
|
||||||
'gnome-mime-' .. mime,
|
'gnome-mime-' .. mime,
|
||||||
mime_family,
|
mime_family,
|
||||||
'gnome-mime-' .. mime_family,
|
'gnome-mime-' .. mime_family,
|
||||||
extension
|
extension
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, filename in ipairs(possible_filenames) do
|
for i, filename in ipairs(possible_filenames) do
|
||||||
local icon = lookup_icon({icon = filename, icon_sizes = (arg.icon_sizes or all_icon_sizes)})
|
local icon = lookup_icon({icon = filename, icon_sizes = (arg.icon_sizes or all_icon_sizes)})
|
||||||
if icon then
|
if icon then
|
||||||
return icon
|
return icon
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- If we don't find ad icon, then pretend is a plain text file
|
-- If we don't find ad icon, then pretend is a plain text file
|
||||||
return lookup_icon({ icon = 'txt', icon_sizes = arg.icon_sizes or all_icon_sizes })
|
return lookup_icon({ icon = 'txt', icon_sizes = arg.icon_sizes or all_icon_sizes })
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Load system MIME types
|
--- Load system MIME types
|
||||||
-- @return A table with file extension <--> MIME type mapping
|
-- @return A table with file extension <--> MIME type mapping
|
||||||
function load_mime_types()
|
function load_mime_types()
|
||||||
if #mime_types == 0 then
|
if #mime_types == 0 then
|
||||||
for line in io.lines('/etc/mime.types') do
|
for line in io.lines('/etc/mime.types') do
|
||||||
if not line:find('^#') then
|
if not line:find('^#') then
|
||||||
local parsed = {}
|
local parsed = {}
|
||||||
for w in line:gmatch('[^%s]+') do
|
for w in line:gmatch('[^%s]+') do
|
||||||
table.insert(parsed, w)
|
table.insert(parsed, w)
|
||||||
|
end
|
||||||
|
if #parsed > 1 then
|
||||||
|
for i = 2, #parsed do
|
||||||
|
mime_types[parsed[i]] = parsed[1]:gsub('/', '-')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if #parsed > 1 then
|
|
||||||
for i = 2, #parsed do
|
|
||||||
mime_types[parsed[i]] = parsed[1]:gsub('/', '-')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Parse a .desktop file
|
--- Parse a .desktop file
|
||||||
@ -160,52 +160,52 @@ end
|
|||||||
-- @param requested_icon_sizes A list of icon sizes (optional). If this list is given, it will be used as a priority list for icon sizes when looking up for icons. If you want large icons, for example, you can put '128x128' as the first item in the list.
|
-- @param requested_icon_sizes A list of icon sizes (optional). If this list is given, it will be used as a priority list for icon sizes when looking up for icons. If you want large icons, for example, you can put '128x128' as the first item in the list.
|
||||||
-- @return A table with file entries.
|
-- @return A table with file entries.
|
||||||
function parse_desktop_file(arg)
|
function parse_desktop_file(arg)
|
||||||
local program = { show = true, file = arg.file }
|
local program = { show = true, file = arg.file }
|
||||||
for line in io.lines(arg.file) do
|
for line in io.lines(arg.file) do
|
||||||
for key, value in line:gmatch("(%w+)=(.+)") do
|
for key, value in line:gmatch("(%w+)=(.+)") do
|
||||||
program[key] = value
|
program[key] = value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Don't show the program if NoDisplay is true
|
-- Don't show the program if NoDisplay is true
|
||||||
-- Only show the program if there is not OnlyShowIn attribute
|
-- Only show the program if there is not OnlyShowIn attribute
|
||||||
-- or if it's equal to 'awesome'
|
-- or if it's equal to 'awesome'
|
||||||
if program.NoDisplay == "true" or program.OnlyShowIn ~= nil and program.OnlyShowIn ~= "awesome" then
|
if program.NoDisplay == "true" or program.OnlyShowIn ~= nil and program.OnlyShowIn ~= "awesome" then
|
||||||
program.show = false
|
program.show = false
|
||||||
end
|
|
||||||
|
|
||||||
-- Look up for a icon.
|
|
||||||
if program.Icon then
|
|
||||||
program.icon_path = lookup_icon({ icon = program.Icon, icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
|
||||||
if program.icon_path ~= nil and not file_exists(program.icon_path) then
|
|
||||||
program.icon_path = nil
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Split categories into a table.
|
-- Look up for a icon.
|
||||||
if program.Categories then
|
if program.Icon then
|
||||||
program.categories = {}
|
program.icon_path = lookup_icon({ icon = program.Icon, icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
||||||
for category in program.Categories:gmatch('[^;]+') do
|
if program.icon_path ~= nil and not file_exists(program.icon_path) then
|
||||||
table.insert(program.categories, category)
|
program.icon_path = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if program.Exec then
|
-- Split categories into a table.
|
||||||
local cmdline = program.Exec:gsub('%%c', program.Name)
|
if program.Categories then
|
||||||
cmdline = cmdline:gsub('%%[fmuFMU]', '')
|
program.categories = {}
|
||||||
cmdline = cmdline:gsub('%%k', program.file)
|
for category in program.Categories:gmatch('[^;]+') do
|
||||||
if program.icon_path then
|
table.insert(program.categories, category)
|
||||||
cmdline = cmdline:gsub('%%i', '--icon ' .. program.icon_path)
|
end
|
||||||
else
|
|
||||||
cmdline = cmdline:gsub('%%i', '')
|
|
||||||
end
|
end
|
||||||
if program.Terminal == "true" then
|
|
||||||
cmdline = terminal .. ' -e ' .. cmdline
|
|
||||||
end
|
|
||||||
program.cmdline = cmdline
|
|
||||||
end
|
|
||||||
|
|
||||||
return program
|
if program.Exec then
|
||||||
|
local cmdline = program.Exec:gsub('%%c', program.Name)
|
||||||
|
cmdline = cmdline:gsub('%%[fmuFMU]', '')
|
||||||
|
cmdline = cmdline:gsub('%%k', program.file)
|
||||||
|
if program.icon_path then
|
||||||
|
cmdline = cmdline:gsub('%%i', '--icon ' .. program.icon_path)
|
||||||
|
else
|
||||||
|
cmdline = cmdline:gsub('%%i', '')
|
||||||
|
end
|
||||||
|
if program.Terminal == "true" then
|
||||||
|
cmdline = terminal .. ' -e ' .. cmdline
|
||||||
|
end
|
||||||
|
program.cmdline = cmdline
|
||||||
|
end
|
||||||
|
|
||||||
|
return program
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Parse a directory with .desktop files
|
--- Parse a directory with .desktop files
|
||||||
@ -213,13 +213,13 @@ end
|
|||||||
-- @param icons_size, The icons sizes, optional.
|
-- @param icons_size, The icons sizes, optional.
|
||||||
-- @return A table with all .desktop entries.
|
-- @return A table with all .desktop entries.
|
||||||
function parse_desktop_files(arg)
|
function parse_desktop_files(arg)
|
||||||
local programs = {}
|
local programs = {}
|
||||||
local files = get_lines('find '.. arg.dir ..' -name "*.desktop" 2>/dev/null')
|
local files = get_lines('find '.. arg.dir ..' -name "*.desktop" 2>/dev/null')
|
||||||
for file in files do
|
for file in files do
|
||||||
arg.file = file
|
arg.file = file
|
||||||
table.insert(programs, parse_desktop_file(arg))
|
table.insert(programs, parse_desktop_file(arg))
|
||||||
end
|
end
|
||||||
return programs
|
return programs
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Parse a directory files and subdirs
|
--- Parse a directory files and subdirs
|
||||||
@ -227,28 +227,28 @@ end
|
|||||||
-- @param icons_size, The icons sizes, optional.
|
-- @param icons_size, The icons sizes, optional.
|
||||||
-- @return A table with all .desktop entries.
|
-- @return A table with all .desktop entries.
|
||||||
function parse_dirs_and_files(arg)
|
function parse_dirs_and_files(arg)
|
||||||
local files = {}
|
local files = {}
|
||||||
local paths = get_lines('find '..arg.dir..' -maxdepth 1 -type d')
|
local paths = get_lines('find '..arg.dir..' -maxdepth 1 -type d')
|
||||||
for path in paths do
|
for path in paths do
|
||||||
if path:match("[^/]+$") then
|
if path:match("[^/]+$") then
|
||||||
local file = {}
|
local file = {}
|
||||||
file.filename = path:match("[^/]+$")
|
file.filename = path:match("[^/]+$")
|
||||||
file.path = path
|
file.path = path
|
||||||
file.show = true
|
file.show = true
|
||||||
file.icon = lookup_icon({ icon = "folder", icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
file.icon = lookup_icon({ icon = "folder", icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
||||||
table.insert(files, file)
|
table.insert(files, file)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
local paths = get_lines('find '..arg.dir..' -maxdepth 1 -type f')
|
||||||
local paths = get_lines('find '..arg.dir..' -maxdepth 1 -type f')
|
for path in paths do
|
||||||
for path in paths do
|
if not path:find("%.desktop$") then
|
||||||
if not path:find("%.desktop$") then
|
local file = {}
|
||||||
local file = {}
|
file.filename = path:match("[^/]+$")
|
||||||
file.filename = path:match("[^/]+$")
|
file.path = path
|
||||||
file.path = path
|
file.show = true
|
||||||
file.show = true
|
file.icon = lookup_file_icon({ filename = file.filename, icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
||||||
file.icon = lookup_file_icon({ filename = file.filename, icon_sizes = (arg.icon_sizes or all_icon_sizes) })
|
table.insert(files, file)
|
||||||
table.insert(files, file)
|
end
|
||||||
end
|
end
|
||||||
end
|
return files
|
||||||
return files
|
|
||||||
end
|
end
|
||||||
|
@ -27,24 +27,24 @@ local wi = require("wi")
|
|||||||
-- Check if awesome encountered an error during startup and fell back to
|
-- Check if awesome encountered an error during startup and fell back to
|
||||||
-- another config (This code will only ever execute for the fallback config)
|
-- another config (This code will only ever execute for the fallback config)
|
||||||
if awesome.startup_errors then
|
if awesome.startup_errors then
|
||||||
naughty.notify({ preset = naughty.config.presets.critical,
|
naughty.notify({ preset = naughty.config.presets.critical,
|
||||||
title = "Oops, there were errors during startup!",
|
title = "Oops, there were errors during startup!",
|
||||||
text = awesome.startup_errors })
|
text = awesome.startup_errors })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle runtime errors after startup
|
-- Handle runtime errors after startup
|
||||||
do
|
do
|
||||||
local in_error = false
|
local in_error = false
|
||||||
awesome.connect_signal("debug::error", function (err)
|
awesome.connect_signal("debug::error", function (err)
|
||||||
-- Make sure we don't go into an endless error loop
|
-- Make sure we don't go into an endless error loop
|
||||||
if in_error then return end
|
if in_error then return end
|
||||||
in_error = true
|
in_error = true
|
||||||
|
|
||||||
naughty.notify({ preset = naughty.config.presets.critical,
|
naughty.notify({ preset = naughty.config.presets.critical,
|
||||||
title = "Oops, an error happened!",
|
title = "Oops, an error happened!",
|
||||||
text = err })
|
text = err })
|
||||||
in_error = false
|
in_error = false
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ end
|
|||||||
terminal = "termite"
|
terminal = "termite"
|
||||||
editor = os.getenv("EDITOR") or "vim"
|
editor = os.getenv("EDITOR") or "vim"
|
||||||
editor_cmd = terminal .. " -e " .. editor
|
editor_cmd = terminal .. " -e " .. editor
|
||||||
rmenu = "rofi-gorice"
|
rmenu = "rofr.sh"
|
||||||
browser = "firefox"
|
browser = "firefox"
|
||||||
filemgr = "thunar"
|
filemgr = "thunar"
|
||||||
txteditor = "geany"
|
txteditor = "geany"
|
||||||
@ -70,7 +70,7 @@ modkey = "Mod4"
|
|||||||
|
|
||||||
-- Table of layouts to cover with awful.layout.inc, order matters.
|
-- Table of layouts to cover with awful.layout.inc, order matters.
|
||||||
local layouts =
|
local layouts =
|
||||||
{
|
{
|
||||||
awful.layout.suit.floating,
|
awful.layout.suit.floating,
|
||||||
awful.layout.suit.tile,
|
awful.layout.suit.tile,
|
||||||
awful.layout.suit.tile.left,
|
awful.layout.suit.tile.left,
|
||||||
@ -83,7 +83,7 @@ local layouts =
|
|||||||
awful.layout.suit.max,
|
awful.layout.suit.max,
|
||||||
awful.layout.suit.max.fullscreen,
|
awful.layout.suit.max.fullscreen,
|
||||||
awful.layout.suit.magnifier
|
awful.layout.suit.magnifier
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Naughty presets
|
-- {{{ Naughty presets
|
||||||
@ -105,41 +105,41 @@ naughty.config.defaults.hover_timeout = nil
|
|||||||
|
|
||||||
-- {{{ Wallpaper
|
-- {{{ Wallpaper
|
||||||
if beautiful.wallpaper then
|
if beautiful.wallpaper then
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
|
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Tags
|
-- {{{ Tags
|
||||||
-- Define a tag table which hold all screen tags.
|
-- Define a tag table which hold all screen tags.
|
||||||
tags = {
|
tags = {
|
||||||
names = {
|
names = {
|
||||||
':1',
|
':1',
|
||||||
':2',
|
':2',
|
||||||
':3',
|
':3',
|
||||||
':4',
|
':4',
|
||||||
':5',
|
':5',
|
||||||
':6',
|
':6',
|
||||||
':7',
|
':7',
|
||||||
':8',
|
':8',
|
||||||
':9',
|
':9',
|
||||||
},
|
},
|
||||||
layout = {
|
layout = {
|
||||||
layouts[5], -- 1:1
|
layouts[5], -- 1:1
|
||||||
layouts[10], -- 2:2
|
layouts[10], -- 2:2
|
||||||
layouts[10], -- 3:3
|
layouts[10], -- 3:3
|
||||||
layouts[12], -- 4:4
|
layouts[12], -- 4:4
|
||||||
layouts[2], -- 5:5
|
layouts[2], -- 5:5
|
||||||
layouts[10], -- 6:6
|
layouts[10], -- 6:6
|
||||||
layouts[10], -- 7:7
|
layouts[10], -- 7:7
|
||||||
layouts[2], -- 8:8
|
layouts[2], -- 8:8
|
||||||
layouts[10], -- 9:9
|
layouts[10], -- 9:9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
-- Each screen has its own tag table.
|
-- Each screen has its own tag table.
|
||||||
tags[s] = awful.tag(tags.names, s, tags.layout)
|
tags[s] = awful.tag(tags.names, s, tags.layout)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -147,16 +147,16 @@ end
|
|||||||
-- menu icon menu pdq 07-02-2012
|
-- menu icon menu pdq 07-02-2012
|
||||||
local wallmenu = {}
|
local wallmenu = {}
|
||||||
local function wall_load(wall)
|
local function wall_load(wall)
|
||||||
local f = io.popen('ln -sfn ' .. '/usr/share/backgrounds/archlabs/' .. wall .. ' ' .. home_path .. '.config/awesome/themes/default/bg.png')
|
local f = io.popen('ln -sfn ' .. '/usr/share/backgrounds/archlabs/' .. wall .. ' ' .. home_path .. '.config/awesome/themes/default/bg.png')
|
||||||
awesome.restart()
|
awesome.restart()
|
||||||
end
|
end
|
||||||
local function wall_menu()
|
local function wall_menu()
|
||||||
local f = io.popen('ls -1 ' .. '/usr/share/backgrounds/archlabs/')
|
local f = io.popen('ls -1 ' .. '/usr/share/backgrounds/archlabs/')
|
||||||
for l in f:lines() do
|
for l in f:lines() do
|
||||||
local item = { l, function () wall_load(l) end }
|
local item = { l, function () wall_load(l) end }
|
||||||
table.insert(wallmenu, item)
|
table.insert(wallmenu, item)
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
wall_menu()
|
wall_menu()
|
||||||
|
|
||||||
@ -179,8 +179,8 @@ vicious.register(batt, vicious.widgets.bat, "Batt: $2% Rem: $3", 61, "BAT1")
|
|||||||
|
|
||||||
menu_items = freedesktop.menu.new()
|
menu_items = freedesktop.menu.new()
|
||||||
myawesomemenu = {
|
myawesomemenu = {
|
||||||
{ "manual", terminal .. " -e man awesome", freedesktop.utils.lookup_icon({ icon = 'help' }) },
|
{ "manual", terminal .. " -e man awesome", freedesktop.utils.lookup_icon({ icon = 'help' }) },
|
||||||
{ "restart", awesome.restart, freedesktop.utils.lookup_icon({ icon = 'system-shutdown' }) },
|
{ "restart", awesome.restart, freedesktop.utils.lookup_icon({ icon = 'system-shutdown' }) },
|
||||||
}
|
}
|
||||||
-- { "quit", awesome.quit, freedesktop.utils.lookup_icon({ icon = 'system-shutdown' }) }
|
-- { "quit", awesome.quit, freedesktop.utils.lookup_icon({ icon = 'system-shutdown' }) }
|
||||||
|
|
||||||
@ -205,251 +205,251 @@ mypromptbox = {}
|
|||||||
mylayoutbox = {}
|
mylayoutbox = {}
|
||||||
mytaglist = {}
|
mytaglist = {}
|
||||||
mytaglist.buttons = awful.util.table.join(
|
mytaglist.buttons = awful.util.table.join(
|
||||||
awful.button({ }, 1, awful.tag.viewonly),
|
awful.button({ }, 1, awful.tag.viewonly),
|
||||||
awful.button({ modkey }, 1, awful.client.movetotag),
|
awful.button({ modkey }, 1, awful.client.movetotag),
|
||||||
awful.button({ }, 3, awful.tag.viewtoggle),
|
awful.button({ }, 3, awful.tag.viewtoggle),
|
||||||
awful.button({ modkey }, 3, awful.client.toggletag),
|
awful.button({ modkey }, 3, awful.client.toggletag),
|
||||||
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
|
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)
|
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
|
||||||
)
|
)
|
||||||
mytasklist = {}
|
mytasklist = {}
|
||||||
mytasklist.buttons = awful.util.table.join(
|
mytasklist.buttons = awful.util.table.join(
|
||||||
awful.button({ }, 1, function (c)
|
awful.button({ }, 1, function (c)
|
||||||
if c == client.focus then
|
if c == client.focus then
|
||||||
c.minimized = true
|
c.minimized = true
|
||||||
else
|
else
|
||||||
-- Without this, the following
|
-- Without this, the following
|
||||||
-- :isvisible() makes no sense
|
-- :isvisible() makes no sense
|
||||||
c.minimized = false
|
c.minimized = false
|
||||||
if not c:isvisible() then
|
if not c:isvisible() then
|
||||||
awful.tag.viewonly(c:tags()[1])
|
awful.tag.viewonly(c:tags()[1])
|
||||||
end
|
end
|
||||||
-- This will also un-minimize
|
-- This will also un-minimize
|
||||||
-- the client, if needed
|
-- the client, if needed
|
||||||
client.focus = c
|
client.focus = c
|
||||||
c:raise()
|
c:raise()
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 3, function ()
|
awful.button({ }, 3, function ()
|
||||||
if instance then
|
if instance then
|
||||||
instance:hide()
|
instance:hide()
|
||||||
instance = nil
|
instance = nil
|
||||||
else
|
else
|
||||||
instance = awful.menu.clients({ width=200 })
|
instance = awful.menu.clients({ width=200 })
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 4, function ()
|
awful.button({ }, 4, function ()
|
||||||
awful.client.focus.byidx(1)
|
awful.client.focus.byidx(1)
|
||||||
if client.focus then client.focus:raise() end
|
if client.focus then client.focus:raise() end
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 5, function ()
|
awful.button({ }, 5, function ()
|
||||||
awful.client.focus.byidx(-1)
|
awful.client.focus.byidx(-1)
|
||||||
if client.focus then client.focus:raise() end
|
if client.focus then client.focus:raise() end
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
-- Create a promptbox for each screen
|
-- Create a promptbox for each screen
|
||||||
mypromptbox[s] = awful.widget.prompt()
|
mypromptbox[s] = awful.widget.prompt()
|
||||||
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
||||||
-- We need one layoutbox per screen.
|
-- We need one layoutbox per screen.
|
||||||
mylayoutbox[s] = awful.widget.layoutbox(s)
|
mylayoutbox[s] = awful.widget.layoutbox(s)
|
||||||
mylayoutbox[s]:buttons(awful.util.table.join(
|
mylayoutbox[s]:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
|
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
|
||||||
awful.button({ }, 3, 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({ }, 4, function () awful.layout.inc(layouts, 1) end),
|
||||||
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
|
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
|
||||||
-- Create a taglist widget
|
-- Create a taglist widget
|
||||||
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
|
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
|
||||||
|
|
||||||
-- Create a tasklist widget
|
-- Create a tasklist widget
|
||||||
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
|
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
|
||||||
|
|
||||||
-- Create the wibox
|
-- Create the wibox
|
||||||
mywibox[s] = awful.wibox({ position = "top", screen = s })
|
mywibox[s] = awful.wibox({ position = "top", screen = s })
|
||||||
|
|
||||||
-- Widgets that are aligned to the left
|
-- Widgets that are aligned to the left
|
||||||
local left_layout = wibox.layout.fixed.horizontal()
|
local left_layout = wibox.layout.fixed.horizontal()
|
||||||
left_layout:add(mylauncher)
|
left_layout:add(mylauncher)
|
||||||
left_layout:add(mytaglist[s])
|
left_layout:add(mytaglist[s])
|
||||||
left_layout:add(mypromptbox[s])
|
left_layout:add(mypromptbox[s])
|
||||||
|
|
||||||
-- Widgets that are aligned to the right
|
-- Widgets that are aligned to the right
|
||||||
local right_layout = wibox.layout.fixed.horizontal()
|
local right_layout = wibox.layout.fixed.horizontal()
|
||||||
if s == 1 then right_layout:add(wibox.widget.systray()) end
|
if s == 1 then right_layout:add(wibox.widget.systray()) end
|
||||||
right_layout:add(spacer)
|
right_layout:add(spacer)
|
||||||
right_layout:add(spacer)
|
right_layout:add(spacer)
|
||||||
right_layout:add(baticon)
|
right_layout:add(baticon)
|
||||||
right_layout:add(batpct)
|
right_layout:add(batpct)
|
||||||
right_layout:add(spacer)
|
right_layout:add(spacer)
|
||||||
right_layout:add(pacicon)
|
right_layout:add(pacicon)
|
||||||
right_layout:add(pacwidget)
|
right_layout:add(pacwidget)
|
||||||
right_layout:add(spacer)
|
right_layout:add(spacer)
|
||||||
right_layout:add(volicon)
|
right_layout:add(volicon)
|
||||||
right_layout:add(volpct)
|
right_layout:add(volpct)
|
||||||
right_layout:add(volspace)
|
right_layout:add(volspace)
|
||||||
right_layout:add(spacer)
|
right_layout:add(spacer)
|
||||||
right_layout:add(mytextclock)
|
right_layout:add(mytextclock)
|
||||||
right_layout:add(mylayoutbox[s])
|
right_layout:add(mylayoutbox[s])
|
||||||
|
|
||||||
-- Now bring it all together (with the tasklist in the middle)
|
-- Now bring it all together (with the tasklist in the middle)
|
||||||
local layout = wibox.layout.align.horizontal()
|
local layout = wibox.layout.align.horizontal()
|
||||||
layout:set_left(left_layout)
|
layout:set_left(left_layout)
|
||||||
layout:set_middle(mytasklist[s])
|
layout:set_middle(mytasklist[s])
|
||||||
layout:set_right(right_layout)
|
layout:set_right(right_layout)
|
||||||
|
|
||||||
mywibox[s]:set_widget(layout)
|
mywibox[s]:set_widget(layout)
|
||||||
|
|
||||||
-- Create the bottom wibox
|
-- Create the bottom wibox
|
||||||
myinfowibox[s] = awful.wibox({ position = "bottom", screen = s })
|
myinfowibox[s] = awful.wibox({ position = "bottom", screen = s })
|
||||||
-- Widgets that are aligned to the bottom
|
-- Widgets that are aligned to the bottom
|
||||||
local bottom_layout = wibox.layout.fixed.horizontal()
|
local bottom_layout = wibox.layout.fixed.horizontal()
|
||||||
bottom_layout:add(cpuicon)
|
bottom_layout:add(cpuicon)
|
||||||
bottom_layout:add(cpu)
|
bottom_layout:add(cpu)
|
||||||
bottom_layout:add(spacer)
|
bottom_layout:add(spacer)
|
||||||
bottom_layout:add(memicon)
|
bottom_layout:add(memicon)
|
||||||
bottom_layout:add(mem)
|
bottom_layout:add(mem)
|
||||||
bottom_layout:add(spacer)
|
bottom_layout:add(spacer)
|
||||||
bottom_layout:add(wifiicon)
|
bottom_layout:add(wifiicon)
|
||||||
bottom_layout:add(wifi)
|
bottom_layout:add(wifi)
|
||||||
bottom_layout:add(spacer)
|
bottom_layout:add(spacer)
|
||||||
bottom_layout:add(weather)
|
bottom_layout:add(weather)
|
||||||
bottom_layout:add(spacer)
|
bottom_layout:add(spacer)
|
||||||
|
|
||||||
-- Now bring it all together
|
-- Now bring it all together
|
||||||
--local layout = wibox.layout.align.horizontal()
|
--local layout = wibox.layout.align.horizontal()
|
||||||
--layout:set_bottom(bottom_layout)
|
--layout:set_bottom(bottom_layout)
|
||||||
|
|
||||||
myinfowibox[s]:set_widget(bottom_layout)
|
myinfowibox[s]:set_widget(bottom_layout)
|
||||||
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Mouse bindings
|
-- {{{ Mouse bindings
|
||||||
root.buttons(awful.util.table.join(
|
root.buttons(awful.util.table.join(
|
||||||
awful.button({ }, 3, function () mymainmenu:toggle() end),
|
awful.button({ }, 3, function () mymainmenu:toggle() end),
|
||||||
awful.button({ }, 4, awful.tag.viewnext),
|
awful.button({ }, 4, awful.tag.viewnext),
|
||||||
awful.button({ }, 5, awful.tag.viewprev)
|
awful.button({ }, 5, awful.tag.viewprev)
|
||||||
))
|
))
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Key bindings
|
-- {{{ Key bindings
|
||||||
globalkeys = awful.util.table.join(
|
globalkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
||||||
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
||||||
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
||||||
|
|
||||||
awful.key({ modkey, }, "j",
|
awful.key({ modkey, }, "j",
|
||||||
function ()
|
function ()
|
||||||
awful.client.focus.byidx( 1)
|
awful.client.focus.byidx( 1)
|
||||||
if client.focus then client.focus:raise() end
|
if client.focus then client.focus:raise() end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, }, "k",
|
awful.key({ modkey, }, "k",
|
||||||
function ()
|
function ()
|
||||||
awful.client.focus.byidx(-1)
|
awful.client.focus.byidx(-1)
|
||||||
if client.focus then client.focus:raise() end
|
if client.focus then client.focus:raise() end
|
||||||
end),
|
end),
|
||||||
awful.key({ }, "Print", function () awful.util.spawn("upload_screens scr") end),
|
awful.key({ }, "Print", function () awful.util.spawn("upload_screens scr") end),
|
||||||
|
|
||||||
-- Layout manipulation
|
-- Layout manipulation
|
||||||
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
|
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, "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" }, "j", function () awful.screen.focus_relative( 1) end),
|
||||||
awful.key({ modkey, "Control" }, "k", 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, }, "u", awful.client.urgent.jumpto),
|
||||||
awful.key({ modkey, }, "Tab",
|
awful.key({ modkey, }, "Tab",
|
||||||
function ()
|
function ()
|
||||||
awful.client.focus.history.previous()
|
awful.client.focus.history.previous()
|
||||||
if client.focus then
|
if client.focus then
|
||||||
client.focus:raise()
|
client.focus:raise()
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
|
|
||||||
-- Standard program
|
-- Standard program
|
||||||
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) 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, }, "h", function () awful.tag.incmwfact(-0.05) end),
|
||||||
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) 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, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
|
||||||
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 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, "Control" }, "l", function () awful.tag.incncol(-1) end),
|
||||||
awful.key({ modkey, "Control" }, "space", function () awful.layout.inc(layouts, -1) end),
|
awful.key({ modkey, "Control" }, "space", function () awful.layout.inc(layouts, -1) end),
|
||||||
awful.key({ modkey, }, "w", function () awful.util.spawn(browser) end),
|
awful.key({ modkey, }, "w", function () awful.util.spawn(browser) end),
|
||||||
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
|
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
|
||||||
awful.key({ modkey }, "t", function () awful.util.spawn(terminal) end),
|
awful.key({ modkey }, "t", function () awful.util.spawn(terminal) end),
|
||||||
awful.key({ modkey }, "e", function () awful.util.spawn(txteditor) end),
|
awful.key({ modkey }, "e", function () awful.util.spawn(txteditor) end),
|
||||||
awful.key({ modkey }, "f", function () awful.util.spawn(filemgr) end),
|
awful.key({ modkey }, "f", function () awful.util.spawn(filemgr) end),
|
||||||
awful.key({ modkey }, "r", function () awful.util.spawn(rmenu) end),
|
awful.key({ modkey }, "r", function () awful.util.spawn(rmenu) end),
|
||||||
awful.key({ modkey }, "space", function () awful.util.spawn(rmenu) end),
|
awful.key({ modkey }, "space", function () awful.util.spawn(rmenu) end),
|
||||||
awful.key({ modkey, "Shift" }, "r", awesome.restart),
|
awful.key({ modkey, "Shift" }, "r", awesome.restart),
|
||||||
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
||||||
awful.key({ modkey, "Control" }, "n", awful.client.restore),
|
awful.key({ modkey, "Control" }, "n", awful.client.restore),
|
||||||
-- Menubar
|
-- Menubar
|
||||||
awful.key({ modkey }, "b", function() menubar.show() end)
|
awful.key({ modkey }, "b", function() menubar.show() end)
|
||||||
)
|
)
|
||||||
|
|
||||||
clientkeys = awful.util.table.join(
|
clientkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, "Shift" }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
awful.key({ modkey, "Shift" }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
||||||
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
||||||
awful.key({ modkey, "Shift" }, "space", awful.client.floating.toggle ),
|
awful.key({ modkey, "Shift" }, "space", awful.client.floating.toggle ),
|
||||||
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
||||||
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
||||||
awful.key({ modkey, "Shift" }, "t", function (c) c.ontop = not c.ontop end),
|
awful.key({ modkey, "Shift" }, "t", function (c) c.ontop = not c.ontop end),
|
||||||
awful.key({ modkey, }, "n",
|
awful.key({ modkey, }, "n",
|
||||||
function (c)
|
function (c)
|
||||||
-- The client currently has the input focus, so it cannot be
|
-- The client currently has the input focus, so it cannot be
|
||||||
-- minimized, since minimized clients can't have the focus.
|
-- minimized, since minimized clients can't have the focus.
|
||||||
c.minimized = true
|
c.minimized = true
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, }, "m",
|
awful.key({ modkey, }, "m",
|
||||||
function (c)
|
function (c)
|
||||||
c.maximized_horizontal = not c.maximized_horizontal
|
c.maximized_horizontal = not c.maximized_horizontal
|
||||||
c.maximized_vertical = not c.maximized_vertical
|
c.maximized_vertical = not c.maximized_vertical
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Compute the maximum number of digit we need, limited to 9
|
-- Compute the maximum number of digit we need, limited to 9
|
||||||
keynumber = 0
|
keynumber = 0
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
keynumber = math.min(9, math.max(#tags[s], keynumber))
|
keynumber = math.min(9, math.max(#tags[s], keynumber))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Bind all key numbers to tags.
|
-- Bind all key numbers to tags.
|
||||||
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
-- 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.
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
||||||
for i = 1, keynumber do
|
for i = 1, keynumber do
|
||||||
globalkeys = awful.util.table.join(globalkeys,
|
globalkeys = awful.util.table.join(globalkeys,
|
||||||
awful.key({ modkey }, "#" .. i + 9,
|
awful.key({ modkey }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
local screen = mouse.screen
|
local screen = mouse.screen
|
||||||
if tags[screen][i] then
|
if tags[screen][i] then
|
||||||
awful.tag.viewonly(tags[screen][i])
|
awful.tag.viewonly(tags[screen][i])
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
local screen = mouse.screen
|
local screen = mouse.screen
|
||||||
if tags[screen][i] then
|
if tags[screen][i] then
|
||||||
awful.tag.viewtoggle(tags[screen][i])
|
awful.tag.viewtoggle(tags[screen][i])
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
if client.focus and tags[client.focus.screen][i] then
|
if client.focus and tags[client.focus.screen][i] then
|
||||||
awful.client.movetotag(tags[client.focus.screen][i])
|
awful.client.movetotag(tags[client.focus.screen][i])
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
||||||
function ()
|
function ()
|
||||||
if client.focus and tags[client.focus.screen][i] then
|
if client.focus and tags[client.focus.screen][i] then
|
||||||
awful.client.toggletag(tags[client.focus.screen][i])
|
awful.client.toggletag(tags[client.focus.screen][i])
|
||||||
end
|
end
|
||||||
end))
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
clientbuttons = awful.util.table.join(
|
clientbuttons = awful.util.table.join(
|
||||||
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
||||||
awful.button({ modkey }, 1, awful.mouse.client.move),
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
||||||
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
||||||
|
|
||||||
-- Set keys
|
-- Set keys
|
||||||
root.keys(globalkeys)
|
root.keys(globalkeys)
|
||||||
@ -457,91 +457,91 @@ root.keys(globalkeys)
|
|||||||
|
|
||||||
-- {{{ Rules
|
-- {{{ Rules
|
||||||
awful.rules.rules = {
|
awful.rules.rules = {
|
||||||
-- All clients will match this rule.
|
-- All clients will match this rule.
|
||||||
{ rule = { },
|
{ rule = { },
|
||||||
properties = { border_width = beautiful.border_width,
|
properties = { border_width = beautiful.border_width,
|
||||||
border_color = beautiful.border_normal,
|
border_color = beautiful.border_normal,
|
||||||
focus = awful.client.focus.filter,
|
focus = awful.client.focus.filter,
|
||||||
keys = clientkeys,
|
keys = clientkeys,
|
||||||
buttons = clientbuttons } },
|
buttons = clientbuttons } },
|
||||||
{ rule = { class = "mpv" },
|
{ rule = { class = "mpv" },
|
||||||
properties = { floating = true } },
|
properties = { floating = true } },
|
||||||
{ rule = { class = "pinentry" },
|
{ rule = { class = "pinentry" },
|
||||||
properties = { floating = true } },
|
properties = { floating = true } },
|
||||||
{ rule = { class = "gimp" },
|
{ rule = { class = "gimp" },
|
||||||
properties = { floating = true } },
|
properties = { floating = true } },
|
||||||
{ rule = { class = "Firefox" },
|
{ rule = { class = "Firefox" },
|
||||||
properties = { tag = tags[1][3] } },
|
properties = { tag = tags[1][3] } },
|
||||||
{ rule = { class = "VirtualBox" },
|
{ rule = { class = "VirtualBox" },
|
||||||
properties = { tag = tags[1][5] } },
|
properties = { tag = tags[1][5] } },
|
||||||
{ rule = { class = "Gns3" },
|
{ rule = { class = "Gns3" },
|
||||||
properties = { tag = tags[1][5] } },
|
properties = { tag = tags[1][5] } },
|
||||||
-- Set Firefox to always map on tags number 2 of screen 1.
|
-- Set Firefox to always map on tags number 2 of screen 1.
|
||||||
-- { rule = { class = "Firefox" },
|
-- { rule = { class = "Firefox" },
|
||||||
-- properties = { tag = tags[1][2] } },
|
-- properties = { tag = tags[1][2] } },
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Signals
|
-- {{{ Signals
|
||||||
-- Signal function to execute when a new client appears.
|
-- Signal function to execute when a new client appears.
|
||||||
client.connect_signal("manage", function (c, startup)
|
client.connect_signal("manage", function (c, startup)
|
||||||
-- Enable sloppy focus
|
-- Enable sloppy focus
|
||||||
c:connect_signal("mouse::enter", function(c)
|
c:connect_signal("mouse::enter", function(c)
|
||||||
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
||||||
and awful.client.focus.filter(c) then
|
and awful.client.focus.filter(c) then
|
||||||
client.focus = c
|
client.focus = c
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not startup then
|
if not startup then
|
||||||
-- Set the windows at the slave,
|
-- Set the windows at the slave,
|
||||||
-- i.e. put it at the end of others instead of setting it master.
|
-- i.e. put it at the end of others instead of setting it master.
|
||||||
-- awful.client.setslave(c)
|
-- awful.client.setslave(c)
|
||||||
|
|
||||||
-- Put windows in a smart way, only if they does not set an initial position.
|
-- 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
|
if not c.size_hints.user_position and not c.size_hints.program_position then
|
||||||
awful.placement.no_overlap(c)
|
awful.placement.no_overlap(c)
|
||||||
awful.placement.no_offscreen(c)
|
awful.placement.no_offscreen(c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local titlebars_enabled = false
|
local titlebars_enabled = false
|
||||||
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
|
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
|
||||||
-- Widgets that are aligned to the left
|
-- Widgets that are aligned to the left
|
||||||
local left_layout = wibox.layout.fixed.horizontal()
|
local left_layout = wibox.layout.fixed.horizontal()
|
||||||
left_layout:add(awful.titlebar.widget.iconwidget(c))
|
left_layout:add(awful.titlebar.widget.iconwidget(c))
|
||||||
|
|
||||||
-- Widgets that are aligned to the right
|
-- Widgets that are aligned to the right
|
||||||
local right_layout = wibox.layout.fixed.horizontal()
|
local right_layout = wibox.layout.fixed.horizontal()
|
||||||
right_layout:add(awful.titlebar.widget.floatingbutton(c))
|
right_layout:add(awful.titlebar.widget.floatingbutton(c))
|
||||||
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
|
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
|
||||||
right_layout:add(awful.titlebar.widget.stickybutton(c))
|
right_layout:add(awful.titlebar.widget.stickybutton(c))
|
||||||
right_layout:add(awful.titlebar.widget.ontopbutton(c))
|
right_layout:add(awful.titlebar.widget.ontopbutton(c))
|
||||||
right_layout:add(awful.titlebar.widget.closebutton(c))
|
right_layout:add(awful.titlebar.widget.closebutton(c))
|
||||||
|
|
||||||
-- The title goes in the middle
|
-- The title goes in the middle
|
||||||
local title = awful.titlebar.widget.titlewidget(c)
|
local title = awful.titlebar.widget.titlewidget(c)
|
||||||
title:buttons(awful.util.table.join(
|
title:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 1, function()
|
awful.button({ }, 1, function()
|
||||||
client.focus = c
|
client.focus = c
|
||||||
c:raise()
|
c:raise()
|
||||||
awful.mouse.client.move(c)
|
awful.mouse.client.move(c)
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 3, function()
|
awful.button({ }, 3, function()
|
||||||
client.focus = c
|
client.focus = c
|
||||||
c:raise()
|
c:raise()
|
||||||
awful.mouse.client.resize(c)
|
awful.mouse.client.resize(c)
|
||||||
end)
|
end)
|
||||||
))
|
))
|
||||||
|
|
||||||
-- Now bring it all together
|
-- Now bring it all together
|
||||||
local layout = wibox.layout.align.horizontal()
|
local layout = wibox.layout.align.horizontal()
|
||||||
layout:set_left(left_layout)
|
layout:set_left(left_layout)
|
||||||
layout:set_right(right_layout)
|
layout:set_right(right_layout)
|
||||||
layout:set_middle(title)
|
layout:set_middle(title)
|
||||||
|
|
||||||
awful.titlebar(c):set_widget(layout)
|
awful.titlebar(c):set_widget(layout)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
|
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
|
||||||
|
@ -26,159 +26,159 @@ BB = {}
|
|||||||
BB.__index = BB
|
BB.__index = BB
|
||||||
|
|
||||||
function BB.create(url, builder)
|
function BB.create(url, builder)
|
||||||
local b = {}
|
local b = {}
|
||||||
setmetatable(b,BB)
|
setmetatable(b,BB)
|
||||||
b.url = url -- buildbot url
|
b.url = url -- buildbot url
|
||||||
b.builder = builder -- builder name
|
b.builder = builder -- builder name
|
||||||
b.lastChecked = 0 -- last checked build number
|
b.lastChecked = 0 -- last checked build number
|
||||||
b.lastSuccessful = 0 -- last successful build number
|
b.lastSuccessful = 0 -- last successful build number
|
||||||
b.lastResult = nil -- last json parsed result
|
b.lastResult = nil -- last json parsed result
|
||||||
b.lastError = nil -- last error string or nil if no error
|
b.lastError = nil -- last error string or nil if no error
|
||||||
return b
|
return b
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:_queryBuildbot(build_number)
|
function BB:_queryBuildbot(build_number)
|
||||||
local f = io.popen("curl --connect-timeout 1 "..self.url.."/json/builders/"..self.builder.."/builds/"..build_number)
|
local f = io.popen("curl --connect-timeout 1 "..self.url.."/json/builders/"..self.builder.."/builds/"..build_number)
|
||||||
local jsbuilder = f:read("*all")
|
local jsbuilder = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
if #jsbuilder == 0 then
|
if #jsbuilder == 0 then
|
||||||
return false, "can't read from url"
|
return false, "can't read from url"
|
||||||
end
|
end
|
||||||
|
|
||||||
local result_status, result = pcall(json.decode, jsbuilder, false)
|
local result_status, result = pcall(json.decode, jsbuilder, false)
|
||||||
if not result_status then
|
if not result_status then
|
||||||
return false, "can't parse json data"
|
return false, "can't parse json data"
|
||||||
end
|
end
|
||||||
return true, result
|
return true, result
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:_getBuildStatus(result)
|
function BB:_getBuildStatus(result)
|
||||||
if #result['text'] > 0 then
|
if #result['text'] > 0 then
|
||||||
local text = result['text']
|
local text = result['text']
|
||||||
if text[1] == "build" and text[2] == "successful" and #text == 2 then
|
if text[1] == "build" and text[2] == "successful" and #text == 2 then
|
||||||
--successful
|
--successful
|
||||||
return bs.OK
|
return bs.OK
|
||||||
|
else
|
||||||
|
--failed
|
||||||
|
return bs.FAILED
|
||||||
|
end
|
||||||
else
|
else
|
||||||
--failed
|
--in progress
|
||||||
return bs.FAILED
|
return bs.RUNNING
|
||||||
end
|
end
|
||||||
else
|
|
||||||
--in progress
|
|
||||||
return bs.RUNNING
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function queries buildbot to refresh builds status.
|
-- Function queries buildbot to refresh builds status.
|
||||||
-- * if build is successful or failed it will not be queried again, number is stored in lasteChecked
|
-- * if build is successful or failed it will not be queried again, number is stored in lasteChecked
|
||||||
-- * up to 10 last builds will be checked to find last successful build
|
-- * up to 10 last builds will be checked to find last successful build
|
||||||
function BB:refresh()
|
function BB:refresh()
|
||||||
local last_pass_fail = 0
|
local last_pass_fail = 0
|
||||||
local nr = -1
|
local nr = -1
|
||||||
local last_result
|
local last_result
|
||||||
local iter_counter = 0
|
local iter_counter = 0
|
||||||
|
|
||||||
self.lastError = nil
|
self.lastError = nil
|
||||||
self.lastResult = nil
|
self.lastResult = nil
|
||||||
--- there is a gap to fill in, iterate all not checked builds starting from latest
|
--- there is a gap to fill in, iterate all not checked builds starting from latest
|
||||||
while nr > self.lastChecked or nr == -1 do
|
while nr > self.lastChecked or nr == -1 do
|
||||||
local r_status, r = self:_queryBuildbot(nr)
|
local r_status, r = self:_queryBuildbot(nr)
|
||||||
local s
|
local s
|
||||||
|
|
||||||
if not r_status then
|
if not r_status then
|
||||||
self.lastError = r
|
self.lastError = r
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
s = self:_getBuildStatus(r)
|
s = self:_getBuildStatus(r)
|
||||||
if not last_result then
|
if not last_result then
|
||||||
last_result = r
|
last_result = r
|
||||||
|
end
|
||||||
|
nr = r['number']
|
||||||
|
assert(nr > 0)
|
||||||
|
if last_pass_fail == 0 and (s == bs.OK or s == bs.FAILED) then
|
||||||
|
last_pass_fail = nr
|
||||||
|
end
|
||||||
|
if s == bs.OK then --successful
|
||||||
|
self.lastSuccessful = nr
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
nr = nr - 1
|
||||||
|
iter_counter = iter_counter + 1
|
||||||
|
if iter_counter > 10 then --check max last 10 builds when searching for successful build
|
||||||
|
break;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
nr = r['number']
|
if last_pass_fail ~= 0 then
|
||||||
assert(nr > 0)
|
self.lastChecked = last_pass_fail
|
||||||
if last_pass_fail == 0 and (s == bs.OK or s == bs.FAILED) then
|
|
||||||
last_pass_fail = nr
|
|
||||||
end
|
end
|
||||||
if s == bs.OK then --successful
|
if last_result then
|
||||||
self.lastSuccessful = nr
|
self.lastResult = last_result
|
||||||
break;
|
|
||||||
end
|
end
|
||||||
nr = nr - 1
|
|
||||||
iter_counter = iter_counter + 1
|
|
||||||
if iter_counter > 10 then --check max last 10 builds when searching for successful build
|
|
||||||
break;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if last_pass_fail ~= 0 then
|
|
||||||
self.lastChecked = last_pass_fail
|
|
||||||
end
|
|
||||||
if last_result then
|
|
||||||
self.lastResult = last_result
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getLastSuccessful()
|
function BB:getLastSuccessful()
|
||||||
return self.lastSuccessful
|
return self.lastSuccessful
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getCurrent()
|
function BB:getCurrent()
|
||||||
return self.lastResult['number']
|
return self.lastResult['number']
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getCurrentStatus()
|
function BB:getCurrentStatus()
|
||||||
return self:_getBuildStatus(self.lastResult)
|
return self:_getBuildStatus(self.lastResult)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getBuilder()
|
function BB:getBuilder()
|
||||||
return self.builder
|
return self.builder
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getError()
|
function BB:getError()
|
||||||
return self.lastError
|
return self.lastError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function getBuilderStatus(b)
|
local function getBuilderStatus(b)
|
||||||
local s = "[" .. b:getBuilder()
|
local s = "[" .. b:getBuilder()
|
||||||
--check if json library was loaded correctly
|
--check if json library was loaded correctly
|
||||||
if not json_status then
|
if not json_status then
|
||||||
return s .. ".<span color=\"orange\">can't find libluaX.X-json</span>]"
|
return s .. ".<span color=\"orange\">can't find libluaX.X-json</span>]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local err = b:getError()
|
local err = b:getError()
|
||||||
if err then
|
if err then
|
||||||
return s .. ".<span color=\"orange\">" .. err .. "</span>]"
|
return s .. ".<span color=\"orange\">" .. err .. "</span>]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if b:getLastSuccessful() ~= 0 then
|
if b:getLastSuccessful() ~= 0 then
|
||||||
success_build_nr_str = "<span color=\"green\">".. b:getLastSuccessful() .."</span>"
|
success_build_nr_str = "<span color=\"green\">".. b:getLastSuccessful() .."</span>"
|
||||||
else
|
else
|
||||||
success_build_nr_str = "-"
|
success_build_nr_str = "-"
|
||||||
end
|
end
|
||||||
|
|
||||||
local current_build_color = bc[b:getCurrentStatus()]
|
local current_build_color = bc[b:getCurrentStatus()]
|
||||||
current_build_nr_str = "<span color=\""..current_build_color.."\">"..b:getCurrent().."</span>"
|
current_build_nr_str = "<span color=\""..current_build_color.."\">"..b:getCurrent().."</span>"
|
||||||
|
|
||||||
if current_build_color ~= "green" then
|
if current_build_color ~= "green" then
|
||||||
s = s .. "." .. current_build_nr_str
|
s = s .. "." .. current_build_nr_str
|
||||||
end
|
end
|
||||||
return s .. "." .. success_build_nr_str .. "]"
|
return s .. "." .. success_build_nr_str .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Buildbot widget type
|
-- {{{ Buildbot widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if #bb == 0 then --fill up bb with builders when worker function is run for the first time
|
if #bb == 0 then --fill up bb with builders when worker function is run for the first time
|
||||||
for i,v in pairs(warg) do
|
for i,v in pairs(warg) do
|
||||||
bb[#bb+1] = BB.create(v["url"], v["builder"])
|
bb[#bb+1] = BB.create(v["url"], v["builder"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local str = ""
|
local str = ""
|
||||||
for i,v in pairs(bb) do
|
for i,v in pairs(bb) do
|
||||||
v:refresh()
|
v:refresh()
|
||||||
str = str .. " " .. getBuilderStatus(v)
|
str = str .. " " .. getBuilderStatus(v)
|
||||||
end
|
end
|
||||||
return {str .. " "}
|
return {str .. " "}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ local setmetatable = setmetatable
|
|||||||
local os = { execute = os.execute }
|
local os = { execute = os.execute }
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
format = string.format,
|
format = string.format,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
local math = {
|
local math = {
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -29,36 +29,36 @@ local pulse = {}
|
|||||||
|
|
||||||
-- {{{ Helper function
|
-- {{{ Helper function
|
||||||
local function pacmd(args)
|
local function pacmd(args)
|
||||||
local f = io.popen("pacmd "..args)
|
local f = io.popen("pacmd "..args)
|
||||||
if f == nil then
|
if f == nil then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
local line = f:read("*all")
|
local line = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function escape(text)
|
local function escape(text)
|
||||||
local special_chars = { ["."] = "%.", ["-"] = "%-" }
|
local special_chars = { ["."] = "%.", ["-"] = "%-" }
|
||||||
return text:gsub("[%.%-]", special_chars)
|
return text:gsub("[%.%-]", special_chars)
|
||||||
end
|
end
|
||||||
|
|
||||||
local cached_sinks = {}
|
local cached_sinks = {}
|
||||||
local function get_sink_name(sink)
|
local function get_sink_name(sink)
|
||||||
if type(sink) == "string" then return sink end
|
if type(sink) == "string" then return sink end
|
||||||
-- avoid nil keys
|
-- avoid nil keys
|
||||||
local key = sink or 1
|
local key = sink or 1
|
||||||
-- Cache requests
|
-- Cache requests
|
||||||
if not cached_sinks[key] then
|
if not cached_sinks[key] then
|
||||||
local line = pacmd("list-sinks")
|
local line = pacmd("list-sinks")
|
||||||
if line == nil then return nil end
|
if line == nil then return nil end
|
||||||
for s in string.gmatch(line, "name: <(.-)>") do
|
for s in string.gmatch(line, "name: <(.-)>") do
|
||||||
table.insert(cached_sinks, s)
|
table.insert(cached_sinks, s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return cached_sinks[key]
|
return cached_sinks[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -66,55 +66,55 @@ end
|
|||||||
|
|
||||||
-- {{{ Pulseaudio widget type
|
-- {{{ Pulseaudio widget type
|
||||||
local function worker(format, sink)
|
local function worker(format, sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return {0, "unknown"} end
|
if sink == nil then return {0, "unknown"} end
|
||||||
|
|
||||||
-- Get sink data
|
-- Get sink data
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
if sink == nil then return {0, "unknown"} end
|
if sink == nil then return {0, "unknown"} end
|
||||||
|
|
||||||
-- If mute return 0 (not "Mute") so we don't break progressbars
|
-- If mute return 0 (not "Mute") so we don't break progressbars
|
||||||
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
||||||
return {0, "off"}
|
return {0, "off"}
|
||||||
end
|
end
|
||||||
|
|
||||||
local vol = tonumber(string.match(data, "set%-sink%-volume "..escape(sink).." (0x[%x]+)"))
|
local vol = tonumber(string.match(data, "set%-sink%-volume "..escape(sink).." (0x[%x]+)"))
|
||||||
if vol == nil then vol = 0 end
|
if vol == nil then vol = 0 end
|
||||||
|
|
||||||
return { math.floor(vol/0x10000*100), "on"}
|
return { math.floor(vol/0x10000*100), "on"}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Volume control helper
|
-- {{{ Volume control helper
|
||||||
function pulse.add(percent, sink)
|
function pulse.add(percent, sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
|
|
||||||
local pattern = "set%-sink%-volume "..escape(sink).." (0x[%x]+)"
|
local pattern = "set%-sink%-volume "..escape(sink).." (0x[%x]+)"
|
||||||
local initial_vol = tonumber(string.match(data, pattern))
|
local initial_vol = tonumber(string.match(data, pattern))
|
||||||
|
|
||||||
local vol = initial_vol + percent/100*0x10000
|
local vol = initial_vol + percent/100*0x10000
|
||||||
if vol > 0x10000 then vol = 0x10000 end
|
if vol > 0x10000 then vol = 0x10000 end
|
||||||
if vol < 0 then vol = 0 end
|
if vol < 0 then vol = 0 end
|
||||||
|
|
||||||
local cmd = string.format("pacmd set-sink-volume %s 0x%x >/dev/null", sink, vol)
|
local cmd = string.format("pacmd set-sink-volume %s 0x%x >/dev/null", sink, vol)
|
||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pulse.toggle(sink)
|
function pulse.toggle(sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
local pattern = "set%-sink%-mute "..escape(sink).." (%a%a%a?)"
|
local pattern = "set%-sink%-mute "..escape(sink).." (%a%a%a?)"
|
||||||
local mute = string.match(data, pattern)
|
local mute = string.match(data, pattern)
|
||||||
|
|
||||||
-- 0 to enable a sink or 1 to mute it.
|
-- 0 to enable a sink or 1 to mute it.
|
||||||
local state = { yes = 0, no = 1}
|
local state = { yes = 0, no = 1}
|
||||||
local cmd = string.format("pacmd set-sink-mute %s %d", sink, state[mute])
|
local cmd = string.format("pacmd set-sink-mute %s %d", sink, state[mute])
|
||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ local io = { popen = io.popen }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
gsub = string.gsub,
|
gsub = string.gsub,
|
||||||
match = string.match
|
match = string.match
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -22,47 +22,47 @@ local sensors = {}
|
|||||||
|
|
||||||
-- {{{ Split helper function
|
-- {{{ Split helper function
|
||||||
local function datasplit(str)
|
local function datasplit(str)
|
||||||
-- Splitting strings into associative array
|
-- Splitting strings into associative array
|
||||||
-- with some magic to get the values right.
|
-- with some magic to get the values right.
|
||||||
str = string.gsub(str, "\n", ":")
|
str = string.gsub(str, "\n", ":")
|
||||||
|
|
||||||
local tbl = {}
|
local tbl = {}
|
||||||
string.gsub(str, "([^:]*)", function (v)
|
string.gsub(str, "([^:]*)", function (v)
|
||||||
if string.match(v, ".") then
|
if string.match(v, ".") then
|
||||||
table.insert(tbl, v)
|
table.insert(tbl, v)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local assoc = {}
|
local assoc = {}
|
||||||
for c = 1, #tbl, 2 do
|
for c = 1, #tbl, 2 do
|
||||||
local k = string.gsub(tbl[c], ".*_", "")
|
local k = string.gsub(tbl[c], ".*_", "")
|
||||||
local v = tonumber(string.match(tbl[c+1], "[%d]+"))
|
local v = tonumber(string.match(tbl[c+1], "[%d]+"))
|
||||||
assoc[k] = v
|
assoc[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
return assoc
|
return assoc
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Sensors widget type
|
-- {{{ Sensors widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Get data from all sensors
|
-- Get data from all sensors
|
||||||
local f = io.popen("LANG=C sensors -uA")
|
local f = io.popen("LANG=C sensors -uA")
|
||||||
local lm_sensors = f:read("*all")
|
local lm_sensors = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
local sensor_data = string.gsub(
|
local sensor_data = string.gsub(
|
||||||
string.match(lm_sensors, warg..":\n(%s%s.-)\n[^ ]"), " ", "")
|
string.match(lm_sensors, warg..":\n(%s%s.-)\n[^ ]"), " ", "")
|
||||||
|
|
||||||
-- One of: crit, max
|
-- One of: crit, max
|
||||||
local divisor = "crit"
|
local divisor = "crit"
|
||||||
local s_data = datasplit(sensor_data)
|
local s_data = datasplit(sensor_data)
|
||||||
|
|
||||||
if s_data[divisor] and s_data[divisor] > 0 then
|
if s_data[divisor] and s_data[divisor] > 0 then
|
||||||
s_data.percent = s_data.input / s_data[divisor] * 100
|
s_data.percent = s_data.input / s_data[divisor] * 100
|
||||||
end
|
end
|
||||||
|
|
||||||
return {s_data.input, tonumber(s_data.percent)}
|
return {s_data.input, tonumber(s_data.percent)}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -22,52 +22,52 @@ baticon:set_image(beautiful.widget_batfull)
|
|||||||
-- Charge %
|
-- Charge %
|
||||||
batpct = wibox.widget.textbox()
|
batpct = wibox.widget.textbox()
|
||||||
vicious.register(batpct, vicious.widgets.bat, function(widget, args)
|
vicious.register(batpct, vicious.widgets.bat, function(widget, args)
|
||||||
bat_state = args[1]
|
bat_state = args[1]
|
||||||
bat_charge = args[2]
|
bat_charge = args[2]
|
||||||
bat_time = args[3]
|
bat_time = args[3]
|
||||||
|
|
||||||
if args[1] == "-" then
|
if args[1] == "-" then
|
||||||
if bat_charge > 70 then
|
if bat_charge > 70 then
|
||||||
baticon:set_image(beautiful.widget_batfull)
|
baticon:set_image(beautiful.widget_batfull)
|
||||||
elseif bat_charge > 30 then
|
elseif bat_charge > 30 then
|
||||||
baticon:set_image(beautiful.widget_batmed)
|
baticon:set_image(beautiful.widget_batmed)
|
||||||
elseif bat_charge > 10 then
|
elseif bat_charge > 10 then
|
||||||
baticon:set_image(beautiful.widget_batlow)
|
baticon:set_image(beautiful.widget_batlow)
|
||||||
else
|
else
|
||||||
baticon:set_image(beautiful.widget_batempty)
|
baticon:set_image(beautiful.widget_batempty)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
baticon:set_image(beautiful.widget_ac)
|
baticon:set_image(beautiful.widget_ac)
|
||||||
if args[1] == "+" then
|
if args[1] == "+" then
|
||||||
blink = not blink
|
blink = not blink
|
||||||
if blink then
|
if blink then
|
||||||
baticon:set_image(beautiful.widget_acblink)
|
baticon:set_image(beautiful.widget_acblink)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return args[2] .. "%"
|
return args[2] .. "%"
|
||||||
end, nil, "BAT1")
|
end, nil, "BAT1")
|
||||||
|
|
||||||
-- Buttons
|
-- Buttons
|
||||||
function popup_bat()
|
function popup_bat()
|
||||||
local state = ""
|
local state = ""
|
||||||
if bat_state == "↯" then
|
if bat_state == "↯" then
|
||||||
state = "Full"
|
state = "Full"
|
||||||
elseif bat_state == "↯" then
|
elseif bat_state == "↯" then
|
||||||
state = "Charged"
|
state = "Charged"
|
||||||
elseif bat_state == "+" then
|
elseif bat_state == "+" then
|
||||||
state = "Charging"
|
state = "Charging"
|
||||||
elseif bat_state == "-" then
|
elseif bat_state == "-" then
|
||||||
state = "Discharging"
|
state = "Discharging"
|
||||||
elseif bat_state == "⌁" then
|
elseif bat_state == "⌁" then
|
||||||
state = "Not charging"
|
state = "Not charging"
|
||||||
else
|
else
|
||||||
state = "Unknown"
|
state = "Unknown"
|
||||||
end
|
end
|
||||||
|
|
||||||
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
|
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
|
||||||
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
|
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
|
||||||
end
|
end
|
||||||
batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat)))
|
batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat)))
|
||||||
baticon:buttons(batpct:buttons())
|
baticon:buttons(batpct:buttons())
|
||||||
@ -81,27 +81,27 @@ pacicon:set_image(beautiful.widget_pac)
|
|||||||
-- Upgrades
|
-- Upgrades
|
||||||
pacwidget = wibox.widget.textbox()
|
pacwidget = wibox.widget.textbox()
|
||||||
vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args)
|
vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args)
|
||||||
if args[1] > 0 then
|
if args[1] > 0 then
|
||||||
pacicon:set_image(beautiful.widget_pacnew)
|
pacicon:set_image(beautiful.widget_pacnew)
|
||||||
else
|
else
|
||||||
pacicon:set_image(beautiful.widget_pac)
|
pacicon:set_image(beautiful.widget_pac)
|
||||||
end
|
end
|
||||||
|
|
||||||
return args[1]
|
return args[1]
|
||||||
end, 1801, "Arch S") -- Arch S for ignorepkg
|
end, 1801, "Arch S") -- Arch S for ignorepkg
|
||||||
--
|
--
|
||||||
-- Buttons
|
-- Buttons
|
||||||
function popup_pac()
|
function popup_pac()
|
||||||
local pac_updates = ""
|
local pac_updates = ""
|
||||||
local f = io.popen("pacman -Sup --dbpath /tmp/pacsync")
|
local f = io.popen("pacman -Sup --dbpath /tmp/pacsync")
|
||||||
if f then
|
if f then
|
||||||
pac_updates = f:read("*a"):match(".*/(.*)-.*\n$")
|
pac_updates = f:read("*a"):match(".*/(.*)-.*\n$")
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
if not pac_updates then
|
if not pac_updates then
|
||||||
pac_updates = "System is up to date"
|
pac_updates = "System is up to date"
|
||||||
end
|
end
|
||||||
naughty.notify { text = pac_updates }
|
naughty.notify { text = pac_updates }
|
||||||
end
|
end
|
||||||
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
|
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
|
||||||
pacicon:buttons(pacwidget:buttons())
|
pacicon:buttons(pacwidget:buttons())
|
||||||
@ -121,12 +121,12 @@ vicious.register(volpct, vicious.widgets.volume, "$1%", nil, "Master")
|
|||||||
--
|
--
|
||||||
-- Buttons
|
-- Buttons
|
||||||
volicon:buttons(awful.util.table.join(
|
volicon:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 1,
|
awful.button({ }, 1,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master toggle") end),
|
function() awful.util.spawn_with_shell("pamixer -t") end),
|
||||||
awful.button({ }, 4,
|
awful.button({ }, 4,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master 3+% unmute") end),
|
function() awful.util.spawn_with_shell("pamixer -i 3") end),
|
||||||
awful.button({ }, 5,
|
awful.button({ }, 5,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master 3-% unmute") end)
|
function() awful.util.spawn_with_shell("pamixer -d 3") end)
|
||||||
))
|
))
|
||||||
volpct:buttons(volicon:buttons())
|
volpct:buttons(volicon:buttons())
|
||||||
volspace:buttons(volicon:buttons())
|
volspace:buttons(volicon:buttons())
|
||||||
|
@ -1,46 +1,99 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Executed by startx
|
|
||||||
# By calling this with arguments we can start different sessions
|
|
||||||
# eg. startx ~/.xinitrc i3 or startx ~/.xinitrc bspwm
|
|
||||||
# simply using startx, openbox is set as the default
|
|
||||||
|
|
||||||
|
# this file is executed when calling startx
|
||||||
|
|
||||||
|
# To run different WM, run:
|
||||||
|
# startx ~/.xinitrc SESSION
|
||||||
|
# eg. startx ~/.xinitrc openbox
|
||||||
|
|
||||||
|
# Commands for autologin with Systemd & Arch
|
||||||
|
# No editing files or messing about required
|
||||||
|
#--------------------------------------#
|
||||||
|
# This copies the default getty service file so we can modify it
|
||||||
|
# 1. sudo cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service
|
||||||
|
|
||||||
|
# This removes the existing link and creates a link to the file copied above
|
||||||
|
# 2. sudo rm -f /etc/systemd/system/getty.target.wants/getty@tty1.service && sudo ln -s /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||||||
|
|
||||||
|
# This command sets your user as the autologin user
|
||||||
|
# 3. sudo sed -i "/ExecStart/ c ExecStart=-/sbin/agetty -a ${USER} %I \$TERM" /etc/systemd/system/autologin@.service
|
||||||
|
|
||||||
|
# This command will back up existing ~/.zprofile or ~/.bash_profile
|
||||||
|
# 4. for f in $HOME/.{zprofile,bash_profile}; do if [[ -f $f ]]; then mv $f $HOME/${f}.bak; fi; done
|
||||||
|
|
||||||
|
# This command creates a new ~/.zprofile & ~/.bash_profile.. you can delete the one you don't need
|
||||||
|
# 5. for x in $HOME/.{zprofile,bash_profile}; do echo -e "# $x\n\nif [[ \$DISPLAY ]] && [[ -n \$XDG_VTNR ]] && [[ \$XDG_VTNR -eq 1 ]]; then\n exec startx\nfi\n" > $x; done
|
||||||
|
|
||||||
|
# Finish up
|
||||||
|
# 6. Remove Your Current Display Manager and Reboot!!
|
||||||
|
#--------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
# Session to run if none given
|
||||||
session=${1:-openbox}
|
session=${1:-openbox}
|
||||||
|
|
||||||
|
# set ENV window manager for use in other scripts
|
||||||
export WM="$session"
|
export WM="$session"
|
||||||
|
|
||||||
if [ -f /etc/X11/xinit/.Xmodmap ]; then
|
# bspwm requires this to be set
|
||||||
xmodmap /etc/X11/xinit/.Xmodmap
|
export XDG_CONFIG_HOME=$HOME/.config
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
# Default Arch xinit scripts
|
||||||
if [ -d /etc/X11/xinit/xinitrc.d ]; then
|
if [ -d /etc/X11/xinit/xinitrc.d ]; then
|
||||||
for f in /etc/X11/xinit/xinitrc.d/*.sh; do
|
for f in /etc/X11/xinit/xinitrc.d/*.sh; do
|
||||||
[ -x "$f" ] && . "$f"
|
[ -x "$f" ] && . "$f"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.Xresources ]; then
|
if [ -f /etc/X11/xinit/.Xmodmap ]; then
|
||||||
xrdb -load ~/.Xresources
|
xmodmap /etc/X11/xinit/.Xmodmap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# user init scripts and settings
|
||||||
if [ -f ~/.Xmodmap ]; then
|
if [ -f ~/.Xmodmap ]; then
|
||||||
xmodmap ~/.Xmodmap
|
xmodmap ~/.Xmodmap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.xprofile ]; then
|
if [ -f ~/.Xresources ]; then
|
||||||
. ~/.xprofile
|
xrdb -merge ~/.Xresources
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f ~/.xprofile ]; then
|
||||||
|
source ~/.xprofile
|
||||||
|
fi
|
||||||
|
|
||||||
|
# keyring for storing passwords
|
||||||
gnome-keyring-daemon --start --components=pkcs11 &
|
gnome-keyring-daemon --start --components=pkcs11 &
|
||||||
|
|
||||||
|
# run policy kit
|
||||||
lxpolkit &
|
lxpolkit &
|
||||||
|
|
||||||
|
# keyboard repeat rate
|
||||||
kbdrate -d 400 -r 50
|
kbdrate -d 400 -r 50
|
||||||
xset r rate 400 50
|
xset r rate 400 50
|
||||||
|
|
||||||
|
# display timeout
|
||||||
xset s 3600 3600
|
xset s 3600 3600
|
||||||
|
|
||||||
# start the session
|
|
||||||
|
# Do NOT put code below this case statement
|
||||||
case $session in
|
case $session in
|
||||||
i3|i3wm) exec i3 ;;
|
dwm)
|
||||||
bsp|bspwm) exec bspwm ;;
|
exec dwm
|
||||||
awesome) exec awesome ;;
|
;;
|
||||||
xfce|xfce4) exec startxfce4 ;;
|
i3|i3wm)
|
||||||
openbox|openbox-session) exec openbox-session ;;
|
exec i3
|
||||||
*) exec "$1"
|
;;
|
||||||
|
bsp|bspwm)
|
||||||
|
exec bspwm
|
||||||
|
;;
|
||||||
|
xfce|xfce4)
|
||||||
|
exec startxfce4
|
||||||
|
;;
|
||||||
|
openbox)
|
||||||
|
exec openbox-session
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exec "$1" # Unknown, try running it
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user