1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | require("awful")
require("awful.rules")
require("awful.autofocus")
require("awful.startup_notification")
require("beautiful")
require("vicious")
require("freedesktop.utils")
require("freedesktop.menu")
require("widgets")
require("volume")
require("mpd")
-- Themes file
beautiful.init("/home/sunny/.config/awesome/theme.lua")
-- Default apps
exec = awful.util.spawn
sexec = awful.util.spawn_with_shell
terminal = "urxvtc"
cli_editor = "vim"
gui_editor = "geany"
browser = "luakit"
gui_fm = "pcmanfm"
cli_fm = terminal .. " -e ranger"
system_monitor = terminal .. " -e htop"
media_player = "gnome-mplayer"
music_player = terminal .. " -e ncmpcpp"
smallterminal = terminal .. ' -title "SmallTerm" -geometry 90x7-200-100'
gtk_settings = "lxappearance"
locker = "sflock"
imclient = "pidgin"
torrents = terminal .. " -e rtorrentd"
cwicd = terminal .. " -e wicd-curses"
-- Default modkey.
modkey = "Mod4"
altkey = "Mod1"
-- Set wallpaper
exec("nitrogen --restore", false)
-- Connect to MPD if it wasn't
function start_mpd()
sexec("pidof mpd || mpd")
-- if mpc == nil then mpc = mpd.new() end
end
mpdcontrols = {
start = function()
local f = io.popen("pidof mpd", 'r')
if f then
local s = f:read("*all")
end
f:close()
if s
then exec("killall mpd")
else exec("mpd")
end
end,
play = function()
start_mpd()
mpc:toggle_play()
mpdtimer:emit_signal("timeout")
end,
next = function() mpc:next()
mpdtimer:emit_signal("timeout") end,
prev = function() mpc:previous()
mpdtimer:emit_signal("timeout") end,
stop = function() mpc:stop()
mpdtimer:emit_signal("timeout") end
}
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.bottom,
awful.layout.suit.fair,
awful.layout.suit.tile.top,
awful.layout.suit.spiral,
awful.layout.suit.magnifier,
awful.layout.suit.max,
}
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
tags[s] = awful.tag({ "Alp", "Bet", "Gam", "Del", "Eps" }, s, layouts[1])
end
-- Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle(desktopmenu_args) end),
awful.button({ }, 5, awful.tag.viewnext),
awful.button({ }, 4, awful.tag.viewprev)))
--/// GLOBAL KEYS BINDINGS
globalkeys = awful.util.table.join(
-- Focus
awful.key({ modkey }, "Left",
function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end),
awful.key({ modkey }, "Right",
function () awful.client.focus.byidx( 1) if client.focus then client.focus:raise() end end),
-- Tag control
awful.key({ altkey, "Control" }, "Left", awful.tag.viewprev ),
awful.key({ altkey, "Control" }, "Right", awful.tag.viewnext ),
awful.key({ modkey, }, "Up", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, }, "Down", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, altkey, }, "Up", function () awful.client.incwfact( 0.05) end),
awful.key({ modkey, altkey, }, "Down", function () awful.client.incwfact(-0.05) end),
awful.key({ modkey, "Control" }, "Up", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "Down", function () awful.tag.incncol(-1) end),
awful.key({ modkey, "Shift" }, "Up", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, "Shift" }, "Down", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Awesome restart and quit
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Control" }, "q", awesome.quit),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "Left", function () awful.client.swap.byidx( -1) end),
awful.key({ modkey, "Shift" }, "Right", function () awful.client.swap.byidx( 1) end),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
-- Program shortcuts
awful.key({ modkey, }, "Return", function () exec(terminal, false) end),
awful.key({ modkey }, "r", function () awful.util.spawn("gmrun") end),
awful.key({ modkey, }, "w", function () exec(browser) end),
awful.key({ modkey, }, "f", function () exec(cli_fm) end),
awful.key({ modkey, }, "v", function () exec(media_player) end),
awful.key({ modkey, }, "h", function () exec(system_monitor, false) end),
awful.key({ modkey, }, "e", function () exec(gui_editor) end),
awful.key({ modkey, }, "a", function () exec(gtk_settings) end),
awful.key({ modkey, }, "n", function () exec(music_player, false) end),
awful.key({ modkey, }, "t", function () exec(torrents, false) end),
awful.key({ modkey, }, "l", function () exec(locker, false) end),
awful.key({ modkey, }, "p", function () exec(imclient, true) end),
awful.key({ modkey, altkey }, "w", function () exec(cwicd, false) end),
awful.key({ modkey, altkey }, "Return", function () exec(smallterminal, false) end),
awful.key({ modkey, altkey }, "f", function () exec(gui_fm) end),
awful.key({ modkey, altkey }, "n", function () exec("nitrogen --sort=alpha") end),
awful.key({ modkey, altkey }, "a", function () exec(terminal .. " -e alsamixer", false) end),
awful.key({ }, "XF86Launch2", function () sexec("sudo /home/sunny/.bin/sospendi", false) end),
-- Volume Control
awful.key({ }, "XF86AudioRaiseVolume", function () volumecfg.up() end),
awful.key({ }, "XF86AudioLowerVolume", function () volumecfg.down() end),
awful.key({ }, "XF86AudioMute", function () volumecfg.toggle() end),
-- MPD control
--awful.key({ modkey }, "XF86AudioPlay", function () exec("/home/sunny/bin/mpd-toggle", false) end),
awful.key({ modkey }, "XF86AudioPlay", function () mpdcontrols.start() end),
awful.key({ }, "XF86AudioPlay", function () mpdcontrols.play() end),
awful.key({ }, "XF86AudioStop", function () mpdcontrols.stop() end),
awful.key({ }, "XF86AudioNext", function () mpdcontrols.next() end),
awful.key({ }, "XF86AudioPrev", function () mpdcontrols.prev() end),
-- Menu
awful.key({ modkey }, "Escape", function () mymainmenu:toggle(keymenu_args) end),
awful.key({ altkey }, "Tab", function () awful.menu.menu_keys.down = { "Down", "Alt_L" }
local cmenu = awful.menu.clients({width=245}, keymenu_args ) end)
)
--/// CLIENT KEYS
clientkeys = awful.util.table.join(
-- Kill
awful.key({ modkey }, "c", function (c) c:kill() end),
-- Floating
awful.key({ altkey }, "space", awful.client.floating.toggle ),
-- Swap to master
awful.key({ altkey }, "Return", function (c) c:swap(awful.client.getmaster()) end),
-- Redraw
awful.key({ modkey }, "F1", function (c) c:redraw() end),
-- Fullscreen
awful.key({ modkey }, "F11", function (c) c.fullscreen = not c.fullscreen end),
-- On Top
awful.key({ modkey }, "F5", function (c) c.ontop = not c.ontop end),
-- Remove Titlebars
awful.key({ modkey }, "F3", function (c) if c.titlebar then awful.titlebar.remove(c) else awful.titlebar.add(c) end end),
-- Move to center
awful.key({ modkey }, "#84", function (c) awful.placement.centered(c) end),
awful.key({ modkey }, "#79", function (c) awful.placement.center_horizontal(c) end),
awful.key({ modkey }, "#87", function (c) awful.placement.center_vertical(c) end),
-- Toggle full maximize
awful.key({ altkey }, "#84", function (c) c.maximized_horizontal, c.maximized_vertical = not c.maximized_horizontal, not c.maximized_vertical end),
-- Toggle vertical maximize
awful.key({ modkey }, "KP_Next", function (c) c.maximized_vertical = not c.maximized_vertical end),
-- Toggle horizontal maximize
awful.key({ modkey }, "KP_Prior", function (c) c.maximized_horizontal = not c.maximized_horizontal end),
-- Move clients (up,down,left,right)
awful.key({ modkey }, "#80", function (c) awful.client.moveresize( 0,-30, 0, 0) end),
awful.key({ modkey }, "#88", function (c) awful.client.moveresize( 0, 30, 0, 0) end),
awful.key({ modkey }, "#83", function (c) awful.client.moveresize(-30, 0, 0, 0) end),
awful.key({ modkey }, "#85", function (c) awful.client.moveresize( 30, 0, 0, 0) end),
-- To margins (up,down,left,right)
awful.key({modkey,altkey}, "#80", function (c) local g = c:geometry(); g.y = 16; c:geometry(g) end),
awful.key({modkey,altkey}, "#88", function (c) local g, screen_area = c:geometry(), screen[c.screen].workarea
g.y = screen_area.y + screen_area.height - g.height
c:geometry(g) end),
awful.key({modkey,altkey}, "#83", function (c) local g = c:geometry(); g.x= 0; c:geometry(g) end),
awful.key({modkey,altkey}, "#85", function (c) local g, screen_area = c:geometry(), screen[c.screen].workarea
g.x = screen_area.x + screen_area.width - g.width
c:geometry(g) end),
-- Resize clients (up,down,left,right)
awful.key({ altkey, }, "#80", function (c) awful.client.moveresize( 0, 0, 0,-30) end),
awful.key({ altkey, }, "#88", function (c) awful.client.moveresize( 0, 0, 0, 30) end),
awful.key({ altkey, }, "#83", function (c) awful.client.moveresize( 0, 0,-30, 0 ) end),
awful.key({ altkey, }, "#85", function (c) awful.client.moveresize( 0, 0, 30, 0 ) end)
)
--///
-- Compute the maximum number of digit we need, limited to 9
keynumber = 5
--[[keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end]]
-- Bind all key numbers to tags.
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_focus,
focus = true,
keys = clientkeys,
buttons = clientbuttons,
size_hints_honor = true, },},
{ rule = { class = 'URxvt' }, properties = { size_hints_honor = false } },
{ rule_any = { class = { "MPlayer", "Gnome-mplayer", "sxiv", "Viewnior" }, },
properties = { floating = true },},
{ rule = { name = "SmallTerm" },
properties = { floating = true, ontop = true, },},
}
-- Signals
client.add_signal("manage", function (c, startup)
awful.client.setslave(c)
if not startup then
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
end)
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
--// Set cursor theme //--
--exec("xsetroot -cursor_name left_ptr", false)
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | --// Main
theme = {}
theme.wallpaper_cmd = { " " }
--//
--/// Styles
theme.font = "montecarlo 7"
--themedir2 = "~/.config/awesome/themes/buttons"
themedir = "~/.config/awesome/themes"
--// Colors
theme.fg_normal = "#719f9f"
theme.fg_focus = "#ff6565"
theme.fg_urgent = "#000000"
theme.bg_normal = "#080808"
theme.bg_focus = "#121212"
theme.bg_urgent = "#ffc0c0"
--//
--// Borders
theme.border_width = "1"
theme.border_normal = "#121212"
theme.border_focus = theme.fg_normal
theme.border_marked = "#000000"
--//
--// Titlebars
theme.titlebar_fg_normal = "#808080"
theme.titlebar_fg_focus = "#ffffff"
theme.titlebar_bg_normal = "#363636ff"
theme.titlebar_bg_focus = "#000000ff"
theme.titlebar_font = theme.font or "cure 8"
--//
-- There are other variable sets
-- overriding the default one when
-- defined, the sets are:
-- [taglist|tasklist]_[bg|fg]_[focus|urgent]
-- titlebar_[normal|focus]
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
-- Example:
theme.taglist_bg_focus = theme.fg_focus
theme.taglist_fg_focus = theme.bg_normal
theme.taglist_bg_not_empty = "#404040"
theme.taglist_fg_not_empty = "#808080"
--theme.tasklist_bg_focus = theme.bg_normal
--////
--// Menu
-- Variables set for theming the menu:
-- menu_[bg|fg]_[normal|focus]
-- menu_[border_color|border_width]
theme.menu_bg_normal = "#101010ff"
theme.menu_bg_focus = "#000000ff"
theme.menu_fg_normal = theme.fg_normal
theme.menu_fg_focus = theme.fg_focus
theme.menu_border_width = "0"
theme.menu_height = "18"
theme.menu_width = "150"
--//
icon_dir = "~/.config/awesome/icons"
--//// Icons
--// Taglist
theme.taglist_squares_sel = themedir .."/taglist/squarefz.png"
theme.taglist_squares_unsel = themedir .."/taglist/squarez.png"
theme.taglist_squares_resize = "false"
--//
--// Misc
--theme.awesome_icon = themedir .."/awesome-icon.png"
--theme.menu_submenu_icon = "~/.config/awesome/themes/default/submenu.png"
--theme.tasklist_floating_icon = "~/.config/awesome/themes/default/tasklist/floatingw.png"
--//
--// Layout
theme.layout_tile = themedir .."/layouts/tile.png"
theme.layout_tileleft = themedir .."/layouts/tileleft.png"
theme.layout_tilebottom = themedir .."/layouts/tilebottom.png"
theme.layout_tiletop = themedir .."/layouts/tiletop.png"
theme.layout_fairv = themedir .."/layouts/fairv.png"
theme.layout_fairh = themedir .."/layouts/fairh.png"
theme.layout_spiral = themedir .."/layouts/spiral.png"
theme.layout_dwindle = themedir .."/layouts/dwindle.png"
theme.layout_max = themedir .."/layouts/max.png"
theme.layout_fullscreen = themedir .."/layouts/fullscreen.png"
theme.layout_magnifier = themedir .."/layouts/magnifier.png"
theme.layout_floating = themedir .."/layouts/floating.png"
--//
--// Titlebar
--[[theme.titlebar_close_button_focus = themedir .."/close-focused.png"
theme.titlebar_close_button_normal = themedir .."/close-unfocused.png"
theme.titlebar_maximized_button_focus_active = themedir .."/maximize-focused.png"
theme.titlebar_maximized_button_normal_active = themedir .."/maximize-unfocused.png"
theme.titlebar_maximized_button_focus_inactive = themedir .."/maximize-focused.png"
theme.titlebar_maximized_button_normal_inactive = themedir .."/maximize-unfocused.png"]]
--//
--////
return theme
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | require("awful")
require("beautiful")
require("vicious")
require("mainmenu")
require("freedesktop.utils")
require("freedesktop.menu")
require("volume")
require("mpd")
beautiful.init("/home/sunny/.config/awesome/theme.lua")
-- MainMenu
mymainmenu = myrc.mainmenu.build()
mylauncher = widget({ type = "textbox" })
mylauncher.text = ' <span color="'..beautiful.fg_focus..'" > MENU</span>'
mylauncher:buttons(awful.util.table.join( awful.button({}, 1, nil, function () mymainmenu:toggle(mainmenu_args) end)))
mainmenu_args = { coords={ x=0, y=0 }, keygrabber = true }
desktopmenu_args = { keygrabber = true }
keymenu_args = { coords={ x=200, y=100 }, keygrabber = true }
-- text color
focus_col = '<span color="'..beautiful.fg_focus..'">'
null_col = '</span>'
colors = {
black = '<span color="#202020" >',
red = '<span color="#ff6565" >',
green = '<span color="#93d44f" >',
yellow = '<span color="#eab93d" >',
blue = '<span color="#204a87" >',
magenta = '<span color="#ce5c00" >',
cyan = '<span color="#89b6e2" >',
white = '<span color="#cccccc" >',
null = '</span>'
}
-- Icon dir
icon_dir = awful.util.getdir("config") .. "/icons/"
-- Start a layoutbox
mylayoutbox = {}
-- Taglist
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
)
-- Clock widget
datewidget = widget({ type = "textbox" })
vicious.register(datewidget, vicious.widgets.date, '<span font="dina 9">'..colors.white..'%a %d %b'..colors.null..'</span>', 10)
--// CPU widget
-- Icon
cpuicon = widget({ type = "imagebox" })
cpuicon.image = image(icon_dir .. "cpu.png")
-- Text
cpuperc = widget({ type = "textbox" })
cpuperc.width = "30"
cpuperc.align = "left"
vicious.register(cpuperc, vicious.widgets.cpu, ' '..colors.red..'$1'..colors.null..' ', 1)
--// Mem Widget
-- Icon
memicon = widget({ type = "imagebox" })
memicon.image = image(icon_dir .. "mem.png")
-- Text
memwidget = widget({ type = "textbox" })
memwidget.align = "left"
vicious.register(memwidget, vicious.widgets.mem, ' '..colors.green..'$1'..colors.null..' $2MB', 17)
--// Battery widget
-- Icon
baticon = widget({ type = "imagebox" })
baticon.image = image(icon_dir .. "bat_full_01.png")
-- Text
batwidget = widget({ type = "textbox" })
batwidget.align = "left"
vicious.register(batwidget, vicious.widgets.bat, ' '..colors.yellow..'$2%'..colors.null..' $1', 23, "BAT0")
--// Temp widget
-- Icon
tempicon = widget({ type = "imagebox" })
tempicon.image = image(icon_dir .. "temp.png")
-- Text
tempwidget1, tempwidget2 = widget({ type = "textbox" }), widget({ type = "textbox" })
tempwidget1.align, tempwidget2.align = "left", "left"
vicious.register(tempwidget1, vicious.widgets.thermal, ' '..colors.blue..'$1'..colors.null..'', 43, "thermal_zone0")
vicious.register(tempwidget2, vicious.widgets.thermal, ' '..colors.blue..'$1'..colors.null..' C', 43, "thermal_zone1")
--/// Net Widget
--neticon = widget({ type = "imagebox" })
netwidget = widget({ type = "textbox" })
netwidget.width = "120"
netwidget.align = "left"
vicious.register(netwidget, vicious.widgets.net,
function (widget, args)
if args["{eth0 carrier}"] == 1
then
-- neticon.image = image(icon_dir .. "/usb.png")
return ' U '..colors.magenta..args["{eth0 up_kb}"]..colors.null..' D '..colors.magenta..args["{eth0 down_kb}"]..colors.null..''
elseif args["{wlan0 carrier}"] == 1
then
-- neticon.image = image(icon_dir .. "/wifi_01.png")
return ' U '..colors.magenta..args["{wlan0 up_kb}"]..colors.null..' D '..colors.magenta..args["{wlan0 down_kb}"]..colors.null..''
else
-- neticon.image = image(icon_dir .. "/empty.png")
return 'Netwok Disabled '
-- end
end
end, 1)
--///
function escape_xml(text)
xml_entities = {
["\""] = """,
["&"] = "&",
["'"] = "'",
["<"] = "<",
[">"] = ">"
}
return text and text:gsub("[\"&'<>]", xml_entities)
end
--/// MPD widget ///
-- Inizialize widgets
mpdwidget = widget({ type = "textbox" })
mpdwidget.align = "left"
mpdicon = widget({ type = "imagebox" })
-- Connect to MPD
mpc = mpd:new()
-- Build mpd widget
function widget_mpd(widget, icon)
local status = mpc:send('status')
local state = status.state
local current = mpc:send('currentsong')
local artist, title, elapsed, totaltime
local running = true
-- Icon table
local icon_dir = awful.util.getdir("config").."/icons/"
local icons = {
play = icon_dir.."/play.png",
pause = icon_dir.."/pause.png",
stop = icon_dir.."/stop.png",
none = icon_dir.."/empty.png",
unknow = icon_dir.."/half.png"
}
-- Get the state and define the icon widget
if state == "stop" then icon.image = image(icons.stop)
elseif state == "pause" then icon.image = image(icons.pause)
elseif state == "play" then icon.image = image(icons.play)
elseif state == nil then icon.image = image(icons.none)
local running = false
else icon.image = image(icons.unknow)
end
-- Get title and artist
if running then
-- get artist
artist = escape_xml(current.artist)
if artist == nil then artist = "[n/a]" end
-- get title
title = escape_xml(current.title)
if title == nil then
title = string.gsub(escape_xml(current.file), ".*/", "")
if title == nil then title = "[n/a]" end
end
-- get time
local elapsed, totaltime = status.elapsed, current.time
if elapsed == nil then elapsed = 0 end
if totaltime == nil then totaltime = 0 end
elapsed = string.format("%d:%2.0f", tonumber(elapsed)/60, tonumber(elapsed)%60)
totaltime = string.format("%d:%2.0f", totaltime/60, totaltime%60)
if (elapsed == nil) or (totaltime == nil) then elapsed, totaltime = "--", "--" end
-- Put the text in the widget
widget.text = string.format("%s%s%s - %s [%s%s%s/%s]", colors.cyan, title, colors.null, artist, colors.cyan, elapsed, colors.null, totaltime)
else
widget.text = ' MPD is closed '
end
end
-- Start mpd widget
widget_mpd(mpdwidget, mpdicon)
-- Define timer and start it
mpdtimer = timer({ timeout = 2 })
mpdtimer:add_signal("timeout", function() widget_mpd(mpdwidget, mpdicon) end)
mpdtimer:start()
--/// Volume icon ///
volicon = widget({ type = "imagebox" })
volicon.image = image(icon_dir .. "spkr_01.png")
--/// Separator ///
sep = widget({ type = "textbox", align = "center" })
sep.text = '<span color="#404040" > | </span>'
--/// DRAW WIDGETS
for s = 1, screen.count() do
--// Layoutbox //
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end)
))
--// Taglist //
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
--// I Wibox
mywibox = {}
mywibox[s] = awful.wibox({ position = "top", height = "16", screen = s })
mywibox[s].widgets = {
{
mytaglist[s], sep,
mpdicon, mpdwidget,
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s], sep,
datewidget, sep,
volumetext, volicon, sep,
batwidget, baticon, sep,
tempwidget2, tempwidget1, tempicon, sep,
memwidget, memicon, sep,
cpuperc, cpuicon, sep,
netwidget, --neticon,
layout = awful.widget.layout.horizontal.rightleft
}
-- mywibox[s].border_width = "1"
-- mywibox[s].border_color = "#3d5454"
-- mywibox[s].width = "1364"
--//
end
--///
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | local awful = require("awful")
local beautiful = require("beautiful")
local freedesktop_utils = require("freedesktop.utils")
local freedesktop_menu = require("freedesktop.menu")
local io = io
local table = table
local awesome = awesome
local ipairs = ipairs
local os = os
local string = string
local mouse = mouse
module("myrc.mainmenu")
-- Creates main menu
-- Note: Uses beautiful.icon_theme and beautiful.icon_theme_size
-- env - table with string constants - command line to different apps
function build()
local terminal = "urxvtc "
local man = "urxvtc -e man "
local editor = "urxvtc -e vim "
local browser = "luakit "
local run = "gmrun "
local fileman = terminal .. " -e ranger "
local torrent = terminal .. " -e rtorrentd "
local messenger = "pidgin"
local myawesomemenu = {
{ "Edit config", editor .. awful.util.getdir("config") .. "/rc.lua"},
{ "Edit theme", editor .. awful.util.getdir("config") .. "/theme.lua" },
{ "Edit widgets", editor .. awful.util.getdir("config") .. "/widgets.lua" },
{ "Edit main menu", editor .. awful.util.getdir("config") .. "/mainmenu.lua" },
{ "Restart", awesome.restart },
{ "Stop", awesome.quit }
}
local appmenu_items = {}
for _, item in ipairs(freedesktop_menu.new()) do table.insert(appmenu_items, item) end
local mymainmenu_items = {
{ "Run", run, },
{ "Terminal", terminal, },
{ "FileMan", fileman, },
{ "Browser", browser, },
{ "Torrent", torrent, },
{ "Pidgin", messenger, },
{ "< AppMenu >", appmenu_items, },
{ "Awesome", myawesomemenu, },
{ "Halt", shutdown, }
}
return awful.menu({ items = mymainmenu_items })
end
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | require("awful")
require("beautiful")
beautiful.init("/home/sunny/.config/awesome/theme.lua")
--/// Volume Config and widget
volumecfg = {}
volumecfg.cardid = 0
volumecfg.channel = "Master"
volumetext = widget({ type = "textbox", name = "volumetext" })
volumetext.align = "left"
-- command must start with a space!
volumecfg.mixercommand = function (command)
local fd = io.popen("amixer -c " .. volumecfg.cardid .. command)
local status = fd:read("*all")
fd:close()
local volume = string.match(status, "(%d?%d?%d)%%")
volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
if string.find(status, "on", 1, true) then
volume = volume
else
volume = "MUTE"
end
volumetext.text = '<span color="'..beautiful.fg_focus..'">'..volume..'</span>'
end
volumecfg.update = function () volumecfg.mixercommand(" sget " .. volumecfg.channel) end
volumecfg.up = function () volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1+") end
volumecfg.down = function () volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1-") end
volumecfg.toggle = function () volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle") end
volumetext:buttons(awful.util.table.join(
awful.button({ }, 4, function () volumecfg.up() end),
awful.button({ }, 5, function () volumecfg.down() end),
awful.button({ }, 1, function () volumecfg.toggle() end),
awful.button({ }, 3, function () exec(terminal .. " -e alsamixer") end)))
volumecfg.update()
volumetimer = timer({ timeout = 30 })
volumetimer:add_signal( "timeout", function() volumecfg.update() end)
volumetimer:start()
--///
|
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | --
-- _ _
-- | |_ _ __ _ _ __ ___ _ __ __| |
-- | | | | |/ _` |_____| '_ ` _ \| '_ \ / _` |
-- | | |_| | (_| |_____| | | | | | |_) | (_| |
-- |_|\__,_|\__,_| |_| |_| |_| .__/ \__,_|
-- |_|
--
-- Small interface to MusicPD
-- use luasocket, with a persistant connection to the MPD server.
--
-- based on a netcat version from Steve Jothen <sjothen at gmail dot com>
-- (see http://modeemi.fi/~tuomov/repos/ion-scripts-3/scripts/mpd.lua)
--
--
-- Copyright (c) 2008-2009, Alexandre Perrin <kaworu@kaworu.ch>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
--
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 4. Neither the name of the author nor the names of its contributors
-- may be used to endorse or promote products derived from this software
-- without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
require("socket")
-- Grab env
local socket = socket
local string = string
local tonumber = tonumber
local setmetatable = setmetatable
local os = os
-- Music Player Daemon Lua library.
module("mpd")
MPD = {
} MPD_mt = { __index = MPD }
-- create and return a new mpd client.
-- the settings argument is a table with theses keys:
-- hostname: the MPD's host (default localhost)
-- port: MPD's port to connect to (default 6600)
-- desc: server's description (default hostname)
-- password: the server's password (default nil, no password)
-- timeout: time in sec to wait for connect() and receive() (default 1)
-- retry: time in sec to wait before reconnect if error (default 60)
function new(settings)
local client = {}
if settings == nil then settings = {} end
client.hostname = settings.hostname or "localhost"
client.port = settings.port or 6600
client.desc = settings.desc or client.hostname
client.password = settings.password
client.timeout = settings.timeout or 1
client.retry = settings.retry or 60
setmetatable(client, MPD_mt)
return client
end
-- calls the action and returns the server's response.
-- Example: if the server's response to "status" action is:
-- volume: 20
-- repeat: 0
-- random: 0
-- playlist: 599
-- ...
-- then the returned table is:
-- { volume = 20, repeat = 0, random = 0, playlist = 599, ... }
--
-- if an error arise (bad password, connection failed etc.), a table with only
-- the errormsg field is returned.
-- Example: if there is no server running on host/port, then the returned
-- table is:
-- { errormsg = "could not connect" }
--
function MPD:send(action)
local command = string.format("%s\n", action)
local values = {}
-- connect to MPD server if not already done.
if not self.connected then
local now = os.time();
if not self.last_try or (now - self.last_try) > self.retry then
self.socket = socket.tcp()
self.socket:settimeout(self.timeout, 't')
self.last_try = os.time()
self.connected = self.socket:connect(self.hostname, self.port)
if not self.connected then
return { errormsg = "could not connect" }
end
-- Read the server's hello message
local line = self.socket:receive("*l")
if not line:match("^OK MPD") then -- Invalid hello message?
self.connected = false
return { errormsg = string.format("invalid hello message: %s", line) }
else
_, _, self.version = string.find(line, "^OK MPD ([0-9.]+)")
end
-- send the password if needed
if self.password then
local rsp = self:send(string.format("password %s", self.password))
if rsp.errormsg then
return rsp
end
end
else
local retry_sec = self.retry - (now - self.last_try)
return { errormsg = string.format("could not connect (retrying in %d sec)", retry_sec) }
end
end
self.socket:send(command)
local line = ""
while not line:match("^OK$") do
line = self.socket:receive("*l")
if not line then -- closed,timeout (mpd killed?)
self.connected = false
return self:send(action)
end
if line:match("^ACK") then
return { errormsg = line }
end
local _, _, key, value = string.find(line, "([^:]+):%s(.+)")
if key then
values[string.lower(key)] = value
end
end
return values
end
function MPD:next()
return self:send("next")
end
function MPD:previous()
return self:send("previous")
end
function MPD:stop()
return self:send("stop")
end
-- no need to check the new value, mpd will set the volume in [0,100]
function MPD:volume_up(delta)
local stats = self:send("status")
local new_volume = tonumber(stats.volume) + delta
return self:send(string.format("setvol %d", new_volume))
end
function MPD:volume_down(delta)
return self:volume_up(-delta)
end
function MPD:toggle_random()
local stats = self:send("status")
if tonumber(stats.random) == 0 then
return self:send("random 1")
else
return self:send("random 0")
end
end
function MPD:toggle_repeat()
local stats = self:send("status")
if tonumber(stats["repeat"]) == 0 then
return self:send("repeat 1")
else
return self:send("repeat 0")
end
end
function MPD:toggle_play()
if self:send("status").state == "stop" then
return self:send("play")
else
return self:send("pause")
end
end
function MPD:seek(delta)
local stats = self:send("status")
local current = stats.time:match("^(%d+):")
return self:send(string.format("seek %d %d", stats.songid, current + delta))
end
function MPD:protocol_version()
if not self.version then
-- send a "status" command to init the connection
local s = self:send("status")
if s.errormsg then
return nil, s
end
end
return self.version
end
-- vim:filetype=lua:tabstop=8:shiftwidth=4:expandtab:
|
x
Notes
25th June 2011
my current desktop
I have a modular configuration for my AwesomeWM so I’m only going to post a link to a tarball that contain my ~/.config/awesome folder
For the widgets you need vicious (most of widgets in the top bar) and luasocket (for the mpd widget)
EDIT: Added widgets.lua, mainmenu.lua, volume.lua and mpd.lua
For the mpd.lua you still need luasocket
for mainmenu.lua you need the freedesktop folder that you can found in the dl link
Thanks Anomareth for the advice
enjoy :)
dipilibupap said about 13 years ago
Everything is coherent. Well done :)
spo11 said about 13 years ago
Love the wallpaper.
Reventlov said about 13 years ago
Hello .
Very nice screenshot !
This is awesome 3 ? Can you paste yor rc.lua ?
Thanks.
Anomareh said about 13 years ago
@SuNjACk I know you posted this before multi-file support was launched, but even before then it would be preferred if you could post a main file like rc.lua or theme.lua and link to a dl of the entire setup in the notes rather than just putting the dl link as the dot.
I’ve gone ahead and edited it for you, feel free to add the other files, or change it as you please, just don’t have the dot contain only the dl link.
Thanks for sharing and welcome to DotShare :]
SuNjACk said about 13 years ago
@Anomareh
Ok, I’m going to correct it ;)
rstrcogburn said about 13 years ago
Heel yeah sunny. Love this one. It’s got all your style in it… Rock, Your amazing conky, those colors that you do so well, and Awesome+Arch of course. GOod job.
SuNjACk said about 13 years ago
Thanks rstrcogburn, I really appreciate it :)
numbchild said about 12 years ago
@SuNjACk Can you share you conky config files ??
dvrts said about 9 years ago
Which version of Awesome is here?