freedesktop: little improvements

This commit is contained in:
luke bonham 2013-08-18 23:26:03 +02:00
parent c99b9bb673
commit 87793a3904
8 changed files with 51 additions and 24 deletions

View File

@ -1,4 +1,3 @@
local wibox = wibox
local widget = widget
local screen = screen
local image = image

View File

@ -12,8 +12,8 @@ require('freedesktop.desktop')
require('freedesktop.menu')
-- require("debian.menu")
freedesktop.utils.terminal = terminal
freedesktop.utils.icon_theme = 'gnome' -- look inside /usr/share/icons/, default: nil (don't use icon theme)
freedesktop.utils.terminal = terminal -- defined in rc.lua, otherwise define it here (default: "xterm")
freedesktop.utils.icon_theme = 'gnome' -- choose your favourite from /usr/share/icons/ (default: nil)
menu_items = freedesktop.menu.new()
@ -25,14 +25,14 @@ myawesomemenu = {
}
for s = 1, screen.count() do
freedesktop.desktop.add_applications_icons({screen = s, showlabels = true})
freedesktop.desktop.add_dirs_and_files_icons({screen = s, showlabels = true})
--freedesktop.desktop.add_application_icons({screen = s, showlabels = true})
--freedesktop.desktop.add_dirs_and_file_icons({screen = s, showlabels = true})
freedesktop.desktop.add_desktop_icons({screen = s, showlabels = true})
end
table.insert(menu_items, { "awesome", myawesomemenu, beautiful.awesome_icon })
table.insert(menu_items, { "open terminal", terminal, freedesktop.utils.lookup_icon({icon = 'terminal'}) })
-- table.insert(menu_items, { "Debian", debian.menu.Debian_menu.Debian, freedesktop.utils.lookup_icon({ icon = 'debian-logo' }) })
mymainmenu = awful.menu.new({ items = menu_items, width = 200 })
mymainmenu = awful.menu.new({ items = menu_items, theme = { width = 150 } })
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu })

View File

@ -71,17 +71,17 @@ function new(arg)
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' }) },
{ "Accessories", programs["Utility"], utils.lookup_icon({ icon = 'applications-accessories' }) },
{ "Development", programs["Development"], utils.lookup_icon({ icon = 'applications-development' }) },
{ "Education", programs["Education"], utils.lookup_icon({ icon = 'applications-science' }) },
{ "Games", programs["Game"], utils.lookup_icon({ icon = 'applications-games' }) },
{ "Graphics", programs["Graphics"], utils.lookup_icon({ icon = 'applications-graphics' }) },
{ "Internet", programs["Network"], utils.lookup_icon({ icon = 'applications-internet' }) },
{ "Multimedia", programs["AudioVideo"], utils.lookup_icon({ icon = 'applications-multimedia' }) },
{ "Office", programs["Office"], utils.lookup_icon({ icon = 'applications-office' }) },
{ "Other", programs["Other"], utils.lookup_icon({ icon = 'applications-other' }) },
{ "Settings", programs["Settings"], utils.lookup_icon({ icon = 'preferences-desktop' }) },
{ "System Tools", programs["System"], utils.lookup_icon({ icon = 'applications-system' }) },
}
-- Removing empty entries from menu

View File

@ -6,12 +6,15 @@ local table = table
local type = type
local ipairs = ipairs
local pairs = pairs
local lgi = require('lgi')
local Gtk = lgi.Gtk
module("freedesktop.utils")
terminal = 'xterm'
icon_theme = nil
local gtk_icon_theme = Gtk.IconTheme.get_default()
all_icon_sizes = {
'128x128',
@ -23,7 +26,9 @@ all_icon_sizes = {
'32x32',
'24x24',
'22x22',
'16x16'
'16x16',
'8x8',
'scalable'
}
all_icon_types = {
'apps',
@ -59,10 +64,16 @@ function file_exists(filename)
end
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') or arg.icon:find('.+%.svg')) then
-- icons with absolute path and supported (AFAICT) formats
return arg.icon
else
local gtk_icon_info = Gtk.IconTheme.lookup_icon(gtk_icon_theme, arg.icon, 48, 0)
if gtk_icon_info then
filename = Gtk.IconInfo.get_filename(gtk_icon_info)
if filename then return filename end
end
local icon_path = {}
local icon_themes = {}
local icon_theme_paths = {}
@ -97,12 +108,14 @@ function lookup_icon(arg)
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
if (arg.icon:find('.+%.png') or arg.icon:find('.+%.xpm') or arg.icon:find('.+%.svg')) 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'
elseif file_exists(directory .. arg.icon .. '.svg') then
return directory .. arg.icon .. '.svg'
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

View File

@ -26,6 +26,16 @@ theme.taglist_bg_focus = "#3D3D3D"
theme.menu_height = "16"
theme.menu_width = "140"
theme.ocol = "<span color='" .. theme.fg_normal .. "'>"
theme.ccol = "</span>"
theme.tasklist_sticky = theme.ocol .. " [S]" .. theme.ccol
theme.tasklist_ontop = theme.ocol .. " [T]" .. theme.ccol
theme.tasklist_floating = theme.ocol .. " [F]" .. theme.ccol
theme.tasklist_maximized_horizontal = theme.ocol .. "[M] " .. theme.ccol
theme.tasklist_maximized_vertical = ""
theme.tasklist_disable_icon = true
theme.awesome_icon = theme.dir .. "/icons/awesome_icon.png"
theme.menu_submenu_icon = theme.dir .. "/icons/submenu.png"
theme.taglist_squares_sel = theme.dir .. "/icons/square_sel2.png"
theme.taglist_squares_unsel = theme.dir .. "/icons/square_unsel.png"
@ -45,8 +55,13 @@ theme.layout_txt_fullscreen = "[F]"
theme.layout_txt_magnifier = "[M]"
theme.layout_txt_floating = "[*]"
theme.tasklist_floating = ""
theme.tasklist_maximized_horizontal = ""
theme.tasklist_maximized_vertical = ""
theme.layout_txt_tilegaps = "[tg]"
theme.layout_txt_tileleftgaps = "[tlg]"
theme.layout_txt_tilebottomgaps = "[tbg]"
theme.layout_txt_tiletopgaps = "[ttg]"
theme.layout_txt_fairhgaps = "[fhg]"
theme.layout_txt_fairvgaps = "[fvg]"
theme.layout_txt_spiralgaps = "[spg]"
theme.layout_txt_dwindlegaps = "[dwg]"
return theme