Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

rc.lua issue

By: a guest on Jan 21st, 2013  |  syntax: None  |  size: 51.09 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ------------------------------------------------
  2. ---Larry's Custom AWM+Blue Awesome
  3. ------------------------------------------------
  4.  
  5.  
  6. -- Standard awesome library
  7. require("awful")
  8. require("awful.autofocus")
  9. require("awful.rules")
  10. -- Theme handling library
  11. require("beautiful")
  12. require("revelation")
  13. -- Notification library
  14. require("naughty")
  15. local vicious = require("vicious")
  16. -- require('weather')           -- http://github.com/jesseadams/weather
  17. --}}}
  18.  
  19. -- {{{ Error Handling
  20. -- Check if awesome encountered an error during startup and fell back to
  21. -- another config (This code will only ever execute for the fallback config)
  22. if awesome.startup_errors then
  23.     naughty.notify({ preset = naughty.config.presets.critical,
  24.                      title = "Oops, there were errors during startup!",
  25.                      text = awesome.startup_errors })
  26. end
  27.  
  28. -- Handle runtime errors after startup
  29. do
  30.     local in_error = false
  31.     awesome.add_signal("debug::error", function (err)
  32.         -- Make sure we don't go into an endless error loop
  33.         if in_error then return end
  34.         in_error = true
  35.  
  36.         naughty.notify({ preset = naughty.config.presets.critical,
  37.                          title = "Oops, an error happened!",
  38.                          text = err })
  39.         in_error = false
  40.     end)
  41. end
  42. -- }}}
  43.  
  44. -- weather_zipcode = '20112' -- USA/Canada postal code
  45.  
  46. -- {{{ Variable Definitions
  47. -- Themes define colours, icons, and wallpapers
  48. beautiful.init("/home/larry/.config/awesome/themes/blue/theme.lua")
  49.  
  50. -- This is used later as the default terminal and editor to run.
  51. terminal = "urxvt"
  52. editor = os.getenv("EDITOR") or "nano"
  53. editor_cmd = terminal .. " -e " .. editor
  54. gui_editor = "scite"
  55. browser = "opera"
  56. fileman = "pcmanfm /home/larry/"
  57. cli_fileman = terminal .. " -e ranger "
  58. music = terminal .. " -e ncmpcpp "
  59. chat = terminal .. " -e weechat-curses "
  60. tasks = terminal .. " -e sudo htop "
  61.  
  62. -- Default modkey.
  63. -- Usually, Mod4 is the key with a logo between Control and Alt.
  64. -- If you do not like this or do not have such a key,
  65. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  66. -- However, you can use another modifier like Mod1, but it may interact with others.
  67. modkey = "Mod4"
  68. altkey = "Mod1"
  69.  
  70. -- Table of layouts to cover with awful.layout.inc, order matters.
  71. layouts = {
  72.    awful.layout.suit.floating,        -- 1
  73.    awful.layout.suit.tile,            -- 2
  74.    awful.layout.suit.tile.left,       -- 3
  75.    awful.layout.suit.tile.bottom,     -- 4
  76.    awful.layout.suit.tile.top,        -- 5
  77.    awful.layout.suit.fair,            -- 6
  78.    awful.layout.suit.fair.horizontal, -- 7
  79.    awful.layout.suit.spiral,          -- 8
  80.    awful.layout.suit.spiral.dwindle,  -- 9
  81.    awful.layout.suit.max,             -- 10
  82.    --awful.layout.suit.max.fullscreen,  -- 11
  83.    --awful.layout.suit.magnifier        -- 12
  84. }
  85. -- }}}
  86.  
  87. -- {{{ Tags
  88. -- Define a tag table which hold all screen tags.
  89. -- tags = {}
  90. -- for s = 1, screen.count() do
  91.     -- Each screen has its own tag table.
  92. --     tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[6])
  93. -- end
  94.  
  95. tags = {
  96.    names  = {
  97.       '1 term',
  98.       '2 web',
  99.       '3 files',
  100.       '4 chat',
  101.       '5 media',
  102.       '6 work',
  103.       '7 vbox',
  104.       '8 games',
  105.       '9 pics'
  106.             },
  107.    layout = {
  108.       layouts[6],
  109.       layouts[6],
  110.       layouts[6],
  111.       layouts[6],
  112.       layouts[6],
  113.       layouts[6],
  114.       layouts[6],
  115.       layouts[6],
  116.       layouts[6]
  117.             }
  118.         }
  119.  
  120. for s = 1, screen.count() do
  121.    -- Each screen has its own tag table.
  122.    tags[s] = awful.tag(tags.names, s, tags.layout)
  123. end
  124. -- }}}
  125.  
  126. -- {{{ Menu
  127. -- Create a laucher widget and a main menu
  128.  
  129. myfilemanagers = {  
  130.  
  131. { "pcmanfm" , "pcmanfm" },
  132.    { "pcmanfm" , "pcmanfm" }
  133. }
  134. myaccessories = {
  135.    { "7-Zip", "7zFM" },
  136.   -- { "Charmap", "gucharmap" },
  137.   -- { "Convertall", "convertall" },
  138.   -- { "Converter", "cute-converter" },
  139.    { "Scite", "scite" },
  140.  --  { "Gvim", "gvim" },
  141.    { "Nano", editor_cmd }
  142. }
  143. myinternet = {
  144.   --  { "Aircrack", "sudo wepcrack" },
  145.   --  { "Amule", "amule" },
  146.     { "Mumble", "mumble" },
  147.     { "Dropbox", "dropboxd" },
  148.     { "Firefox" , browser },
  149.      { "RSS Feed" , "Lightread"},
  150.     { "IRC Client" , chat },
  151.     { "Chrome" , "iron" },
  152.     { "Mail" , "thunderbird" },
  153.     { "Skype" , "skype" },
  154.     { "Teamviewer" , "teamviewer7" },
  155.    -- { "Torrent" , "qbittorrent" },
  156.    -- { "Torrent Search" , "torrent-search" },
  157. }
  158.  
  159. mymedia = {
  160.    -- { "Avidemux" , "avidemux2_gtk" },
  161.    -- { "Burn Tool" , "k3b" },
  162.     { "Mplayer" , "gnome-mplayer" },
  163.    -- { "vlc" , music },
  164.     --{ "Pandora" , "pithos" },
  165.  --   { "Record Desktop" , "gtk-recordMyDesktop --no-frame" },
  166.    -- { "UNetBootin" , "sudo unetbootin" },
  167.     { "Vlc" , "vlc" },
  168.     --{ "Webcam" , "mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 25 -vf screenshot" }
  169.   --  { "Webcam" , "wxcam" }
  170. }
  171.  
  172. mygraphics = {
  173.    --{ "Pinta" , "pinta" },
  174.    -- { "Colors" , "kcolorchooser" },
  175.    { "Gimp" , "gimp" },
  176.  --   { "Gpicview" , "gpicview" },
  177.   --  { "Scanner" , "iscan" },
  178.   --  { "Xournal" , "xournal" }
  179. }
  180.  
  181. --myoffice = {
  182.  --   { "Formula" , "lomath" },
  183.   --  { "Impress" , "loimpress" },
  184.    -- { "Okular" , "okular" },
  185.   --  { "Spreadsheet" , "localc" },
  186.    -- { "Writer" , "lowriter" }
  187. --}
  188.  
  189. mysystem = {
  190.     { "Appearance" , "lxappearance" },
  191.     { "Cleaning" , "bleachbit" },
  192.     { "Virtualbox" , "VirtualBox" },
  193.   --  { "HardInfo" , "hardinfo" },
  194.  --   { "KDE Setting" , "systemsettings" },
  195.  --   { "Powertop" , terminal .. " -e sudo powertop " },
  196.   --  { "Qtconfig" , "qtconfig" },
  197.    { "Task Manager" , "tasks" }
  198. }
  199.  
  200. mysystemroot = {
  201.   --  { "Appearance" , "sudo lxappearance" },
  202.     { "Catalyst" , "sudo amdcccle" },
  203.     --{ "Cleaning" , "sudo bleachbit" },
  204.     --{ "Disk Utility" , "sudo palimpsest" },
  205.   --  { "KDE Settings" , "sudo systemsettings" },
  206.     --{ "Partitions" , "sudo /usr/sbin/gparted" },
  207.    -- { "Qtconfig" , "sudo qtconfig" }
  208. }
  209.  
  210. myfolders = {
  211.     { "Apps" , "sudo pcmanfm /usr/share/applications" },
  212.     { "Arch" , "sudo pcmanfm /" },
  213.     { "Boot" , "sudo pcmanfm /boot" },
  214.     { "Configs" , "pcmanfm /home/larry/.config/awesome/" },
  215.     { "Etc" , "sudo pcmanfm /etc" },
  216.     { "Documents" , "pcmanfm /media/Data/Documents" },
  217.     { "Downloads" , "pcmanfm /home/larry/Documents/" },
  218.     { "Dropbox" , "pcmanfm /home/larry/Dropbox/" },
  219.     { "Home" , "pcmanfm /home/larry" },
  220.     { "Icons" , "sudo pcmanfm /usr/share/icons" },
  221.     { "Media" , "pcmanfm /media" },
  222.   --  { "Motion" , "pcmanfm /home/larry/.motion/files" },
  223.     { "Music" , "pcmanfm /home/larry/Music/" },
  224.     { "Pictures" , "pcmanfm /home/larry/Pictures/" },
  225.     --{ "Pixmaps" , "sudo pcmanfm /usr/share/pixmaps" },
  226.     { "Root" , "sudo pcmanfm /root" },
  227.     { "Themes" , "sudo pcmanfm /usr/share/themes" },
  228.     { "Var" , "sudo pcmanfm /var" },
  229.     { "Videos" , "pcmanfm /home/larry/Videos/" }
  230. }
  231.  
  232. --mystudy = {
  233.   --  { "Calculator" , "qalculate-gtk" },
  234.     --{ "Chemistry" , "gelemental" },
  235.     --{ "Circuits" , "sudo ktechlab" },
  236.     --{ "Esse3" , "firefox https://poliba.esse3.cineca.it/Home.do;jsessionid=39B376CBEAB698B9BD68256B07C36505.jvm_poliba_esse3web05" };
  237.     --{ "Fataing" , "firefox http://www.fataing.poliba.it/login.php" },
  238.     --{ "Graphs" , "kmplot" },
  239.     --{ "Lectures" , "pcmanfm /media/Data/University" },
  240.     --{ "Notes" , "pcmanfm /media/Winzoz/Users/larry/Dropbox/Università " }
  241. --}
  242.  
  243. --mygames = {
  244.   -- { "Blocks" , "gnotski" },
  245.   -- { "Bovo" , "bovo" },
  246.   -- { "Brainy" , "gbrainy" },
  247.   -- { "Breakout" , "kbreakout" },
  248.   -- { "Chess" , "pychess" },
  249.   -- { "Four In Line" , "kfourinline" },
  250.    --{ "Granatier" , "granatier" },
  251.    --{ "Katomic" , "katomic" },
  252.    --{ "Kmahjongg" , "kmahjongg" },
  253.    --{ "Mahjongg" , "mahjongg" },
  254.    --{ "Mines" , "kmines" },
  255.   -- { "Puzzles" , "palapeli" },
  256.   -- { "Reversi" , "kreversi" },
  257.   -- { "Sudoku" , "ksudoku" },
  258.    --{ "Sudoku 2" , "gnome-sudoku" },
  259.   -- { "Tetravex" , "gnotravex" },
  260.   -- { "Tetris" , "kblocks" },
  261.   -- { "Tetris 2" , "quadrapassel" },
  262.   -- { "Urban Terror" , "urbanterror" }
  263. --{ "WoW" , "wow" }
  264. --}
  265.  
  266. myexit = {
  267.    { "Hibernate" , "sudo pm-hibernate" },
  268.    { "Shutdown" , "sudo halt" },
  269.    { "Reboot" , "sudo reboot" },
  270.    { "Quit" , "awesome.quit" }
  271. }
  272.  
  273. mymainmenu = awful.menu({ items = {
  274.                                 { "File Manager", fileman },
  275.                                 { "urxvt", terminal },
  276.                                 --{ "Opera" , browser },
  277.                                     { "Firefox" , "firefox" },
  278.                                   --  { "chrome" , "iron" },
  279.                     { " ", nil, nil}, -- separator
  280.                     { "Edit Lua" , "scite /home/larry/.config/awesome/rc.lua" },
  281.                     { "Edit Tmux" , "scite /home/larry/.tmux.conf" },
  282.                     { "Edit Xinit" , "scite /home/larry/.xinitrc" },
  283.                     { "Edit Bashrc" , "scite /home/larry/.bashrc" },
  284.                     { "Edit Xres" , "scite /home/larry/.Xresources" },
  285.                                     { "Folders" , myfolders },
  286.                     { " ", nil, nil}, -- separator
  287.                                     { "Accessories" , myaccessories },
  288.                                     --{ "Games" , mygames },
  289.                                     --{ "Graphics" , mygraphics },
  290.                                     { "Internet" , myinternet },
  291.                                     { "Multimedia" , mymedia },
  292.                                     --{ "Office" , myoffice },
  293.                                     { "System" , mysystem },
  294.                                     { "System Root" , mysystemroot },
  295.                                  --   { "University" , mystudy },
  296.                     { " ", nil, nil}, -- separator
  297.                                     { "Search" , "sudo kfind" },
  298.                                     { "Exit", myexit },
  299.                                   }
  300.                         })
  301.  
  302. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  303.                                      menu = mymainmenu })
  304. -- }}}
  305.  
  306. -- {{{ Wibox
  307.  
  308. -- Weather widget
  309. -- forecast = widget({ type = 'textbox', name = 'weather' })
  310. -- forecast.bg = bottom_panel_color
  311. -- forecast.width = 70
  312. -- weather.register(forecast, weather_zipcode)
  313.  
  314. -- Weather Icon
  315. weathericon = widget({ type = 'imagebox' })
  316. weathericon.image = image("/home/larry/.config/awesome/themes/blue/widgets/dish.png")
  317.  
  318. --- Weather widget
  319. weatherwidget = widget({ type = "textbox" })
  320. weather_t = awful.tooltip({ objects = { weatherwidget },})
  321.  
  322. vicious.register(weatherwidget, vicious.widgets.weather,
  323.                 function (widget, args)
  324.                   weather_t:set_text("City: " .. args["{city}"] .. "\nTemperature: " .. args["{tempc}"] .. " °C\t" .. args["{tempf}"] .. " °F " .. "\nWind Condition: " .. args["{wind}"] .. "\nWind Speed: " .. args["{windkmh}"] .. " km/h\t" .. args["{windmph}"] .. " mph\t" .. "\nSky: " .. args["{sky}"] .. "\nHumidity: " .. args["{humid}"] .. "%\n" .. "Pressure: " .. args["{press}"] .. " hPa") return args["{tempf}"] .. "F"
  325.                 end, 600, "KHEF")
  326.                 --'600': check every 10 minutes.
  327.                 --'KHEF': the Virginia ICAO code.
  328.  
  329.  
  330. -- Create a textclock widget
  331. clockicon = widget({ type = "imagebox"})
  332. clockicon.image = image(beautiful.widget_clock)
  333. mytextclock = awful.widget.textclock({ align = "right" })
  334.  
  335. mytextclock = awful.widget.textclock({
  336. align = "right",
  337. }, "%a %b %d %l:%M%P", 1)
  338. awful.widget.layout.margins[mytextclock] = { top = -1 }
  339.  
  340. -- Calendar widget to attach to the textclock
  341. require('calendar2')
  342. calendar2.addCalendarToWidget(mytextclock)
  343.  
  344. -- System
  345. sysicon = widget({ type = "imagebox" })
  346. sysicon.image = image(beautiful.widget_sys)
  347. sysicon.align = "middle"
  348.  
  349. syswidget = widget({ type = "textbox" })
  350. vicious.register( syswidget, vicious.widgets.os, "$2")
  351.  
  352. awful.widget.layout.margins[sysicon] = { top = 0 }
  353.  
  354. -- Uptime
  355.  
  356. exitmenu = awful.menu({items = {
  357.                              { "Hibernate" , function () awful.util.spawn("sudo pm-hibernate", false) end },
  358.                              { "Shutdown" , function () awful.util.spawn("sudo halt", false) end },
  359.                              { "Restart" , awesome.restart },
  360.                              { "Reboot" , function () awful.util.spawn("sudo reboot", false) end },
  361.                              { "Quit" , awesome.quit }
  362.                           }
  363.                        })
  364.  
  365. uptimeicon = widget({ type = "imagebox" })
  366. uptimeicon.image = image(beautiful.widget_uptime)
  367.  
  368. uptimewidget = widget({ type = "textbox" })
  369. vicious.register( uptimewidget, vicious.widgets.uptime, "$1d$2h$3m")
  370.  
  371. uptimeicon:buttons(awful.util.table.join(
  372.                                          awful.button({ }, 1, function () exitmenu:toggle() end )
  373.                                    ))
  374.  
  375. uptimewidget:buttons(awful.util.table.join(
  376.                                          awful.button({ }, 1, function () exitmenu:toggle() end )
  377.                                    ))
  378.  
  379. -- Temp Icon
  380. tempicon = widget({ type = "imagebox" })
  381. tempicon.image = image(beautiful.widget_temp)
  382. -- Temp Widget
  383. tempwidget = widget({ type = "textbox" })
  384. vicious.register(tempwidget, vicious.widgets.thermal, "$1°C", 9, "thermal_zone0")
  385.  
  386. tempicon:buttons(awful.util.table.join(
  387.     awful.button({ }, 1, function () awful.util.spawn("urxvtc -e sudo powertop", false) end)
  388. ))
  389.  
  390.  
  391. -- gmail widget and tooltip
  392. mygmail = widget({ type = "textbox" })
  393. gmail_t = awful.tooltip({ objects = { mygmail },})
  394.  
  395. mygmailimg = widget({ type = "imagebox" })
  396. mygmailimg.image = image(beautiful.widget_gmail)
  397.  
  398. vicious.register(mygmail, vicious.widgets.gmail,
  399.                 function (widget, args)
  400.                     gmail_t:set_text(args["{subject}"])
  401.                     gmail_t:add_to_object(mygmailimg)
  402.                     return args["{count}"]
  403.                  end, 120)
  404.                  --the '120' here means check every 2 minutes.
  405.  
  406. mygmailimg:buttons(awful.util.table.join(
  407.     awful.button({ }, 1, function () awful.util.spawn("thunderbird", false) end)
  408. ))
  409.  
  410. -- Disk usage widget
  411. diskwidget = widget({ type = 'imagebox' })
  412. diskwidget.image = image("/home/larry/.config/awesome/themes/blue/widgets/mem.png")
  413. disk = require("diskusage")
  414. -- the first argument is the widget to trigger the diskusage
  415. -- the second/third is the percentage at which a line gets orange/red
  416. -- true = show only local filesystems
  417. disk.addToWidget(diskwidget, 75, 90, false)
  418.  
  419. -- Pacman Icon
  420. pacicon = widget({type = "imagebox" })
  421. pacicon.image = image(beautiful.widget_pac)
  422. -- Pacman Widget
  423. pacwidget = widget({type = "textbox"})
  424. pacwidget_t = awful.tooltip({ objects = { pacwidget},})
  425. vicious.register(pacwidget, vicious.widgets.pkg,
  426.                 function(widget,args)
  427.                     local io = { popen = io.popen }
  428.                     local s = io.popen("yaourt -Qu")
  429.                     local str = ''
  430.                     for line in s:lines() do
  431.                         str = str .. line .. "\n"
  432.                     end
  433.                     pacwidget_t:set_text(str)
  434.                     s:close()
  435.                     return " " .. args[1]
  436.                 end, 10, "Arch")
  437.                 --'60' means check every 10 minutes
  438.  
  439. pacicon:buttons(awful.util.table.join(
  440.     awful.button({ }, 1, function () awful.util.spawn("urxvtc -e yaourt -Syua", false) end)
  441. ))
  442.  
  443. -- CPU Icon
  444. cpuicon = widget({ type = "imagebox" })
  445. cpuicon.image = image(beautiful.widget_cpu)
  446. -- CPU Widget
  447. cpubar = awful.widget.progressbar()
  448. cpubar:set_width(50)
  449. cpubar:set_height(6)
  450. cpubar:set_vertical(false)
  451. cpubar:set_background_color("#434343")
  452. cpubar:set_gradient_colors({ beautiful.fg_normal, beautiful.fg_normal, beautiful.fg_normal, beautiful.bar })
  453. vicious.register(cpubar, vicious.widgets.cpu, "$1", 3)
  454. awful.widget.layout.margins[cpubar.widget] = { top = 5 }
  455.  
  456. -- Cpu usage
  457. cpuwidget = widget({ type = "textbox" })
  458. vicious.register( cpuwidget, vicious.widgets.cpu, "$2% $3% $4% $5%", 3)
  459.  
  460. cpuicon:buttons(awful.util.table.join(
  461.     awful.button({ }, 1, function () awful.util.spawn("urxvtc -e htop", false) end)
  462. ))
  463.  
  464. -- BATT Icon
  465. baticon = widget ({type = "imagebox" })
  466. baticon.image = image(beautiful.widget_batt)
  467.  
  468. -- Battery usage
  469. powermenu = awful.menu({items = {
  470.                              { "Auto" , function () awful.util.spawn("sudo cpufreq-set -r -g ondemand", false) end },
  471.                              { "Ondemand" , function () awful.util.spawn("sudo cpufreq-set -r -g ondemand", false) end },
  472.                              { "Powersave" , function () awful.util.spawn("sudo cpufreq-set -r -g powersave", false) end },
  473.                              { "Performance" , function () awful.util.spawn("sudo cpufreq-set -r -g performance", false) end }
  474.                           }
  475.                        })
  476.  
  477. -- Initialize BATT widget progressbar
  478. batbar = awful.widget.progressbar()
  479. batbar:set_width(50)
  480. batbar:set_height(6)
  481. batbar:set_vertical(false)
  482. batbar:set_background_color("#434343")
  483. batbar:set_border_color(nil)
  484. batbar:set_gradient_colors({ beautiful.fg_normal, beautiful.fg_normal, beautiful.fg_normal, beautiful.bar })
  485. awful.widget.layout.margins[batbar.widget] = { top = 5 }
  486. vicious.register( batbar, vicious.widgets.bat, "$2", 1, "BAT0" )
  487.  
  488. batwidget = widget({ type = "textbox" })
  489. vicious.register( batwidget, vicious.widgets.bat, "$2", 1, "BAT0" )
  490. baticon:buttons(awful.util.table.join(
  491.                                          awful.button({ }, 1, function () powermenu:toggle() end )
  492.                                    ))
  493.  
  494. batwidget:buttons(awful.util.table.join(
  495.                                          awful.button({ }, 1, function () powermenu:toggle() end )
  496.                                    ))
  497.  
  498. -- Vol Icon
  499. volicon = widget ({type = "imagebox" })
  500. volicon.image = image(beautiful.widget_vol)
  501. -- Vol bar Widget
  502. volbar = awful.widget.progressbar()
  503. volbar:set_width(50)
  504. volbar:set_height(6)
  505. volbar:set_vertical(false)
  506. volbar:set_background_color("#434343")
  507. volbar:set_border_color(nil)
  508. volbar:set_gradient_colors({ beautiful.fg_normal, beautiful.fg_normal, beautiful.fg_normal, beautiful.bar })
  509. awful.widget.layout.margins[volbar.widget] = { top = 5 }
  510. vicious.register(volbar, vicious.widgets.volume,  "$1",  1, "Master")
  511.  
  512.  
  513. -- Sound volume
  514. volumewidget = widget ({ type = "textbox" })
  515. vicious.register( volumewidget, vicious.widgets.volume, "$1", 1, "Master" )
  516.  
  517. volicon:buttons(awful.util.table.join(
  518.     awful.button({ }, 1, function () awful.util.spawn("amixer -q sset Master toggle", false) end),
  519.     awful.button({ }, 3, function () awful.util.spawn("urxvtc -e alsamixer", true) end),
  520.     awful.button({ }, 4, function () awful.util.spawn("amixer -q sset Master 1dB+", false) end),
  521.     awful.button({ }, 5, function () awful.util.spawn("amixer -q sset Master 1dB-", false) end)
  522. ))
  523.  
  524. volumewidget:buttons(awful.util.table.join(
  525.     awful.button({ }, 1, function () awful.util.spawn("amixer -q sset Master toggle", false) end),
  526.     awful.button({ }, 3, function () awful.util.spawn("urxvtc -e alsamixer", true) end),
  527.     awful.button({ }, 4, function () awful.util.spawn("amixer -q sset Master 1dB+", false) end),
  528.     awful.button({ }, 5, function () awful.util.spawn("amixer -q sset Master 1dB-", false) end)
  529. ))
  530. -- Net Widget
  531.  
  532. netdownicon = widget ({ type = "imagebox" })
  533. netdownicon.image = image(beautiful.widget_netdown)
  534. netdownicon.align = "middle"
  535.  
  536. netdowninfo = widget({ type = "textbox" })
  537. vicious.register(netdowninfo, vicious.widgets.net, "${eth0 down_kb}", 1)
  538.  
  539. -- netdowninfo:buttons(awful.util.table.join(
  540. --     awful.button({ }, 1, function () awful.util.spawn("sudo netcfg home-wireless-wpa", false) end),
  541. --     awful.button({ }, 3, function () awful.util.spawn("sudo netcfg down home-wireless-wpa", false) end)
  542. -- ))
  543.  
  544.  
  545. netupicon = widget ({ type = "imagebox" })
  546. netupicon.image = image(beautiful.widget_netup)
  547. netupicon.align = "middle"
  548.  
  549. netupinfo = widget({ type = "textbox" })
  550. vicious.register(netupinfo, vicious.widgets.net, "${eth0 up_kb}", 1)
  551.  
  552. -- netupinfo:buttons(awful.util.table.join(
  553. --     awful.button({ }, 1, function () awful.util.spawn("sudo netcfg home-ethernet", false) end),
  554. --     awful.button({ }, 3, function () awful.util.spawn("sudo netcfg down home-ethernet", false) end)
  555. -- ))
  556.  
  557. netmenu = awful.menu({items = {
  558.                              { "Change ip" , function () awful.util.spawn("sh ./.scripts/restartwifi", false) end },
  559.                              { "Connect Lan" , function () awful.util.spawn("urxvtc -hold -e sudo netcfg home-ethernet", false) end },
  560.                              { "Connect Wifi" , function () awful.util.spawn("urxvtc -hold -e sudo netcfg home-wireless-wpa", false) end },
  561.                              { "Disconnect Lan" , function () awful.util.spawn("urxvtc -hold -e sudo netcfg down home-ethernet", false) end },
  562.                              { "Disconnect Wifi" , function () awful.util.spawn("urxvtc -hold -e sudo netcfg down home-wireless-wpa", false) end }
  563.                           }
  564.                        })
  565.  
  566. netdownicon:buttons(awful.util.table.join(
  567.                                          awful.button({ }, 1, function () netmenu:toggle() end )
  568.                                    ))
  569. netdowninfo:buttons(awful.util.table.join(
  570.                                          awful.button({ }, 1, function () netmenu:toggle() end )
  571.                                    ))
  572. netupicon:buttons(awful.util.table.join(
  573.                                          awful.button({ }, 1, function () netmenu:toggle() end )
  574.                                    ))
  575. netupinfo:buttons(awful.util.table.join(
  576.                                          awful.button({ }, 1, function () netmenu:toggle() end )
  577.                                    ))
  578. -- MEM icon
  579. memicon = widget ({type = "imagebox" })
  580. memicon.image = image(beautiful.widget_mem)
  581. -- Initialize MEMBar widget
  582. membar = awful.widget.progressbar()
  583. membar:set_width(50)
  584. membar:set_height(6)
  585. membar:set_vertical(false)
  586. membar:set_background_color("#434343")
  587. membar:set_border_color(nil)
  588. membar:set_gradient_colors({ beautiful.fg_normal, beautiful.fg_normal, beautiful.fg_normal, beautiful.bar })
  589. awful.widget.layout.margins[membar.widget] = { top = 5 }
  590. vicious.register(membar, vicious.widgets.mem, "$1", 1)
  591.  
  592. -- Memory usage
  593. memwidget = widget({ type = "textbox" })
  594. vicious.register(memwidget, vicious.widgets.mem, "$2M", 1)
  595.  
  596. memicon:buttons(awful.util.table.join(
  597.     awful.button({ }, 1, function () awful.util.spawn("urxvtc -e saidar -c", false) end)
  598. ))
  599.  
  600. -- MPD Icon
  601. mpdicon = widget({ type = "imagebox" })
  602. mpdicon.image = image(beautiful.widget_mpd)
  603. -- Initialize MPD Widget
  604. mpdwidget = widget({ type = "textbox" })
  605. vicious.register(mpdwidget, vicious.widgets.mpd,
  606.     function (widget, args)
  607.         if args["{state}"] == "Stop" then
  608.             return "Stopped"
  609.         elseif args["{state}"] == "Pause" then
  610.             return "Paused"
  611.         else
  612.             return args["{Title}"]..' - '.. args["{Artist}"]
  613.         end
  614.     end, 0.5)
  615.  
  616. mpdicon:buttons(awful.util.table.join(
  617.     awful.button({ }, 1, function () awful.util.spawn("urxvt -e ncmpcpp", false) end)
  618. ))
  619.  
  620. -- Spacers
  621. rbracket = widget({type = "textbox" })
  622. rbracket.text = "]"
  623. lbracket = widget({type = "textbox" })
  624. lbracket.text = "["
  625. line = widget({type = "textbox" })
  626. line.text = "|"
  627.  
  628. -- Space
  629. space = widget({ type = "textbox" })
  630. space.text = " "
  631.  
  632. -- MPD controls
  633. music_play = awful.widget.launcher({
  634.     image = beautiful.widget_play,
  635.     command = "ncmpcpp toggle && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  636.   })
  637.  
  638.   music_pause = awful.widget.launcher({
  639.     image = beautiful.widget_pause,
  640.     command = "ncmpcpp toggle && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  641.   })
  642.   music_pause.visible = false
  643.  
  644.   music_stop = awful.widget.launcher({
  645.     image = beautiful.widget_stop,
  646.     command = "ncmpcpp stop && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  647.   })
  648.  
  649.   music_prev = awful.widget.launcher({
  650.     image = beautiful.widget_prev,
  651.     command = "ncmpcpp prev && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  652.   })
  653.  
  654.   music_next = awful.widget.launcher({
  655.     image = beautiful.widget_next,
  656.     command = "ncmpcpp next && echo -e 'vicious.force({ mpdwidget, })' | awesome-client"
  657.   })
  658.  
  659. -- Pianobar Icon
  660. -- pandoraicon = widget({ type = "imagebox" })
  661.  --pandoraicon.image = image(beautiful.widget_pandora)
  662.  
  663.  --pandoraicon:buttons(awful.util.table.join(
  664.   --   awful.button({ }, 1, function () awful.util.spawn("terminal -e tmux -c pianobar", false) end),
  665.    -- awful.button({ }, 2, function () awful.util.spawn("terminal -e tmux attach", false) end)
  666. -- ))
  667.  
  668.  
  669.  
  670. -- Create a systray
  671. mysystray = widget({ type = "systray" })
  672.  
  673. -- Create a wibox for each screen and add it
  674. mywibox = {}
  675. mybottomwibox = {}
  676. mystatusbar = {}
  677. mypromptbox = {}
  678. mylayoutbox = {}
  679. mytaglist = {}
  680. mytaglist.buttons = awful.util.table.join(
  681.                     awful.button({ }, 1, awful.tag.viewonly),
  682.                     awful.button({ modkey }, 1, awful.client.movetotag),
  683.                     awful.button({ }, 3, awful.tag.viewtoggle),
  684.                     awful.button({ modkey }, 3, awful.client.toggletag),
  685.                     awful.button({ }, 4, awful.tag.viewnext),
  686.                     awful.button({ }, 5, awful.tag.viewprev)
  687.                     )
  688. mytasklist = {}
  689. mytasklist.buttons = awful.util.table.join(
  690.                      awful.button({ }, 1, function (c)
  691.                                               if c == client.focus then
  692.                                                   c.minimized = true
  693.                                               else
  694.                                                   if not c:isvisible() then
  695.                                                       awful.tag.viewonly(c:tags()[1])
  696.                                                   end
  697.                                                   -- This will also un-minimize
  698.                                                   -- the client, if needed
  699.                                                   client.focus = c
  700.                                                   c:raise()
  701.                                               end
  702.                                           end),
  703.                      awful.button({ }, 2, function ()
  704.                                               if instance then
  705.                                                   instance:hide()
  706.                                                   instance = nil
  707.                                               else
  708.                                                   instance = awful.menu.clients({ width=250 })
  709.                                               end
  710.                                           end),
  711.                      awful.button({ }, 3, function ()
  712.                                               awful.client.focus.byidx(1)
  713.                                               if client.focus then client.focus:kill() end
  714.                                           end),
  715.                      awful.button({ }, 4, function ()
  716.                                               awful.client.focus.byidx(1)
  717.                                               if client.focus then client.focus:raise() end
  718.                                           end),
  719.                      awful.button({ }, 5, function ()
  720.                                               awful.client.focus.byidx(-1)
  721.                                               if client.focus then client.focus:raise() end
  722.                                           end))
  723.  
  724. for s = 1, screen.count() do
  725.     -- Create a promptbox for each screen
  726.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  727.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  728.    
  729.     -- We need one layoutbox per screen.
  730.     mylayoutbox[s] = awful.widget.layoutbox(s)
  731.     mylayoutbox[s]:buttons(awful.util.table.join(
  732.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  733.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  734.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  735.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  736.     -- Create a taglist widget
  737.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  738.  
  739.     -- Create a tasklist widget
  740.     mytasklist[s] = awful.widget.tasklist(function(c)
  741.                                               return awful.widget.tasklist.label.currenttags(c, s)
  742.                                           end, mytasklist.buttons)
  743.  
  744.     -- Create the upper wibox
  745.     mywibox[s] = awful.wibox({ position = "top", screen = s, border_width = 0, height = 16 })
  746.     -- Add widgets to the wibox - order matters
  747.     mywibox[s].widgets = {
  748.         {
  749.              mylauncher,
  750.             space,
  751.             mytaglist[s],
  752.             space,
  753.             mypromptbox[s],
  754.             layout = awful.widget.layout.horizontal.leftright
  755.         },
  756.         mylayoutbox[s],
  757.         space,
  758.         mytextclock,
  759.         clockicon,
  760.         space,
  761.         space,
  762.         syswidget,
  763.         -- space,
  764.         -- sysicon,
  765.         space,
  766.         space,
  767.  
  768.         s == 1 and mysystray or nil,
  769.         mytasklist[s],
  770.         layout = awful.widget.layout.horizontal.rightleft
  771.     }
  772.    
  773.      mybottomwibox[s] = awful.wibox({ position = "bottom", screen = s, border_width = 0, height = 16 })
  774.  
  775.      mybottomwibox[s].widgets = {
  776.      {
  777.         space, lbracket, volicon, space, volbar, space, volumewidget, space, rbracket, space, space, lbracket, baticon, space, batbar, space, batwidget, space, rbracket, space, space, lbracket, diskwidget, space, membar, space, memwidget, space, rbracket, space, space, lbracket, cpuicon, space, cpubar, space, cpuwidget, space, rbracket, space, lbracket, weathericon, weatherwidget, rbracket, volume_widget,
  778.         layout = awful.widget.layout.horizontal.leftright
  779.      },
  780.         space, rbracket, uptimewidget, space, uptimeicon, lbracket, space, space, rbracket, space, tempwidget, space, tempicon, lbracket, space, space, rbracket, space, netupinfo, netupicon, space, netdowninfo, netdownicon, lbracket, space, space, rbracket, space, pacwidget, pacicon, lbracket, space, space, rbracket, space, mygmail, space, mygmailimg, lbracket, space, space, rbracket, space, music_next, music_play, music_pause, music_stop, music_prev, space, mpdwidget, space, mpdicon, space, lbracket,
  781.         layout = awful.widget.layout.horizontal.rightleft
  782.       }
  783.    end
  784.  
  785. -- }}}
  786.  
  787. -- {{{ Mouse bindings
  788. root.buttons(awful.util.table.join(
  789.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  790.     awful.button({ }, 4, awful.tag.viewnext),
  791.     awful.button({ }, 5, awful.tag.viewprev)
  792. ))
  793. -- }}}
  794.  
  795. -- {{{ Key bindings
  796. globalkeys = awful.util.table.join(
  797.     awful.key({ modkey, "Control" }, "Left",   awful.tag.viewprev       ),
  798.     awful.key({ modkey, "Control" }, "Right",  awful.tag.viewnext       ),
  799.     awful.key({ modkey, "" }, "`", awful.tag.history.restore),
  800.  
  801.     awful.key({modkey}, "g", revelation),
  802.  
  803.     awful.key({ modkey,           }, "Left",
  804.         function ()
  805.             awful.client.focus.byidx( 1)
  806.             if client.focus then client.focus:raise() end
  807.         end),
  808.     awful.key({ modkey,           }, "Right",
  809.         function ()
  810.             awful.client.focus.byidx(-1)
  811.             if client.focus then client.focus:raise() end
  812.         end),
  813.     awful.key({ modkey,           }, "Escape", function () mymainmenu:show({keygrabber=true}) end),
  814.  
  815.     -- Show/Hide Wibox
  816.     awful.key({ modkey }, "b", function ()
  817.     mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
  818.     mybottomwibox[mouse.screen].visible = not mybottomwibox[mouse.screen].visible end),
  819.  
  820.     -- Layout manipulation
  821.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  822.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  823.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  824.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  825.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  826.     --awful.key({ modkey,           }, "Tab",
  827.     --    function ()
  828.     --        awful.client.focus.history.previous()
  829.     --        if client.focus then                client.focus:raise()
  830.     --        end
  831.     --    end),
  832.     -- Standard program
  833.     awful.key({ modkey,           }, "t", function () awful.util.spawn("urxvt") end),
  834.     awful.key({ modkey, altkey    }, "t", function () awful.util.spawn( "sudo urxvt" ) end),
  835.  
  836.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  837.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  838.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  839.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  840.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  841.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  842.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  843.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  844.     -- Volume control
  845.     awful.key({ altkey }, "plus", function () awful.util.spawn("amixer -q sset Master 1dB+", false) end),
  846.     awful.key({ altkey }, "minus", function () awful.util.spawn("amixer -q sset Master 1dB-", false) end),
  847.     --Music control
  848.     awful.key({ altkey,           }, "Up",      function () awful.util.spawn( "ncmpcpp toggle", false ) end),
  849.     awful.key({ altkey,           }, "Down",    function () awful.util.spawn( "ncmpcpp stop", false ) end ),
  850.     awful.key({ altkey,           }, "Left",    function () awful.util.spawn( "ncmpcpp prev", false ) end ),
  851.     awful.key({ altkey,           }, "Right",   function () awful.util.spawn( "ncmpcpp next", false ) end ),
  852.  
  853.     -- Applications
  854.  
  855.     awful.key({ modkey,        }, "w",      function () awful.util.spawn( "firefox", false ) end),
  856.     awful.key({ modkey,        }, "n",      function () awful.util.spawn(music) end),
  857.     awful.key({ modkey, altkey }, "c",      function () awful.util.spawn(chat) end),
  858.     awful.key({ modkey,        }, "h",      function () awful.util.spawn(tasks) end),
  859.     awful.key({ modkey, "Control" }, "t",      function () awful.util.spawn( "thunderbird", false ) end),
  860.     awful.key({ modkey, altkey }, "t",      function () awful.util.spawn( "thunderbird -compose", false ) end),
  861.     --awful.key({ modkey,        }, "j",      function () awful.util.spawn( "jdownloader", false ) end),
  862.     --awful.key({ modkey,        }, "m",      function () awful.util.spawn( "motion", false ) end),
  863.     --awful.key({ modkey, altkey }, "m",      function () awful.util.spawn( "sh ./.scripts/stop-motion", false ) end),
  864.     awful.key({ altkey,        }, "s",      function () awful.util.spawn( "scrot -c", false ) end),
  865.     --awful.key({ modkey,        }, "p",      function () awful.util.spawn( "thunar", false ) end),
  866.     awful.key({ modkey,        }, "d",      function () awful.util.spawn( "pcmanfm", false ) end),
  867.     --awful.key({ modkey, altkey }, "p",      function () awful.util.spawn( "sudo thunar /root", false ) end),
  868.     awful.key({ modkey, altkey }, "d",      function () awful.util.spawn( "sudo pcmanfm /root", false ) end),
  869.     --awful.key({ modkey,        }, "i",      function () awful.util.spawn( "sh ./.scripts/restartwifi", false ) end),
  870.     awful.key({ modkey,        }, "u",      function () awful.util.spawn( "mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -title Webcam -fps 25 -vf screenshot", false ) end),
  871.     --awful.key({ modkey, altkey }, "u",      function () awful.util.spawn( "wxcam", false ) end),
  872.     awful.key({ modkey,        }, "p",      function () awful.util.spawn( "pithos", false ) end),
  873.     awful.key({ altkey,        }, "p",      function () awful.util.spawn( "pavucontrol", false ) end),
  874.     awful.key({ altkey,        }, "m",      function () awful.util.spawn( "mumble", false ) end),
  875.     awful.key({ modkey,        }, "s",      function () awful.util.spawn( "skype", false ) end),
  876.     awful.key({ modkey,        }, "e",      function () awful.util.spawn(gui_editor) end),
  877.     awful.key({ modkey, altkey }, "e",      function () awful.util.spawn(editor_cmd) end),
  878.     awful.key({ modkey,        }, "f",      function () awful.util.spawn(cli_fileman) end),
  879.  
  880.     -- Shutdown
  881.  
  882.     awful.key({ }, "XF86PowerOff",          function () awful.util.spawn( "sudo halt", false ) end),
  883.     awful.key({ }, "Help",                  function () awful.util.spawn( "sudo reboot", false ) end),
  884.    
  885.    awful.key({ modkey, }, "x",     function () awful.util.spawn("xscreensaver-command -lock") end),
  886.   --  awful.key({ modkey,        }, "x",      function () awful.util.spawn( "xkill", false ) end),
  887.    
  888.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  889.     awful.key({ }, "XF86HomePage", awesome.quit),
  890.  
  891.      -- change background
  892.    awful.key({ modkey, altkey }, "b",               function () awful.util.spawn("awsetbg -t -f  -r " .. awful.util.getdir("config") .. "/wallpapers/") end),
  893.  
  894.    
  895.     -- Print Screen Key
  896.    awful.key({ }, "Print",                   function () awful.util.spawn("scrot -e 'mv $f ~/Screenshots/ 2>/dev/null'") end),
  897.  
  898.    -- Multimedia keys
  899. --    awful.key({ }, "XF86AudioMute",           function () awful.util.spawn("sh -c 'amixer -q sset Master toggle'") end),
  900. --    awful.key({ }, "XF86AudioRaiseVolume",    function () awful.util.spawn("sh -c 'amixer -q sset Master 2%+'") end),
  901. --    awful.key({ }, "XF86AudioLowerVolume",    function () awful.util.spawn("sh -c 'amixer -q sset Master 2%-'") end),
  902.  --   awful.key({ }, "XF86AudioMute",           function () awful.util.spawn("sh -c '" .. home_path .. ".config/awesome/volumechanger.sh mute'") end),
  903.   --  awful.key({ }, "XF86AudioRaiseVolume",    function () awful.util.spawn("sh -c '" .. home_path .. ".config/awesome/volumechanger.sh increase'") end),
  904.   --  awful.key({ }, "XF86AudioLowerVolume",    function () awful.util.spawn("sh -c '" .. home_path .. ".config/awesome/volumechanger.sh decrease'") end),
  905. --   awful.key({ }, "XF86AudioMedia",          function () awful.util.spawn("gmpc") end),
  906.  
  907.     -- F-key shortcut bindings
  908.  
  909.    -- awful.key({modkey, }, "F1",                   function () awful.util.spawn_with_shell("spacefm > /dev/null 1>&2") end),
  910. --    awful.key({modkey, }, "F2",                   function () awful.util.spawn("sh -c 'firefox -P Tor > /dev/null 2>&1'") end),
  911.   awful.key({modkey, }, "F4",                   function () awful.util.spawn_with_shell("pidgin > /dev/null 2>&1") end),
  912.    --awful.key({modkey, }, "F4",                   function () awful.util.spawn("skype") end),
  913.    -- awful.key({modkey, }, "F5",                   function () awful.util.spawn("pavucontrol") end),
  914. --    awful.key({modkey, }, "F8",                   function () awful.util.spawn("sh -c 'firefox -P Normal -no-remote > /dev/null 2>&1'") end),
  915. --    awful.key({modkey, }, "F9",                   function () awful.util.spawn("claws-mail") end),
  916.  
  917.     -- Prompt
  918.     awful.key({ modkey }, "r",     function () mypromptbox[mouse.screen]:run() end),
  919.     awful.key({ modkey }, "q",
  920.               function ()
  921.                   awful.prompt.run({ prompt = "Run in urxvt: " },
  922.                   mypromptbox[mouse.screen].widget,
  923.                   function (...) awful.util.spawn(terminal .. " -hold -e " .. ...) end,
  924.                   awful.completion.shell,
  925.                   -- awful.util.eval, nil,
  926.                   awful.util.getdir("cache") .. "/history")
  927.               end)
  928. )
  929. clientkeys = awful.util.table.join(
  930.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  931.     awful.key({ modkey,           }, "c",      function (c) c:kill()                         end),
  932.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  933.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  934.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  935.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  936.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  937.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  938.     awful.key({ modkey,           }, "m",
  939.         function (c)
  940.             c.maximized_horizontal = not c.maximized_horizontal
  941.             c.maximized_vertical   = not c.maximized_vertical
  942.         end)
  943. )
  944.  
  945. -- Compute the maximum number of digit we need, limited to 9
  946. keynumber = 0
  947. for s = 1, screen.count() do
  948.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  949. end
  950.  
  951. -- Bind all key numbers to tags.
  952. -- Be careful: we use keycodes to make it works on any keyboard layout.
  953. -- This should map on the top row of your keyboard, usually 1 to 9.
  954. for i = 1, keynumber do
  955.     globalkeys = awful.util.table.join(globalkeys,
  956.         awful.key({ modkey }, "#" .. i + 9,
  957.                   function ()
  958.                         local screen = mouse.screen
  959.                         if tags[screen][i] then
  960.                             awful.tag.viewonly(tags[screen][i])
  961.                         end
  962.                   end),
  963.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  964.                   function ()
  965.                       local screen = mouse.screen
  966.                       if tags[screen][i] then
  967.                           awful.tag.viewtoggle(tags[screen][i])
  968.                       end
  969.                   end),
  970.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  971.                   function ()
  972.                       if client.focus and tags[client.focus.screen][i] then
  973.                           awful.client.movetotag(tags[client.focus.screen][i])
  974.                       end
  975.                   end),
  976.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  977.                   function ()
  978.                       if client.focus and tags[client.focus.screen][i] then
  979.                           awful.client.toggletag(tags[client.focus.screen][i])
  980.                       end
  981.                   end))
  982. end
  983.  
  984. clientbuttons = awful.util.table.join(
  985.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  986.     awful.button({ modkey }, 1, awful.mouse.client.move),
  987.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  988.  
  989. -- Set keys
  990. root.keys(globalkeys)
  991. -- }}}
  992.  
  993. -- {{{ Rules
  994. awful.rules.rules = {
  995.     -- All clients will match this rule.
  996.     { rule = { },
  997.       properties = { border_width = beautiful.border_width,
  998.                      border_color = beautiful.border_normal,
  999.                      focus = true,
  1000.                      keys = clientkeys,
  1001.                      maximized_vertical = false,
  1002.                      maximized_horizontal = false,
  1003.                      buttons = clientbuttons,
  1004.                          size_hints_honor = false
  1005.                     }
  1006.    },
  1007.     { rule = { class = "Vlc" },
  1008.       properties = { tag = tags[2][5], switchtotag = true } },
  1009.      
  1010.           { rule = { class = "Urxvt" },
  1011.       properties = { tag = tags[1][1], switchtotag = true } },
  1012.    
  1013.        { rule = { class = "urxvt" },
  1014.       properties = { tag = tags[1][1], switchtotag = true } },
  1015.     { rule = { class = "Gimp" },
  1016.       properties = { tag = tags[1][6] } },
  1017.      
  1018.       { rule = { class = "Lightread" },
  1019.       properties = { tag = tags[1][6] } },
  1020.  
  1021.     { rule = { instance = "Blender" },
  1022.       properties = { tag = tags[1][6] } },
  1023.    
  1024.     { rule = { instance = "plugin-container" },
  1025.       properties = { floating = true } },
  1026.  
  1027.     { rule = { class = "Firefox" },
  1028.       properties = { tag = tags[1][2], switchtotag = true } },
  1029.      
  1030.       { rule = { class = "iron" },
  1031.       properties = { tag = tags[2][2], switchtotag = true } },
  1032.    
  1033.     { rule = { class = "Firefox", instance = "Download" },
  1034.       properties = { tag = tags[1][2], floating = true } },
  1035.  
  1036.     { rule = { class = "Qbittorrent" },
  1037.       properties = { tag = tags[1][2], switchtotag = true } },
  1038.    
  1039.     { rule = { class = "Rxvt" },
  1040.       properties = { tag = tags[2][1], switchtotag = true } },
  1041.    
  1042.     { rule = { class = "Thunderbird" },
  1043.       properties = { tag = tags[1][6], switchtotag = true } },
  1044.    
  1045.     { rule = { class = "Skype" },
  1046.       properties = { tag = tags[2][4], floating = false, switchtotag = true } },
  1047.  
  1048.       { rule = { class = "Mumble" },
  1049.       properties = { tag = tags[2][4], floating = false, switchtotag = true } },
  1050.      
  1051.     { rule = { class = "Gajim" },
  1052.       properties = { tag = tags[1][4], floating = true, switchtotag = true } },
  1053.  
  1054.     { rule = { class = "eog" },
  1055.       properties = { tag = tags[1][3], switchtotag = true } },
  1056.    
  1057.     { rule = { class = "Qalculate-gtk" },
  1058.       properties = { tag = tags[1][6], switchtotag = true } },
  1059.    
  1060.     { rule = { class = "Convertall.py" },
  1061.       properties = { tag = tags[1][6], switchtotag = true } },
  1062.    
  1063.     { rule = { class = "QtConverter.pyw" },
  1064.       properties = { tag = tags[1][6], switchtotag = true } },
  1065.    
  1066.     { rule = { class = "Kmplot" },
  1067.       properties = { tag = tags[1][6], switchtotag = true } },
  1068.    
  1069.     { rule = { class = "Gelemental" },
  1070.       properties = { tag = tags[1][6], switchtotag = true } },
  1071.    
  1072.     { rule = { class = "Ktechlab" },
  1073.       properties = { tag = tags[1][6] } },
  1074.    
  1075.     { rule = { class = "Gucharmap" },
  1076.       properties = { tag = tags[1][3], switchtotag = true } },
  1077.    
  1078.     { rule = { class = "Thunar" },
  1079.       properties = { tag = tags[1][3], switchtotag = true } },
  1080.    
  1081.     { rule = { class = "Pcmanfm" },
  1082.       properties = { tag = tags[1][3], switchtotag = true } },
  1083.    
  1084.     { rule = { class = "Pcmanfm", name = "Moving*" },
  1085.       properties = { tag = tags[1][3], floating = true } },
  1086.    
  1087.     { rule = { class = "Pcmanfm", name = "Copying*" },
  1088.       properties = { tag = tags[1][3], floating = true } },
  1089.    
  1090.     { rule = { class = "Pcmanfm", name = "File Already Exists" },
  1091.       properties = { tag = tags[1][3], floating = true } },
  1092.  
  1093.     { rule = { class = "Pcmanfm", name = "Progress Dialog" },
  1094.       properties = { tag = tags[1][3], floating = true } },
  1095.    
  1096.     { rule = { class = "scite" },
  1097.       properties = { tag = tags[2][6], switchtotag = true } },
  1098.    
  1099.     { rule = { class = "Gvim" },
  1100.       properties = { tag = tags[1][1], switchtotag = true } },
  1101.    
  1102.     { rule = { class = "Kcolorchooser" },
  1103.       properties = { tag = tags[1][6], switchtotag = true } },
  1104.    
  1105.     { rule = { class = "Xournal" },
  1106.       properties = { tag = tags[1][3] } },
  1107.    
  1108.     { rule = { class = "Okular" },
  1109.       properties = { tag = tags[1][3], switchtotag = true } },
  1110.    
  1111.     { rule = { class = "GWepCrackGui" },
  1112.       properties = { tag = tags[1][2], floating = true } },
  1113.    
  1114.     { rule = { class = "Amule" },
  1115.       properties = { tag = tags[1][2] } },
  1116.    
  1117.     { rule = { class = "Zenity", name = "filmlimitless" },
  1118.       properties = { tag = tags[1][5] } },
  1119.    
  1120.     { rule = { class = "Torrent-search" },
  1121.       properties = { tag = tags[1][2], switchtotag = true } },
  1122.    
  1123.     { rule = { class = "K3b" },
  1124.       properties = { tag = tags[1][5], switchtotag = true } },
  1125.    
  1126.     { rule = { class = "SciTE" },
  1127.       properties = { tag = tags[2][6] } },
  1128.    
  1129.     { rule = { class = "Gnome-mplayer" },
  1130.       properties = { tag = tags[1][5], switchtotag = true } },
  1131.    
  1132.     { rule = { class = "MPlayer" },
  1133.       properties = { tag = tags[2][9], switchtotag = true } },
  1134.    
  1135.     { rule = { class = "Pithos" },
  1136.       properties = { tag = tags[2][5], switchtotag = true } },
  1137.      
  1138.       { rule = { class = "Wine" },
  1139.       properties = { tag = tags[1][8], switchtotag = true } },
  1140.      
  1141.       { rule = { class = "Gthumb" },
  1142.       properties = { tag = tags[1][9], switchtotag = true } },
  1143.      
  1144.       { rule = { class = "Pavucontrol" },
  1145.       properties = { tag = tags[2][5], switchtotag = true } },
  1146.    
  1147.     { rule = { class = "Gtk-recordMyDesktop" },
  1148.       properties = { tag = tags[1][5], switchtotag = true } },
  1149.    
  1150.     { rule = { class = "Unetbootin.elf" },
  1151.       properties = { tag = tags[1][5], switchtotag = true } },
  1152.    
  1153.     { rule = { class = "Weechat" },
  1154.       properties = { tag = tags[1][4], switchtotag = true } },
  1155.  
  1156.     { rule = { class = "Bleachbit" },
  1157.       properties = { tag = tags[1][3], switchtotag = true } },
  1158.    
  1159.     { rule = { class = "VirtualBox" },
  1160.       properties = { tag = tags[1][7] } },
  1161.    
  1162.     { rule = { class = "Pidgin" },
  1163.       properties = { tag = tags[2][4], switchtotag = true } },
  1164.  
  1165.     { rule = { class = "Hardinfo" },
  1166.       properties = { tag = tags[1][3] } },
  1167.    
  1168.     { rule = { class = "Gpartedbin" },
  1169.       properties = { tag = tags[1][3], switchtotag = true } },
  1170.  
  1171.     -- { rule = { class = "Lxappearance" },
  1172.     --   properties = { tag = tags[1][6] } },
  1173. }
  1174.  
  1175. -- }}}
  1176.  
  1177. -- {{{ Signals
  1178. -- Signal function to execute when a new client appears.
  1179. client.add_signal("manage", function (c, startup)
  1180.     -- Add a titlebar
  1181.     --awful.titlebar.add(c, { modkey = modkey })
  1182.  
  1183.     -- Enable sloppy focus
  1184.     c:add_signal("mouse::enter", function(c)
  1185.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  1186.             and awful.client.focus.filter(c) then
  1187.             client.focus = c
  1188.         end
  1189.     end)
  1190.  
  1191.     if not startup then
  1192.         -- Set the windows at the slave,
  1193.         -- i.e. put it at the end of others instead of setting it master.
  1194.         -- awful.client.setslave(c)
  1195.  
  1196.         -- Put windows in a smart way, only if they does not set an initial position.
  1197.         if not c.size_hints.user_position and not c.size_hints.program_position then
  1198.             awful.placement.no_overlap(c)
  1199.             awful.placement.no_offscreen(c)
  1200.         end
  1201.     end
  1202. end)
  1203.  
  1204. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  1205. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  1206.  
  1207. -- menu.add_signal("focus", function(c)
  1208. --                              c.border_color = beautiful.border_focus
  1209. --                              c.opacity = 1
  1210. --                           end)
  1211. -- menu.add_signal("unfocus", function(c)
  1212. --                                c.border_color = beautiful.border_normal
  1213. --                                c.opacity = 1
  1214. --                             end)
  1215.  
  1216. -- }}}
  1217.  
  1218. -- {{{ Functions to help launch run commands in a terminal using ":" keyword
  1219. function check_for_terminal (command)
  1220.    if command:sub(1,1) == ":" then
  1221.       command = terminal .. ' -e "' .. command:sub(2) .. '"'
  1222.    end
  1223.    awful.util.spawn(command)
  1224. end
  1225.    
  1226. function clean_for_completion (command, cur_pos, ncomp, shell)
  1227.    local term = false
  1228.    if command:sub(1,1) == ":" then
  1229.       term = true
  1230.       command = command:sub(2)
  1231.       cur_pos = cur_pos - 1
  1232.    end
  1233.    command, cur_pos =  awful.completion.shell(command, cur_pos,ncomp,shell)
  1234.    if term == true then
  1235.       command = ':' .. command
  1236.       cur_pos = cur_pos + 1
  1237.    end
  1238.    return command, cur_pos
  1239. end
  1240. -- }}}
  1241.  
  1242. -- {{{ Autostart
  1243.  
  1244.  
  1245. function run_once(cmd)
  1246.   findme = cmd
  1247.   firstspace = cmd:find(" ")
  1248.   if firstspace then
  1249.      findme = cmd:sub(0, firstspace-1)
  1250.   end
  1251.   awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
  1252.  end
  1253.  
  1254.  --os.execute"dex -a -e Awesome ~/.screenlayout/ds.sh"
  1255.  
  1256.    --run_once os.execute('arandr --options /home/larry/.screenlayout/ds.sh &')
  1257.   --run_once("xsetroot -cursor_name Adwaita")
  1258.   --run_once("compton -cCGfF -o 0.38 -O 200 -I 200 -t 0.02 -l 0.02 -r 3.2 -D2")
  1259.   --run_once("devilspie")
  1260.   run_once('xrdb ~/.Xresources')
  1261.   --run_once('urxvt')
  1262.     -- run_once('ranger')
  1263.   --run_once('weechat-curses')
  1264.   --run_once("terminal -q -f -o")
  1265.   -- run_once("wicd-client")
  1266.   --run_once("sudo netcfg home-wireless-wpa")
  1267.  -- run_once("klipper")
  1268.   --run_once('firefox')
  1269. -- run_once('thunderbird')
  1270. -- run_once('vlc')
  1271.  -- run_once("dropboxd")
  1272.   --run_once('mumble')
  1273. -- run_once('pidgin')
  1274.   --run_once('skype')
  1275.   --run_once('pithos')
  1276.   --run_once('pavucontrol')
  1277. --run_once('numlockx')
  1278. --run_once('mutt')
  1279. --run_once("/home/larry/.screenlayout/ds.sh")
  1280. --run_once('feh --no-xinerama --bg-scale ~/Gimp/swirl\ archlinux.png')
  1281.   --run_once('tmux attach')
  1282. -- }}}
  1283.  
  1284. -- {{{ Disable startup-notification globally
  1285. local oldspawn = awful.util.spawn
  1286. awful.util.spawn = function (s)
  1287.   oldspawn(s, false)
  1288. end
  1289.  
  1290. -- }}}