Guest User

rc.lua

a guest
May 19th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.26 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. -- Load Debian menu entries
  10. require("debian.menu")
  11. -- User libraries
  12. vicious = require("vicious")
  13. scratch = require("scratch")
  14. -- load the 'run or raise' function
  15. -- local ror = require("aweror")
  16.  
  17. -- generate and add the 'run or raise' key bindings to the globalkeys table
  18. -- globalkeys = awful.util.table.join(globalkeys, ror.genkeys(modkey))
  19.  
  20. -- root.keys(globalkeys)
  21.  
  22. --{{  Java GUI's fix
  23. awful.util.spawn_with_shell("wmname LG3D")
  24.  
  25.  
  26. --transparency
  27. -- awful.util.spawn_with_shell("xcompmgr -cF &")
  28.  
  29. function run_or_raise(cmd, properties)
  30.    --{{{
  31.    local clients = client.get()
  32.    local focused = awful.client.next(0)
  33.    local findex = 0
  34.    local matched_clients = {}
  35.    local n = 0
  36.    for i, c in pairs(clients) do
  37.       --make an array of matched clients
  38.       if match(properties, c) then
  39.          n = n + 1
  40.          matched_clients[n] = c
  41.          if c == focused then
  42.             findex = n
  43.          end
  44.       end
  45.    end
  46.    if n > 0 then
  47.       local c = matched_clients[1]
  48.       -- if the focused window matched switch focus to next in list
  49.       if 0 < findex and findex < n then
  50.          c = matched_clients[findex+1]
  51.       end
  52.       local ctags = c:tags()
  53.       if table.getn(ctags) == 0 then
  54.          -- ctags is empty, show client on current tag
  55.          local curtag = awful.tag.selected()
  56.          awful.client.movetotag(curtag, c)
  57.       else
  58.          -- Otherwise, pop to first tag client is visible on
  59.          awful.tag.viewonly(ctags[1])
  60.       end
  61.       -- And then focus the client
  62.       client.focus = c
  63.       c:raise()
  64.       return
  65.    end
  66.    awful.util.spawn_with_shell(cmd)
  67.    --awful.util.spawn(cmd)
  68. end
  69. --}}}
  70.  
  71.  
  72. -- Returns true if all pairs in table1 are present in table2
  73. function match (table1, table2)
  74.    for k, v in pairs(table1) do
  75.       if table2[k] ~= v and not table2[k]:find(v) then
  76.          return false
  77.       end
  78.    end
  79.    return true
  80. end
  81.  
  82. local function run(cmd)
  83.     return awful.util.spawn(cmd)
  84. end
  85.  
  86. local function shell_run(cmd)
  87.     return awful.util.spawn_with_shell(cmd)
  88. end
  89.  
  90. --Autostart
  91. function run_once(prg, args)
  92.   if not prg then
  93.     do return nil end
  94.   end
  95.   if not args then
  96.     args=""
  97.   end
  98.   awful.util.spawn_with_shell('pgrep -f -u $USER -x ' .. prg .. ' || (' .. prg .. ' ' .. args .. ')')
  99. end
  100.  
  101. --{{{
  102. -------------------- Run or raise script --------------------
  103. -- Run or raise definition, see: http://awesome.naquadah.org/wiki/Run_or_raise
  104. -- Spawns cmd if no client can be found matching properties
  105. -- If such a client can be found, pop to first tag where it is visible, and give it focus
  106. -- cmd: the command to execute
  107. -- properties: a table of properties to match against clients.  Possible entries: any properties of the client object
  108. function run_or_raise(cmd, properties)
  109.    local clients = client.get()
  110.    local focused = awful.client.next(0)
  111.    local findex = 0
  112.    local matched_clients = {}
  113.    local n = 0
  114.    for i, c in pairs(clients) do
  115.       --make an array of matched clients
  116.       if match(properties, c) then
  117.          n = n + 1
  118.          matched_clients[n] = c
  119.          if c == focused then
  120.             findex = n
  121.          end
  122.       end
  123.    end
  124.    if n > 0 then
  125.       local c = matched_clients[1]
  126.       -- if the focused window matched switch focus to next in list
  127.       if 0 < findex and findex < n then
  128.          c = matched_clients[findex+1]
  129.       end
  130.       local ctags = c:tags()
  131.       if table.getn(ctags) == 0 then
  132.          -- ctags is empty, show client on current tag
  133.          local curtag = awful.tag.selected()
  134.          awful.client.movetotag(curtag, c)
  135.       else
  136.          -- Otherwise, pop to first tag client is visible on
  137.          awful.tag.viewonly(ctags[1])
  138.       end
  139.       -- And then focus the client
  140.       client.focus = c
  141.       c:raise()
  142.       return
  143.    end
  144.    awful.util.spawn(cmd)
  145. end
  146.  
  147. --}}}
  148.  
  149. -- {{{ Error handling
  150. -- Check if awesome encountered an error during startup and fell back to
  151. -- another config (This code will only ever execute for the fallback config)
  152. if awesome.startup_errors then
  153.     naughty.notify({ preset = naughty.config.presets.critical,
  154.                      title = "Oops, there were errors during startup!",
  155.                      text = awesome.startup_errors })
  156. end
  157.  
  158. -- Handle runtime errors after startup
  159. do
  160.     local in_error = false
  161.     awesome.add_signal("debug::error", function (err)
  162.         -- Make sure we don't go into an endless error loop
  163.         if in_error then return end
  164.         in_error = true
  165.  
  166.         naughty.notify({ preset = naughty.config.presets.critical,
  167.                          title = "Oops, an error happened!",
  168.                          text = err })
  169.         in_error = false
  170.     end)
  171. end
  172. -- }}}
  173.  
  174. -- {{{ Variable definitions
  175. -- Themes define colours, icons, and wallpapers
  176. -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  177. config_dir=("/home/murat/.config/awesome/")
  178. -- beautiful.init(config_dir .. "zenburn.lua")
  179. beautiful.init("/home/murat/.config/awesome/default/theme.lua")
  180.  
  181. -- beautiful.init(config_dir .. "sky.lua")
  182.  
  183.  
  184. -- This is used later as the default terminal and editor to run.
  185. terminal = "gnome-terminal"
  186. editor = os.getenv("EDITOR") or "nano"
  187. editor_cmd = terminal .. " -e " .. editor
  188.  
  189. -- Default modkey.
  190. -- Usually, Mod4 is the key with a logo between Control and Alt.
  191. -- If you do not like this or do not have such a key,
  192. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  193. -- However, you can use another modifier like Mod1, but it may interact with others.
  194. modkey = "Mod4"
  195.  
  196. run_once("nm-applet")
  197. run_once("fluxgui")
  198. -- run_once("/home/murat/.wififix")
  199. -- run_once("conky")
  200. run_once("gnome-keyring-daemon")
  201. run_once("gnome-settings-daemon")
  202. run_once("setxkbmap -layout us,ru -variant -option grp:caps_toggle,terminate:ctrl_alt_bksp")
  203. -- run_once("jupiter")
  204. run_once("xxkb")
  205. run_once("skype")
  206. run_once("pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness 20 ")
  207. run_once("dbus-send  --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:0")
  208. -- Table of layouts to cover with awful.layout.inc, order matters.
  209. layouts =
  210. {
  211.     awful.layout.suit.floating, --1
  212.     awful.layout.suit.tile,     --2
  213.     awful.layout.suit.tile.left,--3
  214.     awful.layout.suit.tile.bottom,--4
  215.     awful.layout.suit.tile.top, --5
  216.     awful.layout.suit.fair,
  217.     awful.layout.suit.fair.horizontal,
  218.     --awful.layout.suit.spiral,
  219.     --awful.layout.suit.spiral.dwindle,
  220.     --awful.layout.suit.max,
  221.     --awful.layout.suit.max.fullscreen,
  222.     --awful.layout.suit.magnifier
  223. }
  224. -- }}}
  225.  
  226.  -- {{{ Tags
  227.  -- Define a tag table which will hold all screen tags.
  228.  tags = {
  229.    names  = { "www", "dev", "im", "misc", "film" },
  230.    layout = { layouts[2], layouts[2], layouts[1], layouts[5], layouts[5],
  231.  }}
  232.  for s = 1, screen.count() do
  233.      -- Each screen has its own tag table.
  234.      tags[s] = awful.tag(tags.names, s, tags.layout)
  235.  end
  236.  -- }}}
  237.  
  238. -- {{{ Menu
  239. -- Create a laucher widget and a main menu
  240. myawesomemenu = {
  241.    { "manual", terminal .. " -e man awesome" },
  242.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  243.    { "restart", awesome.restart },
  244.    { "quit", awesome.quit }
  245. }
  246.  
  247. mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
  248.                                     { "Terminal", terminal },
  249.                                     {"Chrome", "google-chrome"},
  250.                                     {"Sublime", "sublime-text-2"},
  251.                                     {"Fileman", "nautilus --no-desktop"},
  252.                                     {"Transmission", "transmission-gtk"},
  253.                                     {"Skype", "skype"},
  254.                                     {"Vlc", "vlc"},
  255.                                     {"Suspend", "dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.freedesktop.UPower.Suspend"},
  256.                                     {"Reboot", "dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart"},
  257.                                     {"Shutdown", "dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop"}
  258.                                   }
  259.                         })
  260.  
  261. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  262.                                      menu = mymainmenu })
  263. -- }}}
  264.  
  265. -- {{{ Wibox
  266.  
  267. -- Create a textclock widget
  268. --mytextclock = awful.widget.textclock({ align = "right" })
  269.  
  270. datewidget = widget({ type = "textbox" })
  271. vicious.register(datewidget, vicious.widgets.date, "%d.%m %H:%M")
  272.  
  273. -- Create a systray
  274. mysystray = widget({ type = "systray" })
  275.  
  276. -- seperator
  277. seperator = widget({ type = "textbox" })
  278. seperator.text = " | "
  279.  
  280. -- {{{ Battery state
  281. baticon = widget({ type = "imagebox" })
  282. baticon.image = image(beautiful.widget_bat)
  283. batwidget = widget({ type = "textbox" })
  284. vicious.register(batwidget, vicious.widgets.bat, "$3", 61, "BAT0")
  285. -- }}
  286.  
  287. -- Weather widget
  288. weathericon = widget({ type = "imagebox" })
  289. weathericon.image = image(beautiful.widget_temp)
  290. weatherwidget = widget({ type = "textbox" })
  291. weather_t = awful.tooltip({ objects = { weatherwidget },})
  292.  
  293. vicious.register(weatherwidget, vicious.widgets.weather,
  294.                 function (widget, args)
  295.                     weather_t:set_text("City: " .. args["{city}"] .."\nWind: " .. args["{windkmh}"] .. "km/h " .. args["{wind}"] .. "\nSky: " .. args["{sky}"] .. "\nHumidity: " .. args["{humid}"] .. "%")
  296.                     return args["{tempc}"] .. "°C"
  297.                 end, 1800, "LKKB")
  298.                 --'1800': check every 30 minutes.
  299.                 --'LKKB': the Prague ICAO code.
  300.  
  301.  
  302. --{{{ Create a volume widget
  303.  volumewicon = widget({ type = "imagebox"})
  304.  volumewicon.image = image(beautiful.widget_mus)
  305.  volumewidget = widget({ type = "textbox"})
  306.   vicious.register(volumewidget, vicious.widgets.volume,
  307.   function(widget, args) return "" .. args[1] .. "%" end, 2, "Master")
  308. --}}}
  309.  
  310. ---{{{
  311. mailicon = widget ({ type = "textbox" })
  312. mailicon.bg_image = image(beautiful.widget_mail)
  313. mailicon.bg_align = "middle"
  314. mailicon.width = 8
  315. mailicon:buttons({ button({}, 1, function () awful.util.spawn("claws-mail") end)})
  316. mailinfo = widget ({ type = "textbox" })
  317. vicious.register(mailinfo, vicious.widgets.gmail,
  318.   function (widget, args)
  319.     if args["{count}"] == 0 then
  320.       mailicon.bg_image = image(beautiful.widget_mail)
  321.       return 0
  322.     else
  323.       mailicon.bg_image = image(beautiful.widget_mail)
  324.       return args["{count}"]
  325.     end
  326.   end, 61)
  327. ---}}}
  328.  
  329.  
  330. -- Create a wibox for each screen and add it
  331. mywibox = {}
  332. mypromptbox = {}
  333. mylayoutbox = {}
  334. mytaglist = {}
  335. mytaglist.buttons = awful.util.table.join(
  336.                     awful.button({ }, 1, awful.tag.viewonly),
  337.                     awful.button({ modkey }, 1, awful.client.movetotag),
  338.                     awful.button({ }, 3, awful.tag.viewtoggle),
  339.                     awful.button({ modkey }, 3, awful.client.toggletag),
  340.                     awful.button({ }, 4, awful.tag.viewnext),
  341.                     awful.button({ }, 5, awful.tag.viewprev)
  342.                     )
  343. mytasklist = {}
  344. mytasklist.buttons = awful.util.table.join(
  345.                      awful.button({ }, 1, function (c)
  346.                                               if c == client.focus then
  347.                                                   c.minimized = true
  348.                                               else
  349.                                                   if not c:isvisible() then
  350.                                                       awful.tag.viewonly(c:tags()[1])
  351.                                                   end
  352.                                                   -- This will also un-minimize
  353.                                                   -- the client, if needed
  354.                                                   client.focus = c
  355.                                                   c:raise()
  356.                                               end
  357.                                           end),
  358.                      awful.button({ }, 3, function ()
  359.                                               if instance then
  360.                                                   instance:hide()
  361.                                                   instance = nil
  362.                                               else
  363.                                                   instance = awful.menu.clients({ width=250 })
  364.                                               end
  365.                                           end),
  366.                      awful.button({ }, 4, function ()
  367.                                               awful.client.focus.byidx(1)
  368.                                               if client.focus then client.focus:raise() end
  369.                                           end),
  370.                      awful.button({ }, 5, function ()
  371.                                               awful.client.focus.byidx(-1)
  372.                                               if client.focus then client.focus:raise() end
  373.                                           end))
  374.  
  375. for s = 1, screen.count() do
  376.     -- Create a promptbox for each screen
  377.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  378.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  379.     -- We need one layoutbox per screen.
  380.     mylayoutbox[s] = awful.widget.layoutbox(s)
  381.     mylayoutbox[s]:buttons(awful.util.table.join(
  382.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  383.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  384.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  385.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  386.     -- Create a taglist widget
  387.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  388.  
  389.     -- Create a tasklist widget
  390.     mytasklist[s] = awful.widget.tasklist(function(c)
  391.                                               return awful.widget.tasklist.label.currenttags(c, s)
  392.                                           end, mytasklist.buttons)
  393.  
  394.     -- Create the wibox
  395.     mywibox[s] = awful.wibox({ position = "bottom", screen = s , height = "16" })
  396.     -- Add widgets to the wibox - order matters
  397.     mywibox[s].widgets = {
  398.         {
  399.             mylauncher,
  400.             mytaglist[s],
  401.             mypromptbox[s],
  402.             mylayoutbox[s],
  403.             layout = awful.widget.layout.horizontal.leftright
  404.         },
  405.         s == 1 and mysystray or nil,
  406.         datewidget, seperator,
  407.         volumewidget, volumewicon, seperator,
  408.         batwidget, baticon, seperator,
  409.         -- mailinfo, mailicon,seperator,
  410.         weatherwidget, seperator,
  411.         mytasklist[s],
  412.         layout = awful.widget.layout.horizontal.rightleft
  413.     }
  414. end
  415. -- }}}
  416.  
  417. -- {{{ Mouse bindings
  418. root.buttons(awful.util.table.join(
  419.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  420.     awful.button({ }, 4, awful.tag.viewnext),
  421.     awful.button({ }, 5, awful.tag.viewprev
  422. )))
  423. -- }}}
  424.  
  425. ---{{{
  426. ---}}}
  427.  
  428. -- {{{ Key bindings
  429. globalkeys = awful.util.table.join(
  430.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  431.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  432.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  433.  
  434.     awful.key({ modkey,           }, "j",
  435.         function ()
  436.             awful.client.focus.byidx( 1)
  437.             if client.focus then client.focus:raise() end
  438.         end),
  439.     awful.key({ modkey,           }, "k",
  440.         function ()
  441.             awful.client.focus.byidx(-1)
  442.             if client.focus then client.focus:raise() end
  443.         end),
  444.         -- all minimized clients are restored
  445.     awful.key({ modkey, "Shift"   }, "n",
  446.         function()
  447.             local tag = awful.tag.selected()
  448.                 for i=1, #tag:clients() do
  449.                     tag:clients()[i].minimized=false
  450.                     tag:clients()[i]:redraw()
  451.             end
  452.         end),
  453.     --alt-tab v1
  454.     --  awful.key({ "Mod1" }, "Tab", function ()
  455.     --     awful.menu.menu_keys.down = { "Down", "Tab" }
  456.     --     local cmenu = awful.menu.clients({width=245}, {keygrabber=true, coords={x=525, y=330} })
  457.     -- end),
  458.     --      -- alt + tab
  459.     -- awful.key({ "Mod1", }, "Tab",
  460.     --     function ()
  461.     --         awful.client.focus.history.previous()
  462.     --         if client.focus then
  463.     --             client.focus:raise()
  464.     --         end
  465.     --     end),
  466.     --run or raise test
  467.         awful.key({ modkey, }, "1", function () run_or_raise("google-chrome", { instance = "google-chrome" }) end),
  468.         awful.key({ modkey, }, "2", function () run_or_raise("sublime-text", { instance = "sublime-text" }) end),
  469.         awful.key({ modkey, }, "3", function () run_or_raise("skype", {instance="skype",role="ConversationsWindow" }) end),
  470.         awful.key({ modkey, }, "4", function () run_or_raise("nautilus --no-desktop", { instance = "nautilus" }) end),
  471.         awful.key({ modkey, }, "4", function () run_or_raise("nautilus --no-desktop", { instance = "nautilus" }) end),
  472.  
  473.  
  474.     --fn-keys
  475.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  476.     -- awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn_with_shell("amixer -D pulse set Master 4%+ unmute") end),
  477.     -- awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn_with_shell("amixer -D pulse set Master 4%- unmute") end),
  478.     -- awful.key({ }, "XF86AudioMute", function () awful.util.spawn_with_shell("amixer -D pulse set Master 1+ toggle") end),
  479.     -- awful.key({ }, "XF86KbdBrightnessDown", function () awful.util.spawn_with_shell("dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:0") end),
  480.     -- awful.key({ }, "XF86KbdBrightnessUp", function () awful.util.spawn_with_shell("dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:3") end),
  481.     -- awful.key({ }, "XF86TouchpadToggle", function () awful.util.spawn_with_shell("/home/murat/.config/ttoggle") end),
  482.     -- awful.key({ }, "Print", function () awful.util.spawn_with_shell("scrot 'f%Y-%m-%d-%s_$wx$h.png' -e 'mv -f /home/murat/Pictures/'") end),
  483.     -- awful.key({}, "XF86MonBrightnessUp", function() awful.util.spawn_with_shell("pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $(($(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness)+4)) ; echo \"up\" ") end),
  484.     -- awful.key({}, "XF86MonBrightnessDown", function() awful.util.spawn_with_shell("pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $(($(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness)-4)) ; echo \"down\"") end),
  485.  
  486.     --{{{
  487.     -- awful.key({ }, "F11", function () scratch.pad.toggle() end),
  488.     -- awful.key({ }, "F12", function () scratch.drop("skype", "top", "left", 30, 750, 0.30) end),
  489.     --}}}
  490.  
  491.     awful.key({modkey, "Shift"}, "l", function () awful.util.spawn("i3lock -c \"#555555\"")end),
  492.  
  493.     -- Layout manipulation
  494.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  495.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  496.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  497.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  498.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  499.     awful.key({ modkey,           }, "Tab",
  500.         function ()
  501.             awful.client.focus.history.previous()
  502.             if client.focus then
  503.                 client.focus:raise()
  504.             end
  505.         end),
  506.  
  507.     -- Standard program
  508.     -- awful.key({ modkey,}, "s",      function () run_or_raise("skype", { name = "Skype" }) end),
  509.     -- awful.key({ modkey, }, "g", function () run_or_raise("google-chrome", { name = "Google Chrome" }) end),
  510.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  511.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  512.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  513.  
  514.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  515.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  516.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  517.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  518.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  519.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  520.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  521.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  522.  
  523.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  524.  
  525.     -- Prompt
  526.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  527.  
  528.     awful.key({ modkey }, "x",
  529.               function ()
  530.                   awful.prompt.run({ prompt = "Run Lua code: " },
  531.                   mypromptbox[mouse.screen].widget,
  532.                   awful.util.eval, nil,
  533.                   awful.util.getdir("cache") .. "/history_eval")
  534.               end)
  535. )
  536.  
  537. clientkeys = awful.util.table.join(
  538.     --{{{
  539.     -- awful.key({ }, "F10", function (c) scratch.pad.set(c, 0.60, 0.60, true) end),
  540.     --}}}
  541.  
  542.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  543.     awful.key({ modkey, }, "q",      function (c) c:kill()                         end),
  544.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  545.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  546.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  547.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  548.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  549.     awful.key({ modkey,           }, "n",
  550.         function (c)
  551.             -- The client currently has the input focus, so it cannot be
  552.             -- minimized, since minimized clients can't have the focus.
  553.             c.minimized = true
  554.         end),
  555.     awful.key({ modkey,           }, "m",
  556.         function (c)
  557.             c.maximized_horizontal = not c.maximized_horizontal
  558.             c.maximized_vertical   = not c.maximized_vertical
  559.         end)
  560. )
  561.  
  562. -- Compute the maximum number of digit we need, limited to 9
  563. keynumber = 0
  564. for s = 1, screen.count() do
  565.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  566. end
  567.  
  568. -- Bind all key numbers to tags.
  569. -- Be careful: we use keycodes to make it works on any keyboard layout.
  570. -- This should map on the top row of your keyboard, usually 1 to 9.
  571. for i = 1, keynumber do
  572.     globalkeys = awful.util.table.join(globalkeys,
  573.         awful.key({ modkey }, "#" .. i + 9,
  574.                   function ()
  575.                         local screen = mouse.screen
  576.                         if tags[screen][i] then
  577.                             awful.tag.viewonly(tags[screen][i])
  578.                         end
  579.                   end),
  580.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  581.                   function ()
  582.                       local screen = mouse.screen
  583.                       if tags[screen][i] then
  584.                           awful.tag.viewtoggle(tags[screen][i])
  585.                       end
  586.                   end),
  587.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  588.                   function ()
  589.                       if client.focus and tags[client.focus.screen][i] then
  590.                           awful.client.movetotag(tags[client.focus.screen][i])
  591.                       end
  592.                   end),
  593.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  594.                   function ()
  595.                       if client.focus and tags[client.focus.screen][i] then
  596.                           awful.client.toggletag(tags[client.focus.screen][i])
  597.                       end
  598.                   end))
  599. end
  600.  
  601. clientbuttons = awful.util.table.join(
  602.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  603.     awful.button({ modkey }, 1, awful.mouse.client.move),
  604.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  605.  
  606. -- Set keys
  607. root.keys(globalkeys)
  608. -- }}}
  609.  
  610. -- {{{ Rules
  611. awful.rules.rules = {
  612.     -- All clients will match this rule.
  613.     { rule = { },
  614.       properties = { border_width = beautiful.border_width,
  615.                      border_color = beautiful.border_normal,
  616.                      focus = true,
  617.                      keys = clientkeys,
  618.                      buttons = clientbuttons } },
  619.     { rule = { class = "MPlayer" },
  620.       properties = { floating = true } },
  621.     { rule = { class = "pinentry" },
  622.       properties = { floating = true } },
  623.     { rule = { class = "gimp" },
  624.       properties = { floating = true } },
  625.     -- Set Firefox to always map on tags number 2 of screen 1.
  626.     { rule = { class = "Google-chrome" },
  627.       properties = { tag = tags[1][1] } },
  628.     { rule = { class = "Skype" },
  629.       properties = { tag = tags[1][3] } },
  630.     { rule = { class = "sublime-text-2" },
  631.       properties = { tag = tags[1][2] } },
  632.     { rule = { class = "Vlc" },
  633.       properties = { tag = tags[1][5] } },
  634.     -- { rule = { class = "Google-chrome" },
  635.       -- properties = { tag = tags[1][1] } },
  636. }
  637. -- }}}
  638.  
  639. -- {{{ Signals
  640. -- Signal function to execute when a new client appears.
  641. client.add_signal("manage", function (c, startup)
  642.     -- Add a titlebar
  643.     -- awful.titlebar.add(c, { modkey = modkey })
  644.  
  645.     -- Enable sloppy focus
  646.     -- c:add_signal("mouse::enter", function(c)
  647.     --     if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  648.     --         and awful.client.focus.filter(c) then
  649.     --         client.focus = c
  650.     --     end
  651.     -- end)
  652.  
  653.     if not startup then
  654.         -- Set the windows at the slave,
  655.         -- i.e. put it at the end of others instead of setting it master.
  656.         -- awful.client.setslave(c)
  657.  
  658.         -- Put windows in a smart way, only if they does not set an initial position.
  659.         if not c.size_hints.user_position and not c.size_hints.program_position then
  660.             awful.placement.no_overlap(c)
  661.             awful.placement.no_offscreen(c)
  662.         end
  663.     end
  664. end)
  665.  
  666. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  667. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  668. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment