Guest User

Untitled

a guest
Mar 28th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.81 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Theme handling library
  6. require("beautiful")
  7. -- Notification library
  8. require("naughty")
  9. require("vicious")
  10.  
  11.  
  12. -- space between icons
  13. space = 40
  14.  
  15.  
  16. -- Handle runtime errors after startup
  17. do
  18. local in_error = false
  19. awesome.add_signal("debug::error", function (err)
  20. -- Make sure we don't go into an endless error loop
  21. if in_error then return end
  22. in_error = true
  23.  
  24. naughty.notify({ preset = naughty.config.presets.critical,
  25. title = "time to debug",
  26. text = err,
  27. timeout = 1 })
  28. in_error = false
  29. end)
  30. end
  31.  
  32. -- {{{ Error handling
  33. -- Check if awesome encountered an error during startup and fell back to
  34. -- another config (This code will only ever execute for the fallback config)
  35. if awesome.startup_errors then
  36. naughty.notify({ preset = naughty.config.presets.critical,
  37. title = "Oops, there were errors during startup!",
  38. text = awesome.startup_errors })
  39. end
  40.  
  41.  
  42.  
  43.  
  44. -- }}}
  45.  
  46. -- {{{ Variable definitions
  47. -- Themes define colours, icons, and wallpapers
  48. beautiful.init("/usr/share/awesome/themes/redhalo/theme.lua")
  49.  
  50. -- This is used later as the default terminal and editor to run.
  51. config = awful.util.getdir("config")
  52. terminal = "urxvt"
  53. editor = os.getenv("EDITOR") or "vim"
  54. editor_cmd = terminal .. " -e " .. editor
  55. exec = awful.util.spawn
  56. sexec = awful.util.spawn_with_shell
  57.  
  58. -- Default modkey.
  59. -- Usually, Mod4 is the key with a logo between Control and Alt.
  60. -- If you do not like this or do not have such a key,
  61. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  62. -- However, you can use another modifier like Mod1, but it may interact with others.
  63. modkey = "Mod4"
  64. winkey = "Mod4"
  65. altkey = "Mod1"
  66.  
  67. barheight = 16
  68. borderwidth = 0
  69.  
  70.  
  71.  
  72. -- Table of layouts to cover with awful.layout.inc, order matters.
  73. layouts =
  74. {
  75. awful.layout.suit.floating,
  76. awful.layout.suit.tile,
  77. awful.layout.suit.tile.left,
  78. awful.layout.suit.tile.bottom,
  79. awful.layout.suit.tile.top,
  80. awful.layout.suit.fair,
  81. awful.layout.suit.fair.horizontal,
  82. awful.layout.suit.spiral,
  83. awful.layout.suit.spiral.dwindle,
  84. awful.layout.suit.max,
  85. awful.layout.suit.max.fullscreen,
  86. awful.layout.suit.magnifier
  87. }
  88. -- }}}
  89.  
  90. -- {{{ Tags
  91. -- Define a tag table which hold all screen tags.
  92. tags = {
  93. -- names = { "intrntbrn:", "www >", "dev >", "mail >", "media >", "pdf >", "☊"},
  94. -- names = { "intrntbrn:", "/web ", "/dev ", "/mail ", "/media ", "/pdf ", "/mpd"},
  95. names = { "sys", "web", "doc", "dev", "irc", "foo"},
  96. -- names = { "α ", "β ", "δ ", "ε ", "ζ "},
  97.  
  98. layout = { layouts[1], layouts[10], layouts[8], layouts[8], layouts[2], layouts[1]
  99. }}
  100.  
  101. for s = 1, screen.count() do
  102. tags[s] = awful.tag(tags.names, s, tags.layout)
  103. end
  104. -- }}}
  105.  
  106. -- {{{ Menu
  107. -- Create a laucher widget and a main menu
  108. myawesomemenu = {
  109. { "edit rc.lua", function () sexec("medit -t rc.lua") end},
  110. { "edit theme", function () sexec("gvim /usr/share/awesome/themes/redhalo/theme.lua") end },
  111. { "testmode", function () sexec("bash ~/bin/awsm.sh") end},
  112. { "restart", awesome.restart },
  113. { "quit", awesome.quit }
  114. }
  115.  
  116. mysystemmenu = {
  117. { "shutdown", function () sexec("sudo shutdown -h 0") end},
  118. { "reboot", function () sexec("sudo reboot") end},
  119. { "lock", function () sexec("slimlock") end},
  120. { "suspend", function () sexec("sudo pm-suspend") end},
  121. { "hibernate", function () sexec("sudo pm-hibernate") end}
  122. }
  123.  
  124. myfoldermenu = {
  125. { "Downloads", function () exec("thunar Downloads") end},
  126. { "Movies", function () exec("spacefm HDD/Film") end},
  127. { "Music", function () exec("spacefm HDD/Musik") end},
  128. { "Downloads JD", function () exec("spacefm HDD/Downloads_JD") end},
  129. { "Workspace", function () exec("spacefm Workspace") end},
  130. { "Dropbox W", function () exec("spacefm /Dropbox/WORKSPACE") end},
  131. { "Netbeans", function () exec("spacefm Workspace/NetBeansProjects") end},
  132. { "SE", function () exec("spacefm Dropbox/SS2011/SS2012/SE") end},
  133. { "DB", function () exec("spacefm Dropbox/SS2011/SS2012/Datenbanken") end},
  134. { "MPS", function () exec("spacefm Dropbox/SS2011/SS2012/MPS-ARM") end},
  135. { "OS", function () exec("spacefm Dropbox/SS2011/SS2012/Betriebssysteme") end},
  136. }
  137.  
  138. myappmenu = {
  139. { "mp3", terminal .. " -e ncmpcpp"},
  140. { "mail", "xterm -e alpine"},
  141. { "jabber", terminal .. " -e mcabber" },
  142. { "irc", terminal .. " -e weechat-curses" },
  143. { "watch tv", "vlc Downloads/stream.m3u" },
  144. { "eclipse", "eclipse" },
  145. { "netbeans", function () sexec("netbeans --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel") end},
  146. { "mplayer", function () exec("gnome-mplayer") end},
  147. { "vlc", function () exec("vlc") end},
  148. { "gimp", function () exec("gimp") end},
  149. { "jdownloader", function () exec("jdownloader") end},
  150. { "pidgin", function () exec("pidgin") end},
  151. { "dwb", function () exec("dwb") end},
  152. { "firefox", function () exec("firefox") end},
  153. { "calculator", function () exec("gnome-calculator") end}
  154. }
  155.  
  156.  
  157. mymainmenu = awful.menu({ items = { { "folder", myfoldermenu, "/usr/share/awesome/icons/ontop_focus_inactive.png" },
  158. { "system", mysystemmenu, "/usr/share/awesome/icons/arch-red.png" },
  159. { "awesome", myawesomemenu, "/usr/share/awesome/icons/awesome-blue.png" },
  160. { "applications", myappmenu, "/usr/share/awesome/icons/arch-green.png" },
  161. { "terminal", terminal },
  162. { "browser", function () exec("dwb") end},
  163. { "filemanager", function () exec("spacefm") end},
  164. { "editor", function () sexec("medit -t") end},
  165. { "youtube", terminal .. " -e youtube-viewer"}
  166. }
  167. })
  168.  
  169. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  170. menu = mymainmenu })
  171. -- }}}
  172.  
  173. -- {{{ Wibox
  174. -- Create a textclock widget
  175.  
  176. --"%a %d %b %H:%M"
  177. --mytextclock = awful.widget.textclock({ align = "right",}, "%a, %d. %b - %H:%M", 60)
  178. --mytextclock = awful.widget.textclock({ align = "right" })
  179. mytextclock = awful.widget.textclock({ align = "right",}, "%H:%M", 60)
  180. mytextclock.width = space
  181.  
  182. --test oocairo
  183. require("blingbling")
  184.  
  185. my_cal =blingbling.calendar.new({type = "imagebox", image = "/usr/share/awesome/icons/blind-alien/icons/clock_blue.png"})
  186. my_cal:set_cell_padding(2)
  187. my_cal:set_title_font_size(8)
  188. my_cal:set_font_size(8)
  189. my_cal:set_inter_margin(1)
  190. my_cal:set_columns_lines_titles_font_size(8)
  191. my_cal:set_columns_lines_titles_text_color("#1692d0ff")
  192. my_cal:set_link_to_external_calendar(true)
  193.  
  194.  
  195.  
  196.  
  197. -- Create a systray
  198. mysystray = widget({ type = "systray" })
  199.  
  200. -- Create a wibox for each screen and add it
  201. mywibox = {}
  202. mywib = {}
  203. mypromptbox = {}
  204. mylayoutbox = {}
  205. mytaglist = {}
  206. mytaglist.buttons = awful.util.table.join(
  207. awful.button({ }, 1, awful.tag.viewonly),
  208. awful.button({ modkey }, 1, awful.client.movetotag),
  209. awful.button({ }, 3, awful.tag.viewtoggle),
  210. awful.button({ modkey }, 3, awful.client.toggletag),
  211. awful.button({ }, 4, awful.tag.viewnext),
  212. awful.button({ }, 5, awful.tag.viewprev)
  213. )
  214. mytasklist = {}
  215. mytasklist.buttons = awful.util.table.join(
  216. awful.button({ }, 1, function (c)
  217. if c == client.focus then
  218. -- c.minimized = true
  219. client.focus = c
  220. c:swap(awful.client.getmaster())
  221. else
  222. if not c:isvisible() then
  223. awful.tag.viewonly(c:tags()[1])
  224. client.focus = c
  225. c:swap(awful.client.getmaster())
  226. end
  227. -- This will also un-minimize
  228. -- the client, if needed
  229. client.focus = c
  230. c:raise()
  231. c:swap(awful.client.getmaster())
  232. end
  233. end),
  234. awful.button({ }, 3, function ()
  235. if instance then
  236. instance:hide()
  237. instance = nil
  238. else
  239. instance = awful.menu.clients({ width=250 })
  240. end
  241. end),
  242. awful.button({ }, 4, function ()
  243. awful.client.focus.byidx(1)
  244. if client.focus then client.focus:raise() end
  245. end),
  246. awful.button({ }, 8, function ()
  247. awful.client.focus.byidx(-1)
  248. if client.focus then client.focus:raise() end
  249. end),
  250. -- middle mouse
  251. awful.button({ }, 0, function (c)
  252. if c == client.focus then
  253. c.minimized = true
  254. else
  255. client.focus = c
  256. c:raise()
  257. end
  258. end))
  259.  
  260. for s = 1, screen.count() do
  261. -- Create a promptbox for each screen
  262. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  263. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  264. -- We need one layoutbox per screen.
  265. mylayoutbox[s] = awful.widget.layoutbox(s)
  266. mylayoutbox[s]:buttons(awful.util.table.join(
  267. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  268. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  269. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  270. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  271. -- Create a taglist widget
  272. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  273.  
  274. -- Create a tasklist widget
  275. mytasklist[s] = awful.widget.tasklist(function(c)
  276. return awful.widget.tasklist.label.currenttags(c, s)
  277. end, mytasklist.buttons)
  278.  
  279.  
  280.  
  281.  
  282.  
  283. -- spacer
  284. spacer = widget({ type = "textbox" })
  285. spacer.text = " "
  286.  
  287.  
  288. -- WLAN UP DOWN
  289. netwidget = widget({ type = "textbox" })
  290. vicious.register(netwidget, vicious.widgets.net,
  291. function (widget, args)
  292. if (args["{wlan0 down_kb}"] ~= nil) then
  293. return round(args["{wlan0 down_kb}"], 0) .. "kb"
  294.  
  295. else
  296. return ""
  297. end
  298. end)
  299. netwidget.width = space
  300.  
  301. neticon = widget({ type = "imagebox" })
  302. neticon.image = image("/home/intrntbrn/icons/netdown_blue.png")
  303.  
  304. -- WLAN widget
  305. wlanwidget = widget({ type = "textbox" })
  306. --vicious.register(wlanwidget, vicious.widgets.wifi, "${link}%", 10, "wlan0")
  307. vicious.register(wlanwidget, vicious.widgets.wifi,
  308. function (widget, args)
  309. if (args["{link}"] == 0) then
  310. netwidget.width = 0
  311. netwidget.visible = false
  312. neticon.visible = false
  313. return "off"
  314. else
  315. netwidget.width = space
  316. netwidget.visible = true
  317. neticon.visible = true
  318. return round(((args["{link}"] *100) / 70), 0) .. "%"
  319.  
  320. end
  321. end, 10, "wlan0")
  322.  
  323. wlanwidget.width = space
  324.  
  325. wlanicon = widget({ type = "imagebox" })
  326. wlanicon.image = image("/home/intrntbrn/icons/wifi_blue.png")
  327.  
  328.  
  329. -- mem load
  330. mymem = widget({ type = "textbox" })
  331. vicious.register(mymem, vicious.widgets.mem, "$1%", 30)
  332. mymem.width = space
  333.  
  334. mymemicon = widget({ type = "imagebox" })
  335. mymemicon.image = image("/usr/share/awesome/icons/blind-alien/icons/mem_blue.png")
  336.  
  337. -- cpu load
  338. mycpuload = widget({ type = "textbox" })
  339. vicious.register(mycpuload, vicious.widgets.cpu, "$1%", 1)
  340. mycpuload.width = space
  341.  
  342. mycpuloadicon = widget({ type = "imagebox" })
  343. mycpuloadicon.image = image("/usr/share/awesome/icons/blind-alien/icons/cpu_blue.png")
  344.  
  345. -- fan
  346. function fan()
  347. local file = io.open("/sys/devices/platform/thinkpad_hwmon/fan1_input", "r")
  348. local fan = file:read("*n")
  349. file:close()
  350.  
  351. return fan
  352. end
  353. -- cputmp
  354. function cputemp()
  355. local file = io.open("/sys/class/thermal/thermal_zone0/temp", "r")
  356. local tmp = file:read("*n")
  357. file:close()
  358. output = tmp / 1000
  359.  
  360. return output
  361. end
  362.  
  363. -- cpu popup
  364. mycpuloadicon:add_signal("mouse::enter", function() batnotify = naughty.notify({
  365. text = "Fan: " .. fan() .. " RPM\n" .. "Temp: " .. cputemp() .. " °C",
  366. title = "CPU Info",
  367. timeout = 0
  368. })
  369. end)
  370.  
  371. mycpuloadicon:add_signal("mouse::leave",
  372. function ()
  373. if batnotify then
  374. naughty.destroy(batnotify)
  375. batnotify = nil
  376. end
  377. end)
  378.  
  379. -- cpu temp
  380. mycpu = widget({ type = "textbox" })
  381. vicious.register(mycpu, vicious.widgets.thermal,"$1°", 30, "thermal_zone0")
  382.  
  383. mycpuicon = widget({ type = "imagebox" })
  384. mycpuicon.image = image("/usr/share/awesome/icons/intel_white.png")
  385.  
  386.  
  387.  
  388.  
  389.  
  390. -- volume
  391. myvolicon = widget({ type = "imagebox" })
  392. myvolicon.image = image("/usr/share/awesome/icons/blind-alien/icons/volume_blue.png")
  393.  
  394. myvol = widget({ type = "textbox" })
  395. vicious.register(myvol, vicious.widgets.volume,
  396. function (widget, args)
  397. if args[1] < 1 then
  398. myvolicon.image = image("/usr/share/awesome/icons/blind-alien/icons/volume_low_blue.png")
  399. return "mute"
  400. else
  401. myvolicon.image = image("/usr/share/awesome/icons/blind-alien/icons/volume_blue.png")
  402. return args[1] .. "%"
  403. end
  404. end, 2, "Master")
  405.  
  406. myvol.width = space
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413. -- battery
  414. mybaticon = widget({ type = "imagebox" })
  415. mybaticon.image = image("/usr/share/awesome/icons/blind-alien/icons/battery_full_blue.png")
  416.  
  417. -- batstate()
  418. function batstate()
  419. local fileee = io.open("/sys/class/power_supply/BAT0/status", "r")
  420. local batstate = fileee:read("*line")
  421. if ((batstate == 'Discharging') or (batstate == 'Charging')) then
  422. return batstate
  423. else
  424. return "Fully charged"
  425. end
  426. end
  427.  
  428.  
  429. -- round()
  430. function round(num, idp)
  431. if ((num ~= nil) and (num ~= 0)) then
  432. local mult = 10^(idp or 0)
  433. return math.floor(num * mult + 0.5) / mult
  434. else
  435. return 0
  436. end
  437. end
  438.  
  439. -- shutdown()
  440. function shdown()
  441. sexec("sudo pm-suspend")
  442. end
  443.  
  444.  
  445. -- watt()
  446. function watt()
  447.  
  448. if (batstate() == 'Discharging') then
  449.  
  450. if(io.open("/sys/devices/platform/smapi/BAT0/power_avg", "r")) then
  451.  
  452.  
  453. local file = io.open("/sys/devices/platform/smapi/BAT0/power_avg", "r")
  454. local currentnow = file:read("*n")
  455. file:close()
  456.  
  457. cur = ((currentnow * -1) / 1000)
  458.  
  459. return "\nUsage: ".. round(cur, 2) .. "W"
  460. else
  461. return "\nUsage: Error"
  462.  
  463. end
  464.  
  465.  
  466. else
  467. return ""
  468. end
  469. end
  470.  
  471.  
  472. -- remaining()
  473. function remaining()
  474.  
  475. if (batstate() == 'Fully charged') then
  476. return ""
  477. end
  478.  
  479. if (batstate() == 'Discharging') then
  480.  
  481. if (io.open("/sys/devices/platform/smapi/BAT0/remaining_running_time", "r")) then
  482. local file = (io.open("/sys/devices/platform/smapi/BAT0/remaining_running_time", "r"))
  483. local remain = file:read("*n")
  484. file:close()
  485.  
  486. return "\nRemaining: " .. remain .. " min"
  487.  
  488. else return "\nRemaining: Error"
  489. end
  490.  
  491.  
  492. else
  493.  
  494. if (io.open("/sys/devices/platform/smapi/BAT0/remaining_charging_time", "r")) then
  495. local filee = io.open("/sys/devices/platform/smapi/BAT0/remaining_charging_time", "r")
  496. local charge = filee:read("*n")
  497. filee:close()
  498. return "\nRemaining: " .. charge .. " min"
  499. else
  500. return "\nRemaining: Error"
  501. end
  502.  
  503. end
  504. end
  505.  
  506.  
  507.  
  508.  
  509. -- batterypopup
  510.  
  511. mybaticon:add_signal("mouse::enter", function() batnotify = naughty.notify({
  512. text = "Status: " .. batstate() .. watt() .. remaining(),
  513. title = "Battery Info",
  514. timeout = 0
  515. })
  516. end)
  517.  
  518.  
  519. mybaticon:add_signal("mouse::leave",
  520. function ()
  521. if batnotify then
  522. naughty.destroy(batnotify)
  523. batnotify = nil
  524. end
  525. end)
  526.  
  527.  
  528. mybat = widget({ type = "textbox" })
  529. vicious.register(mybat, vicious.widgets.bat,
  530. function (widget, args)
  531.  
  532. batnofiy = nil
  533.  
  534.  
  535.  
  536. -- critical
  537. if (args[2] < 4 and batstate() == 'Discharging') then
  538. naughty.notify({
  539. text = "hybernating to disk now",
  540. title = "Critical Battery",
  541. position = "top_right",
  542. timeout = 30,
  543. fg="#262729",
  544. bg="#f92671",
  545. screen = 1,
  546. ontop = true,
  547. run = function () sexec("sudo pm-suspend") end
  548. })
  549. shdown()
  550. mybaticon.image = image("/usr/share/awesome/icons/blind-alien/icons/battery_low_blue.png")
  551. return args[2] .. "%"
  552.  
  553. -- low
  554. elseif (args[2] <= 9 and batstate() == 'Discharging') then
  555. naughty.notify({
  556. text = "charge now",
  557. title = "Low Battery",
  558. position = "top_right",
  559. timeout = 1,
  560. fg="#262729",
  561. bg="#f92671",
  562. screen = 1,
  563. ontop = true,
  564. })
  565.  
  566. mybaticon.image = image("/usr/share/awesome/icons/blind-alien/icons/battery_low_blue.png")
  567. return args[2] .. "%"
  568.  
  569. -- normal discharging
  570. elseif (batstate() == 'Discharging') then
  571. mybaticon.image = image("/usr/share/awesome/icons/blind-alien/icons/battery_full_blue.png")
  572. return args[2] .. "%"
  573. -- charging
  574. else
  575. mybaticon.image = image("/usr/share/awesome/icons/blind-alien/icons/ac_blue.png")
  576. return args[2] .. "%"
  577. end
  578. end, 61, 'BAT0')
  579. mybat.width = space
  580.  
  581.  
  582.  
  583. -- gmail
  584. awful.widget.gmail = require('awful.widget.gmail')
  585. gmailwidget = awful.widget.gmail.new()
  586.  
  587. gmailcount = gmailwidget["{count}"]
  588.  
  589.  
  590. -- spacer
  591. spacer = widget({ type = "textbox" })
  592. spacer.text = " "
  593.  
  594.  
  595. -- MPD
  596. widthMpd = 450 --Width of MPD widget
  597. useMpd = true
  598.  
  599. -- MPD Widget
  600. if useMpd == true then
  601. -- PLAY, STOP, PREV/NEXT Buttons
  602. -- requires modification of /usr/share/awesome/lib/awful/widget/launcher.lua
  603. -- b = util.table.join(w:buttons(), button({}, 1, nil, function () util.spawn(args.command) end))
  604. -- to:
  605. -- b = util.table.join(w:buttons(), button({}, 1, nil, function () util.spawn_with_shell(args.command) end))
  606. music_play = awful.widget.launcher({
  607. image = image("/usr/share/awesome/icons/blind-alien/icons/play_blue.png"),
  608. command = "ncmpcpp toggle"
  609. })
  610.  
  611. music_pause = awful.widget.launcher({
  612. image = image("/usr/share/awesome/icons/blind-alien/icons/pause_blue.png"),
  613. command = "ncmpcpp toggle && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  614. })
  615. music_pause.visible = false
  616.  
  617. music_stop = awful.widget.launcher({
  618. image = image("/usr/share/awesome/icons/blind-alien/icons/stop_blue.png"),
  619. command = "ncmpcpp stop && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  620. })
  621.  
  622. music_prev = awful.widget.launcher({
  623. image = image("/usr/share/awesome/icons/blind-alien/icons/prev_blue.png"),
  624. command = "ncmpcpp prev && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  625. })
  626.  
  627. music_next = awful.widget.launcher({
  628. image = image("/usr/share/awesome/icons/blind-alien/icons/next_blue.png"),
  629. command = "ncmpcpp next && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  630. })
  631. maxlength = 15
  632.  
  633. mpdicon = awful.widget.launcher({
  634. image = image("/usr/share/awesome/icons/blind-alien/icons/note_blue.png"),
  635. command = "ncmpcpp toggle && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  636. })
  637.  
  638. -- Initialize widget
  639. mpdwidget = widget({ type = "textbox" })
  640. --mpdwidget.wrap = "none"
  641. mpdwidget.width = widthMpd
  642. --mpdwidget.wrap = "word_char"
  643. -- Register Widget
  644. --vicious.register(mpdwidget, vicious.widgets.mpd, "(${state}) : ${Artist} - ${Title} ]", 13)
  645. -- Set the maximum width of the MPD widget inside the string.format function as "%.<length>s"
  646. vicious.register(mpdwidget, vicious.widgets.mpd,
  647. function(widget, args)
  648.  
  649. local string = args["{Artist}"] .. " - " .. args["{Title}"]
  650. --local string = "[" .. args["{state}"] .. "]" .. " : " .. args["{Artist}"] .. " - " .. args["{Title}"]
  651.  
  652. -- play
  653. if (args["{state}"] == "Play") then
  654. music_play.visible = false
  655. music_pause.visible = true
  656. music_next.visible = true
  657. music_prev.visible = true
  658. music_stop.visible = true
  659. mpdwidget.visible = true
  660. mpdicon.visible = false
  661. return string
  662. -- pause
  663. elseif (args["{state}"] == "Pause") then
  664.  
  665. music_play.visible = true
  666. music_pause.visible = false
  667. music_next.visible = true
  668. music_prev.visible = true
  669. music_stop.visible = true
  670. mpdwidget.visible = true
  671. mpdicon.visible = false
  672. return string
  673. -- stop
  674. else
  675. mpdicon.visible = true
  676. music_play.visible = false
  677. music_pause.visible = false
  678. music_next.visible = false
  679. music_prev.visible = false
  680. music_stop.visible = false
  681. mpdwidget.visible = false
  682. return string
  683.  
  684. end
  685.  
  686. end, 2)
  687. end
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695. -- Create the wibox
  696.  
  697. -- TOP
  698. mywibox[s] = awful.wibox({ position = "top", screen = s })
  699.  
  700.  
  701. -- BOTTOM
  702. mywib[s] = awful.wibox({ position = "bottom", screen = s})
  703.  
  704.  
  705.  
  706. -- Add widgets to the wibox - order matters
  707. mywibox[s].widgets = {
  708. {
  709. mylauncher,
  710. mytaglist[s],
  711. spacer,
  712. gmailwidget,
  713. spacer,
  714. mpdicon,
  715. music_play,
  716. music_pause,
  717. music_stop,
  718. music_prev,
  719. music_next,
  720. spacer,
  721. spacer,
  722. spacer,
  723. spacer,
  724. mpdwidget,
  725. spacer,
  726. mypromptbox[s],
  727. layout = awful.widget.layout.horizontal.leftright,
  728. },
  729. mylayoutbox[s],
  730. mytextclock,
  731. my_cal.widget,
  732. netwidget,
  733. neticon,
  734. mymem,
  735. mymemicon,
  736. mycpuload,
  737. mycpuloadicon,
  738. wlanwidget,
  739. wlanicon,
  740. mybat,
  741. mybaticon,
  742. myvol,
  743. myvolicon,
  744.  
  745. s == 1 or nil,
  746. layout = awful.widget.layout.horizontal.rightleft
  747.  
  748.  
  749. }
  750.  
  751. mywib[s].widgets = {
  752. -- s == 1 and mysystray or nil,
  753. mysystray,
  754. mytasklist[s],
  755.  
  756. layout = awful.widget.layout.horizontal.rightleft
  757.  
  758. }
  759. end
  760. -- }}}
  761.  
  762. -- {{{ Mouse bindings
  763. root.buttons(awful.util.table.join(
  764. awful.button({ }, 3, function () mymainmenu:toggle() end),
  765. awful.button({ }, 4, awful.tag.viewnext),
  766. awful.button({ }, 5, awful.tag.viewprev)
  767. ))
  768. -- }}}
  769.  
  770. -- {{{ Key bindings
  771. globalkeys = awful.util.table.join(
  772. awful.key({ "Control" }, "Left", awful.tag.viewprev ),
  773. awful.key({ "Control" }, "Right", awful.tag.viewnext ),
  774. awful.key({ "Control" }, "Escape", awful.tag.history.restore),
  775. awful.key({}, "#122", function () sexec("sh ~/bin/vol.sh down" ) end),
  776. awful.key({}, "#123", function () sexec("sh ~/bin/vol.sh up") end),
  777. awful.key({}, "#121", function () sexec("sh ~/bin/vol.sh mute") end),
  778. awful.key({}, "#233", function () sexec("sh ~/bin/bright.sh") end),
  779. awful.key({}, "#232", function () sexec("sh ~/bin/bright.sh") end),
  780. awful.key({ altkey, }, "Tab",
  781. function ()
  782. awful.client.focus.byidx( 1)
  783. if client.focus then client.focus:raise() end
  784. end),
  785. awful.key({ altkey, }, "k",
  786. function ()
  787. awful.client.focus.byidx(-1)
  788. if client.focus then client.focus:raise() end
  789. end),
  790. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  791.  
  792. -- Layout manipulation
  793. awful.key({ modkey }, "Tab", function () awful.client.swap.byidx( 1) end),
  794. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  795. awful.key({ altkey }, "j", function () awful.screen.focus_relative( 1) end),
  796. awful.key({ altkey }, "k", function () awful.screen.focus_relative(-1) end),
  797. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  798. awful.key({ modkey, }, "Tab",
  799. function ()
  800. awful.client.focus.history.previous()
  801. if client.focus then
  802. client.focus:raise()
  803. end
  804. end),
  805.  
  806. -- Standard program
  807. awful.key({ "Control" }, "y", function () awful.util.spawn(terminal) end),
  808. awful.key({ modkey, "Control" }, "r", awesome.restart),
  809. -- awful.key({ modkey, "Shift" }, "q", awesome.quit),
  810. awful.key({ }, "F1", function () exec("dwb") end),
  811. awful.key({ }, "F8", function () exec("firefox") end),
  812. awful.key({}, "#160", function () exec("slimlock") end),
  813. awful.key({}, "#150", function () sexec("sudo pm-suspend") end),
  814.  
  815. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  816. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  817. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  818. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  819. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  820. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  821. awful.key({ "Control", }, "space", function () awful.layout.inc(layouts, 1) end),
  822. awful.key({ modkey }, "space", function () awful.layout.inc(layouts, -1) end),
  823.  
  824. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  825.  
  826. -- Prompt
  827. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  828.  
  829. awful.key({ modkey }, "x",
  830. function ()
  831. awful.prompt.run({ prompt = "Run Lua code: " },
  832. mypromptbox[mouse.screen].widget,
  833. awful.util.eval, nil,
  834. awful.util.getdir("cache") .. "/history_eval")
  835. end)
  836. )
  837.  
  838. clientkeys = awful.util.table.join(
  839. awful.key({ altkey }, "m", function (c) c.fullscreen = not c.fullscreen end),
  840. awful.key({ "Control" }, "q", function (c) c:kill() end),
  841. awful.key({ altkey }, "d", awful.client.floating.toggle ),
  842. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  843. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  844. awful.key({ altkey, }, "t", function (c) c.ontop = not c.ontop end),
  845. awful.key({ altkey }, "n",
  846. function (c)
  847. -- The client currently has the input focus, so it cannot be
  848. -- minimized, since minimized clients can't have the focus.
  849. c.minimized = true
  850. end),
  851. awful.key({ altkey }, "f",
  852. function (c)
  853. c.maximized_horizontal = not c.maximized_horizontal
  854. c.maximized_vertical = not c.maximized_vertical
  855. end)
  856. )
  857.  
  858. -- Compute the maximum number of digit we need, limited to 9
  859. keynumber = 0
  860. for s = 1, screen.count() do
  861. keynumber = math.min(9, math.max(#tags[s], keynumber));
  862. end
  863.  
  864. -- Bind all key numbers to tags.
  865. -- Be careful: we use keycodes to make it works on any keyboard layout.
  866. -- This should map on the top row of your keyboard, usually 1 to 9.
  867. for i = 1, keynumber do
  868. globalkeys = awful.util.table.join(globalkeys,
  869. awful.key({ "Control" }, "#" .. i + 9,
  870. function ()
  871. local screen = mouse.screen
  872. if tags[screen][i] then
  873. awful.tag.viewonly(tags[screen][i])
  874. end
  875. end),
  876. awful.key({ modkey, "Control" }, "#" .. i + 9,
  877. function ()
  878. local screen = mouse.screen
  879. if tags[screen][i] then
  880. awful.tag.viewtoggle(tags[screen][i])
  881. end
  882. end),
  883. awful.key({ altkey }, "#" .. i + 9,
  884. function ()
  885. if client.focus and tags[client.focus.screen][i] then
  886. awful.client.movetotag(tags[client.focus.screen][i])
  887. end
  888. end),
  889. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  890. function ()
  891. if client.focus and tags[client.focus.screen][i] then
  892. awful.client.toggletag(tags[client.focus.screen][i])
  893. end
  894. end))
  895. end
  896.  
  897. clientbuttons = awful.util.table.join(
  898. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  899. awful.button({ altkey }, 1, awful.mouse.client.move),
  900. awful.button({ altkey }, 3, awful.mouse.client.resize))
  901.  
  902. -- Set keys
  903. root.keys(globalkeys)
  904. -- }}}
  905.  
  906. -- {{{ Rules
  907. awful.rules.rules = {
  908. -- All clients will match this rule.
  909. { rule = { },
  910. properties = { border_width = beautiful.border_width,
  911. border_color = beautiful.border_normal,
  912. focus = true,
  913. keys = clientkeys,
  914. buttons = clientbuttons } },
  915.  
  916.  
  917. { rule = { class = "gimp" },
  918. properties = { floating = true } },
  919. -- Set Firefox to always map on tags number 2 of screen 1.
  920. { rule = { class = "Firefox" },
  921. properties = { tag = tags[1][2] } },
  922.  
  923.  
  924. -- 1: sys
  925.  
  926.  
  927.  
  928. -- 2: web
  929.  
  930. { rule = { class = "Firefox" },
  931. except = { instance = "Navigator" },
  932. properties = { tag = tags[1][2], floating = true, switchtotag = true },
  933. -- callback = awful.placement.centered
  934.  
  935.  
  936. },
  937. { rule = { class = "Firefox", instance = "Navigator" },
  938. properties = { tag = tags[1][2], switchtotag = true }
  939. },
  940.  
  941. { rule = { class = "Firefox", instance = "Dialog" },
  942. properties = { tag = tags[1][2], switchtotag = true }
  943. },
  944. { rule = { class = "Midori" },
  945. properties = { tag = tags[1][2], switchtotag = true }
  946. },
  947. { rule = { class = "Dwb" },
  948. properties = { tag = tags[1][2], switchtotag = true }
  949. },
  950.  
  951.  
  952.  
  953. -- 3: doc
  954. { rule = { class = ".*[Mm]edit.*", name = ".*[Mm]edit.*", instance = ".*[Mm]edit.*" },
  955. except = { name = "Find" },
  956. properties = { tag = tags[1][3], switchtotag = true }
  957. },
  958. { rule = { class = "medit" },
  959. except = { name = "Find" },
  960. properties = { tag = tags[1][3], switchtotag = true }
  961. },
  962. { rule = { instance = "medit" },
  963. except = { name = "Find" },
  964. properties = { tag = tags[1][3], switchtotag = true }
  965. },
  966. { rule = { instance = "medit.*" },
  967. except = { name = "Find" },
  968. properties = { tag = tags[1][3], switchtotag = true }
  969. },
  970. { rule = { name = "^medit\ %-.*" },
  971. except = { name = "Find" },
  972. properties = { tag = tags[1][3], switchtotag = true }
  973. },
  974. { rule = { name = "medit.*" },
  975. except = { name = "Find" },
  976. properties = { tag = tags[1][3], switchtotag = true }
  977. },
  978.  
  979. { rule = { class = "epdfview" },
  980. properties = { tag = tags[1][3], switchtotag = true }
  981. },
  982. { rule = { class = "Epdfview" },
  983. properties = { tag = tags[1][3], switchtotag = true }
  984. },
  985. { rule = { class = "zathura" },
  986. properties = { tag = tags[1][3], switchtotag = true }
  987. },
  988. { rule = { class = "Zathura" },
  989. properties = { tag = tags[1][3], switchtotag = true }
  990. },
  991.  
  992.  
  993.  
  994. -- 4: dev
  995.  
  996. { rule = { class = "NetBeans" },
  997. properties = { tag = tags[1][4], switchtotag = true }
  998. },
  999. { rule = { class = "netbeans" },
  1000. properties = { tag = tags[1][4], switchtotag = true }
  1001. },
  1002.  
  1003. { rule = { class = "sun-awt-X11-XFramePeer" },
  1004. properties = { tag = tags[1][4], switchtotag = true }
  1005. },
  1006. { rule = { class = "java-lang-Thread" },
  1007. properties = { tag = tags[1][4], switchtotag = true }
  1008. },
  1009. { rule = { class = "Eclipse" },
  1010. properties = { tag = tags[1][4], switchtotag = true }
  1011. },
  1012.  
  1013.  
  1014.  
  1015. -- 5: irc
  1016.  
  1017. -- 6: foo
  1018.  
  1019. { rule = { class = "Mplayer" },
  1020. properties = { tag = tags[1][6], switchtotag = true }
  1021. },
  1022. { rule = { class = "mplayer" },
  1023. properties = { tag = tags[1][6], switchtotag = true }
  1024. },
  1025.  
  1026. -- { rule = { class = "Gnome-mplayer" },
  1027. -- properties = { tag = tags[1][5], switchtotag = true }
  1028. -- },
  1029. -- 6: pdf
  1030.  
  1031.  
  1032. -- Set Firefox to always map on tags number 2 of screen 1.
  1033. -- { rule = { class = "Firefox" },
  1034. -- properties = { tag = tags[1][2] } },
  1035. --]
  1036.  
  1037.  
  1038. }
  1039. -- }}}
  1040.  
  1041. -- {{{ Signals
  1042. -- Signal function to execute when a new client appears.
  1043. client.add_signal("manage", function (c, startup)
  1044. -- Add a titlebar
  1045. -- awful.titlebar.add(c, { modkey = modkey })
  1046.  
  1047. -- Enable sloppy focus
  1048. c:add_signal("mouse::enter", function(c)
  1049. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  1050. and awful.client.focus.filter(c) then
  1051. client.focus = c
  1052. end
  1053. end)
  1054.  
  1055. if not startup then
  1056. -- Set the windows at the slave,
  1057. -- i.e. put it at the end of others instead of setting it master.
  1058. -- awful.client.setslave(c)
  1059.  
  1060. -- Put windows in a smart way, only if they does not set an initial position.
  1061. if not c.size_hints.user_position and not c.size_hints.program_position then
  1062. awful.placement.no_overlap(c)
  1063. awful.placement.no_offscreen(c)
  1064. end
  1065. end
  1066. end)
  1067.  
  1068. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  1069. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  1070. -- }}}
  1071.  
  1072. naughty.config.presets.online = {
  1073. bg = "#1f880e80",
  1074. fg = "#ffffff",
  1075. }
  1076. naughty.config.presets.chat = naughty.config.presets.online
  1077. naughty.config.presets.away = {
  1078. bg = "#eb4b1380",
  1079. fg = "#ffffff",
  1080. }
  1081. naughty.config.presets.xa = {
  1082. bg = "#65000080",
  1083. fg = "#ffffff",
  1084. }
  1085. naughty.config.presets.dnd = {
  1086. bg = "#65340080",
  1087. fg = "#ffffff",
  1088. }
  1089. naughty.config.presets.invisible = {
  1090. bg = "#ffffff80",
  1091. fg = "#000000",
  1092. }
  1093. naughty.config.presets.offline = {
  1094. bg = "#64636380",
  1095. fg = "#ffffff",
  1096. }
  1097. naughty.config.presets.requested = naughty.config.presets.offline
  1098. naughty.config.presets.error = {
  1099. bg = "#ff000080",
  1100. fg = "#ffffff",
  1101. }
  1102.  
  1103. -- mcabber notifcation wrapper
  1104.  
  1105. muc_nick = "fsafsafsaafs"
  1106.  
  1107. function mcabber_event_hook(kind, direction, jid, msg)
  1108. if kind == "MSG" then
  1109. if direction == "IN" or direction == "MUC" then
  1110. local filehandle = io.open(msg)
  1111. local txt = filehandle:read("*all")
  1112. filehandle:close()
  1113. awful.util.spawn("rm "..msg)
  1114. if direction == "MUC" and txt:match("^<" .. muc_nick .. ">") then
  1115. return
  1116. end
  1117. naughty.notify{
  1118. -- icon = "chat_msg_recv",
  1119. text = awful.util.escape(txt),
  1120. title = jid
  1121. }
  1122. end
  1123. elseif kind == "STATUS" then
  1124. local mapping = {
  1125. [ "O" ] = "online",
  1126. [ "F" ] = "chat",
  1127. [ "A" ] = "away",
  1128. [ "N" ] = "xa",
  1129. [ "D" ] = "dnd",
  1130. [ "I" ] = "invisible",
  1131. [ "_" ] = "offline",
  1132. [ "?" ] = "error",
  1133. [ "X" ] = "requested"
  1134. }
  1135. local status = mapping[direction]
  1136. local iconstatus = status
  1137. if not status then
  1138. status = "error"
  1139. end
  1140. if jid:match("icq") then
  1141. iconstatus = "icq/" .. status
  1142. end
  1143. naughty.notify{
  1144. preset = naughty.config.presets[status],
  1145. text = jid,
  1146. -- icon = iconstatus
  1147. }
  1148. end
  1149. end
  1150.  
  1151.  
  1152. -- disable startup-notification globally
  1153. local oldspawn = awful.util.spawn
  1154. awful.util.spawn = function (s)
  1155. oldspawn(s, false)
  1156. end
Advertisement
Add Comment
Please, Sign In to add comment