awesome/rc.lua
changeset 7 03125e413ae3
child 8 0eae48be1d62
equal deleted inserted replaced
6:8daa0d8b9a0e 7:03125e413ae3
       
     1 require("debug")
       
     2 --
       
     3 -- Standard awesome library
       
     4 require("awful")
       
     5 require("awful.autofocus")
       
     6 -- Theme handling library
       
     7 require("beautiful")
       
     8 -- Notification library
       
     9 require("naughty")
       
    10 -- shifty - dynamic tagging library
       
    11 require("shifty")
       
    12 -- Revelation
       
    13 require("revelation")
       
    14 -- vicious widgets
       
    15 local vicious = require("vicious")
       
    16 local wicked = require("wicked")
       
    17 -- Load Debian menu entries
       
    18 require("debian.menu")
       
    19 
       
    20 -- require("keychains")
       
    21 
       
    22 require("my")
       
    23 
       
    24 -- {{{ Error handling
       
    25 -- Check if awesome encountered an error during startup and fell back to
       
    26 -- another config (This code will only ever execute for the fallback config)
       
    27 if awesome.startup_errors then
       
    28    naughty.notify({ preset = naughty.config.presets.critical,
       
    29                     title = "Oops, there were errors during startup!",
       
    30                     text = awesome.startup_errors })
       
    31 end
       
    32 
       
    33 -- Handle runtime errors after startup
       
    34 do
       
    35    awesome.add_signal("debug::error", my.notify_error)
       
    36 end
       
    37 -- }}}
       
    38 
       
    39 -- Variable definitions
       
    40 -- Themes define colours, icons, and wallpapers
       
    41 -- The default is a dark theme
       
    42 -- theme_path = "/usr/share/awesome/themes/default/theme.lua"
       
    43 -- Uncommment this for a lighter theme
       
    44 theme_path = "/usr/share/awesome/themes/sky/theme.lua"
       
    45 
       
    46 -- This is used later as the default terminal and editor to run.
       
    47 terminal = "x-terminal-emulator"
       
    48 editor = os.getenv("EDITOR") or "editor"
       
    49 editor_cmd = terminal .. " -e " .. editor
       
    50 browser = "iceweasel"
       
    51 mail = "icedove"
       
    52 musicplayer = "ario"
       
    53 monitor = "gnome-system-monitor"
       
    54 filemanager = "pcmanfm"
       
    55 lookup = "pcmanfm -f"
       
    56 calculator = "galculator"
       
    57 
       
    58 -- Default modkey.
       
    59 -- Usually, Mod4 is the key with a logo between Control and Alt.
       
    60 -- If you do not like this or do not have such a key, I suggest you to remap
       
    61 -- Mod4 to another key using xmodmap or other tools.  However, you can use
       
    62 -- another modifier like Mod1, but it may interact with others.
       
    63 modkey = "Mod4"
       
    64 
       
    65 wallpaper_dir = "/home/fabien/themes/backgrounds/"
       
    66 wallpaper = wallpaper_dir .. "universalis_1024_jsh.jpg"
       
    67 
       
    68 -- Actually load theme
       
    69 beautiful.init(theme_path)
       
    70 beautiful.get().wallpaper_cmd = { "awsetbg -a " .. wallpaper }
       
    71 awful.util.spawn_with_shell("pgrep unagi || unagi &")
       
    72 
       
    73 
       
    74 -- Table of layouts to cover with awful.layout.inc, order matters.
       
    75 layouts =
       
    76    {
       
    77       awful.layout.suit.tile,
       
    78       awful.layout.suit.tile.left,
       
    79       awful.layout.suit.tile.bottom,
       
    80       awful.layout.suit.tile.top,
       
    81       awful.layout.suit.fair,
       
    82       awful.layout.suit.fair.horizontal,
       
    83       awful.layout.suit.max,
       
    84       awful.layout.suit.max.fullscreen,
       
    85       awful.layout.suit.magnifier,
       
    86       awful.layout.suit.floating
       
    87    }
       
    88 
       
    89 -- Define if we want to use titlebar on all applications.
       
    90 use_titlebar = true
       
    91 
       
    92 -- Shifty configured tags.
       
    93 shifty.config.tags = {
       
    94    w1 = {
       
    95       layout    = awful.layout.suit.tile,
       
    96       mwfact    = 0.60,
       
    97       exclusive = false,
       
    98       position  = 1,
       
    99       init      = true,
       
   100       screen    = 1,
       
   101       slave     = true,
       
   102    },
       
   103    web = {
       
   104       layout      = awful.layout.suit.tile.bottom,
       
   105       mwfact      = 0.65,
       
   106       exclusive   = true,
       
   107       max_clients = 1,
       
   108       position    = 4,
       
   109       spawn       = browser,
       
   110    },
       
   111    mail = {
       
   112       layout    = awful.layout.suit.tile,
       
   113       mwfact    = 0.55,
       
   114       exclusive = false,
       
   115       position  = 5,
       
   116       spawn     = mail,
       
   117       slave     = true
       
   118    },
       
   119    media = {
       
   120       layout    = awful.layout.suit.float,
       
   121       exclusive = false,
       
   122       position  = 8,
       
   123       spawn     = musicplayer
       
   124    },
       
   125    office = {
       
   126       layout   = awful.layout.suit.tile,
       
   127       position = 9,
       
   128    },
       
   129    steam = {
       
   130       layout      = awful.layout.suit.max,
       
   131       mwfact      = 0.65,
       
   132       exclusive   = true,
       
   133       spawn       = "steam",
       
   134       position    = 6,
       
   135    },
       
   136 }
       
   137 
       
   138 -- SHIFTY: application matching rules
       
   139 -- order here matters, early rules will be applied first
       
   140 shifty.config.apps = {
       
   141    {
       
   142       match = {
       
   143          "Navigator",
       
   144          "Vimperator",
       
   145          "Gran Paradiso",
       
   146       },
       
   147       float = false,
       
   148       tag = "web",
       
   149    },
       
   150    {
       
   151       match = {
       
   152          "Shredder.*",
       
   153          "Thunderbird",
       
   154          "Icedove",
       
   155          "mutt",
       
   156       },
       
   157       tag = "mail",
       
   158    },
       
   159    {
       
   160       match = {
       
   161          "pcmanfm",
       
   162       },
       
   163       slave = true
       
   164    },
       
   165    {
       
   166       match = {
       
   167          "OpenOffice.*",
       
   168          "Abiword",
       
   169          "Gnumeric",
       
   170       },
       
   171       tag = "office",
       
   172    },
       
   173    {
       
   174       match = {
       
   175          "Mplayer.*",
       
   176          "Mirage",
       
   177          "gimp",
       
   178          "gtkpod",
       
   179          "Ufraw",
       
   180          "easytag",
       
   181          "Ario",
       
   182       },
       
   183       tag = "media",
       
   184       nopopup = true,
       
   185    },
       
   186    {
       
   187       match = {
       
   188          "MPlayer",
       
   189          "Gnuplot",
       
   190          "galculator",
       
   191          "speedcrunch"
       
   192       },
       
   193       float = true,
       
   194    },
       
   195    {
       
   196       match = { "emacs" },
       
   197       tag = "emacs"
       
   198    },
       
   199    {
       
   200       match = {
       
   201          terminal,
       
   202       },
       
   203       honorsizehints = false,
       
   204       slave = true,
       
   205    },
       
   206    {
       
   207       match = { "Steam" },
       
   208       tag = "steam",
       
   209    },
       
   210    {
       
   211       match = {""},
       
   212       buttons = awful.util.table.join(
       
   213          awful.button({}, 1, function (c) client.focus = c; c:raise() end),
       
   214          awful.button({modkey}, 1, function(c)
       
   215                client.focus = c
       
   216                c:raise()
       
   217                awful.mouse.client.move(c)
       
   218          end),
       
   219          awful.button({modkey}, 3, awful.mouse.client.resize)
       
   220       )
       
   221    },
       
   222 }
       
   223 
       
   224 -- SHIFTY: default tag creation rules
       
   225 -- parameter description
       
   226 --  * floatBars : if floating clients should always have a titlebar
       
   227 --  * guess_name : should shifty try and guess tag names when creating
       
   228 --                 new (unconfigured) tags?
       
   229 --  * guess_position: as above, but for position parameter
       
   230 --  * run : function to exec when shifty creates a new tag
       
   231 --  * all other parameters (e.g. layout, mwfact) follow awesome's tag API
       
   232 shifty.config.defaults = {
       
   233    layout = awful.layout.suit.tile.bottom,
       
   234    ncol = 1,
       
   235    mwfact = 0.60,
       
   236    floatBars = true,
       
   237    guess_name = true,
       
   238    guess_position = true,
       
   239 }
       
   240 
       
   241 --  Wibox
       
   242 -- Create a textbox widget
       
   243 mytextclock = awful.widget.textclock({align = "right"})
       
   244 
       
   245 -- Create a laucher widget and a main menu
       
   246 myawesomemenu = {
       
   247    {"manual", terminal .. " -e man awesome"},
       
   248    {"edit config",
       
   249     editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua"},
       
   250    {"restart", awesome.restart},
       
   251    {"quit", my.quit}
       
   252 }
       
   253 
       
   254 mymainmenu = awful.menu(
       
   255    {
       
   256       items = {
       
   257          {"awesome", myawesomemenu, beautiful.awesome_icon},
       
   258          { "Debian", debian.menu.Debian_menu.Debian },
       
   259          {"open terminal", terminal}}
       
   260 })
       
   261 
       
   262 mylauncher = awful.widget.launcher({image = image(beautiful.awesome_icon),
       
   263                                     menu = mymainmenu})
       
   264 
       
   265 -- Create a systray
       
   266 mysystray = widget({type = "systray", align = "right"})
       
   267 
       
   268 -- Create a wibox for each screen and add it
       
   269 mywibox = {}
       
   270 mypromptbox = {}
       
   271 mylayoutbox = {}
       
   272 mytaglist = {}
       
   273 mytaglist.buttons = awful.util.table.join(
       
   274    awful.button({}, 1, awful.tag.viewonly),
       
   275    awful.button({modkey}, 1, awful.client.movetotag),
       
   276    awful.button({}, 3, function(tag) tag.selected = not tag.selected end),
       
   277    awful.button({modkey}, 3, awful.client.toggletag),
       
   278    awful.button({}, 4, awful.tag.viewnext),
       
   279    awful.button({}, 5, awful.tag.viewprev)
       
   280 )
       
   281 
       
   282 mytasklist = {}
       
   283 mytasklist.buttons = awful.util.table.join(
       
   284    awful.button({}, 1, function(c)
       
   285          if not c:isvisible() then
       
   286             awful.tag.viewonly(c:tags()[1])
       
   287          end
       
   288          client.focus = c
       
   289          c:raise()
       
   290    end),
       
   291    awful.button({modkey}, 3, my.show_clients),
       
   292    awful.button({}, 3, function(c)
       
   293          c.minimized = not c.minimized
       
   294    end),
       
   295    awful.button({}, 4, function()
       
   296          awful.client.focus.byidx(1)
       
   297          if client.focus then client.focus:raise() end
       
   298    end),
       
   299    awful.button({}, 5, function()
       
   300          awful.client.focus.byidx(-1)
       
   301          if client.focus then client.focus:raise() end
       
   302 end))
       
   303 
       
   304 local mycpuwidget = my.widgets.decorated(my.widgets.cpu(), my.mkspawn(monitor))
       
   305 local mymemwidget = my.widgets.decorated(my.widgets.mem(), my.mkspawn(monitor))
       
   306 local mynetwidget = my.widgets.decorated(my.widgets.net("eth1"), my.mkspawn(monitor))
       
   307 -- local mynetupwidget = my.decorated_monitor_widget(make_netwidget("eth1", "up"))
       
   308 -- local mynetdownwidget = my.decorated_monitor_widget(make_netwidget("eth1", "down"))
       
   309 local myktwidget = my.widgets.mode()
       
   310 
       
   311 for s = 1, screen.count() do
       
   312    awful.util.spawn("awsetbg -a " .. wallpaper, false, s)
       
   313 
       
   314    -- status box
       
   315 
       
   316    -- Create a promptbox for each screen
       
   317    mypromptbox[s] =
       
   318       awful.widget.prompt({layout = awful.widget.layout.leftright})
       
   319    -- Create an imagebox widget which will contains an icon indicating which
       
   320    -- layout we're using.  We need one layoutbox per screen.
       
   321    mylayoutbox[s] = awful.widget.layoutbox(s)
       
   322    mylayoutbox[s]:buttons(awful.util.table.join(
       
   323                              awful.button({}, 1, function() awful.layout.inc(layouts, 1) end),
       
   324                              awful.button({}, 3, function() awful.layout.inc(layouts, -1) end),
       
   325                              awful.button({}, 4, function() awful.layout.inc(layouts, 1) end),
       
   326                              awful.button({}, 5, function() awful.layout.inc(layouts, -1) end)))
       
   327    -- Create a taglist widget
       
   328    mytaglist[s] = awful.widget.taglist.new(s,
       
   329                                            awful.widget.taglist.label.all,
       
   330                                            mytaglist.buttons)
       
   331 
       
   332    -- Create a tasklist widget
       
   333    mytasklist[s] = awful.widget.tasklist.new(
       
   334       function(c)
       
   335         return awful.widget.tasklist.label.currenttags(c, s)
       
   336       end,
       
   337       mytasklist.buttons)
       
   338 
       
   339 
       
   340    -- Create the wibox
       
   341    mywibox[s] = awful.wibox({position = "top", screen = s})
       
   342    -- Add widgets to the wibox - order matters
       
   343    mywibox[s].widgets = {
       
   344       {
       
   345          myktwidget,
       
   346          mylauncher,
       
   347          s == 1 and mycpuwidget or nil,
       
   348          s == 1 and mymemwidget or nil,
       
   349          mytaglist[s],
       
   350          mypromptbox[s],
       
   351          layout = awful.widget.layout.horizontal.leftright
       
   352       },
       
   353       mylayoutbox[s],
       
   354       s == 1 and mynetwidget or nil,
       
   355       mytextclock,
       
   356       s == 1 and mysystray or nil,
       
   357       mytasklist[s],
       
   358       layout = awful.widget.layout.horizontal.rightleft
       
   359    }
       
   360 
       
   361    mywibox[s].screen = s
       
   362 end
       
   363 
       
   364 -- SHIFTY: initialize shifty
       
   365 -- the assignment of shifty.taglist must always be after its actually
       
   366 -- initialized with awful.widget.taglist.new()
       
   367 shifty.taglist = mytaglist
       
   368 shifty.init()
       
   369 
       
   370 -- Mouse bindings
       
   371 root.buttons(awful.util.table.join(
       
   372                 awful.button({}, 3, function() mymainmenu:toggle() end),
       
   373                 awful.button({}, 4, awful.tag.viewnext),
       
   374                 awful.button({}, 5, awful.tag.viewprev)
       
   375 ))
       
   376 
       
   377 -- key tables
       
   378 
       
   379 local tagkeys = {
       
   380    -- Shifty: keybindings specific to shifty
       
   381    my.make_key("n", "Send to Next Tag", shifty.send_next), -- client to next tag
       
   382    my.make_key("a", "Add tag", my.mkinteractive(shifty.add)), -- create a new tag
       
   383    my.make_key("r", "Rename tag", my.mkinteractive(shifty.rename)), -- rename a tag
       
   384    my.make_key("d", "Delete tag", shifty.del),
       
   385    my.make_key("Shift+A", "Add tag (no popup)", -- nopopup new tag
       
   386             my.mkinteractive(function() shifty.add({nopopup = true}) end)),
       
   387    my.make_key("Up", "View prev",
       
   388             function () awful.tag.viewprev(); return true; end),
       
   389    my.make_key("Down", "View next", 
       
   390             function () awful.tag.viewnext(); return true; end),
       
   391    my.make_key("Shift+Up", "Move tag left", 
       
   392             function()
       
   393                local t = awful.tag.selected()
       
   394                local s = awful.util.cycle(screen.count(), t.screen + 1)
       
   395                awful.tag.history.restore()
       
   396                t = shifty.tagtoscr(s, t)
       
   397                awful.tag.viewonly(t)
       
   398                return true
       
   399    end),
       
   400    my.make_key("Shift+Right", "Move tag left", 
       
   401             function()
       
   402                local t = awful.tag.selected()
       
   403                local s = awful.util.cycle(screen.count(), t.screen + 1)
       
   404                awful.tag.history.restore()
       
   405                t = shifty.tagtoscr(s, t)
       
   406                awful.tag.viewonly(t)
       
   407                return true
       
   408    end),
       
   409 }
       
   410 
       
   411 local awesome_keys = {
       
   412    my.make_key("m", "Menu", my.mkinteractive(function () 
       
   413                mymainmenu:show({keygrabber=true}) 
       
   414                return true
       
   415    end)),
       
   416    -- my.make_key("k", "Kill all clients", 
       
   417    --             function () 
       
   418    --                for client.
       
   419    --                my.kill_all(function (c)
       
   420    my.make_key("r", "Restart", awesome.restart),
       
   421    my.make_key("q", "Quit", awesome.quit),
       
   422    my.make_key("t", "Terminal", my.mkspawn(terminal)),
       
   423 }
       
   424 
       
   425 local layout_keys = {
       
   426    my.make_key("Right", "Focus right",
       
   427             function () awful.client.focus.bydirection("right"); return true end),
       
   428    my.make_key("Left", "Focus left",
       
   429             function () awful.client.focus.bydirection("left"); return true end),
       
   430    my.make_key("Up", "Focus up",
       
   431             function () awful.client.focus.bydirection("up"); return true end),
       
   432    my.make_key("Down", "Focus down",
       
   433             function () awful.client.focus.bydirection("down"); return true end),
       
   434    my.make_key("Shift+Right", "Move right",
       
   435             function () awful.client.swap.bydirection("right"); return true end),
       
   436    my.make_key("Shift+Left", "Move left",
       
   437             function () awful.client.swap.bydirection("left"); return true end),
       
   438    my.make_key("Shift+Up", "Move up",
       
   439             function () awful.client.swap.bydirection("up"); return true end),
       
   440    my.make_key("Shift+Down", "Move down",
       
   441             function () awful.client.swap.bydirection("down"); return true end),
       
   442    -- my.make_key("Right", "Focus next",
       
   443    --          function () awful.client.focus.byidx(1); return true end),
       
   444    -- my.make_key("Left", "Focus prev",
       
   445    --          function () awful.client.focus.byidx(-1); return true end),
       
   446    -- my.make_key("Shift+Right", "Move next", 
       
   447    --          function() awful.client.swap.byidx(1); return true end),
       
   448    -- my.make_key("Shift+Left", "Move previous", 
       
   449    --          function() awful.client.swap.byidx(-1); return true end),
       
   450    -- my.make_key("Shift+Right", "Move next", 
       
   451    --          function() awful.screen.focus(1); return true end),
       
   452    -- my.make_key("Shift+Left", "Move previous", 
       
   453    --          function() awful.screen.focus(-1); return true end),
       
   454    my.make_key("c", "Master grow",
       
   455             function() awful.tag.incmwfact(0.05); return true end),
       
   456    my.make_key("z", "Master shrink",
       
   457             function() awful.tag.incmwfact(-0.05); return true end),
       
   458    my.make_key("Shift+c", "Add master windows", 
       
   459             function() awful.tag.incnmaster(1); return true end),
       
   460    my.make_key("Shift+z", "Remove master windows",
       
   461             function() awful.tag.incnmaster(-1); return true end),
       
   462    my.make_key("Control+c", "Add column",
       
   463             function() awful.tag.incncol(1); return true end),
       
   464    my.make_key("Control+z", "Remove column", 
       
   465             function() awful.tag.incncol(-1); return true end),
       
   466    my.make_key("Space", "Next layout", 
       
   467             function() awful.layout.inc(layouts, 1); return true end),
       
   468    my.make_key("Shift+_", "Previous layout", 
       
   469             function() awful.layout.inc(layouts, -1) ; return true end),
       
   470 }
       
   471 
       
   472 media_keys = {
       
   473    -- media keys
       
   474    my.make_key("XF86HomePage", "Browser", my.mkspawn(browser)),
       
   475    my.make_key("XF86Mail", "Mail", my.mkspawn(mail)),
       
   476    my.make_key("XF86Search", "Search file...", my.mkspawn(lookup)),
       
   477    my.make_key("XF86Explorer", "File Manager", my.mkspawn(filemanager)),
       
   478    my.make_key("XF86Calculator", "Calculator", my.mkspawn(calculator)),
       
   479    my.make_key("XF86Tools", "Music", my.mkspawn(musicplayer)),
       
   480    my.make_key("XF86AudioPrev", "Previous song", my.mkspawn("mpc prev")),
       
   481    my.make_key("XF86AudioNext", "Next song", my.mkspawn("mpc next")),
       
   482    my.make_key("XF86AudioPlay", "Play song", my.mkspawn("mpc toggle")),
       
   483    my.make_key("XF86AudioMute", "Mute", my.mkspawn("pulseaudio-ctl mute")),
       
   484    my.make_key("XF86AudioLowerVolume", "Volume down", my.mkspawn("pulseaudio-ctl down")),
       
   485    my.make_key("XF86AudioRaiseVolume", "Volume up", my.mkspawn("pulseaudio-ctl up")),
       
   486    my.make_key("XF86Eject", "Eject", my.mkspawn("eject")),
       
   487 }
       
   488 
       
   489 global_table = {
       
   490    my.make_key("Escape", "Restore History", awful.tag.history.restore),
       
   491    my.make_key("e", "Revel windows", revelation),
       
   492    my.make_key("c", "Previous tag", awful.tag.viewprev),
       
   493    my.make_key("z", "Next tag", awful.tag.viewnext),
       
   494    my.make_key("Right", "Right client", my.make_focus_bydirection("right")),
       
   495    my.make_key("Left", "Left client", my.make_focus_bydirection("left")),
       
   496    my.make_key("Up", "Up client", my.make_focus_bydirection("up")),
       
   497    my.make_key("Down", "Down client", my.make_focus_bydirection("down")),
       
   498    my.make_key("u", "Jump to urgent", awful.client.urgent.jumpto),
       
   499    my.make_key("Tab", "Previous client", 
       
   500             function()
       
   501                awful.client.focus.history.previous()
       
   502                if client.focus then
       
   503                   client.focus:raise()
       
   504                end
       
   505    end),
       
   506 
       
   507    -- Prompt
       
   508    my.make_key("F2", "Run...", function()
       
   509                awful.prompt.run({prompt = "Run: "},
       
   510                   mypromptbox[mouse.screen].widget,
       
   511                   awful.util.spawn, awful.completion.shell,
       
   512                   awful.util.getdir("cache") .. "/history")
       
   513    end),
       
   514 
       
   515    my.make_key("F3", "Eval...", function()
       
   516                awful.prompt.run({prompt = "Run Lua code: "},
       
   517                   mypromptbox[mouse.screen].widget,
       
   518                   awful.util.eval, nil,
       
   519                   awful.util.getdir("cache") .. "/history_eval")
       
   520    end),
       
   521 
       
   522    -- modal key binding
       
   523    my.make_key("a", "Main mode", my.make_kt(awesome_keys, "awesome") ),
       
   524    my.make_key("t", "Tag mode...", my.make_kt(tagkeys, "tag") ),
       
   525    my.make_key("l", "layout mode...", my.make_kt(layout_keys, "layout") ),
       
   526 }
       
   527 
       
   528 client_keytable = {
       
   529    my.make_key("F4", "Kill client", 
       
   530             function(c) c:kill() end),
       
   531    my.make_key("k", "Kill client", 
       
   532             function(c) c:kill() end),
       
   533    my.make_key("f", "Toggle fullscreen", 
       
   534             function(c) c.fullscreen = not c.fullscreen  end),
       
   535    my.make_key("space", "Toggle floating", 
       
   536             awful.client.floating.toggle),
       
   537    my.make_key("m", "Toggle maximize", 
       
   538       function(c)
       
   539          c.maximized_horizontal = not c.maximized_horizontal
       
   540          c.maximized_vertical   = not c.maximized_vertical
       
   541    end),
       
   542    my.make_key("h", "Toggle minimized",
       
   543                function (c)
       
   544                   c.minimized = not c.minimized
       
   545    end),
       
   546    my.make_key("Return", "Swap master", 
       
   547             function(c)
       
   548                c:swap(awful.client.getmaster())
       
   549    end),
       
   550    my.make_key("o", "Move to screen", awful.client.movetoscreen),
       
   551 }
       
   552 
       
   553 -- Key bindings
       
   554 globalkeys = awful.util.table.join(
       
   555    awful.key({modkey}, "F1", function () my.show_kt(global_table, "Global binding") end),
       
   556    my.make_globalkeys({modkey}, global_table),
       
   557    my.make_globalkeys({}, media_keys), 
       
   558    -- forcing restart of mpd.
       
   559    -- it sometime have difficulty to connect to pulse
       
   560    awful.key({modkey}, "F6", function ()
       
   561    	awful.util.spawn("pkill -9 mpd")
       
   562 	awful.util.spawn("mpd")
       
   563 	end)
       
   564    )
       
   565 
       
   566 
       
   567 -- Client awful tagging: this is useful to tag some clients and then do stuff
       
   568 -- like move to tag on them
       
   569 clientkeys = awful.util.table.join(
       
   570    awful.key({modkey, "Shift"}, "F1", 
       
   571       function () my.show_kt(client_keytable, "Client binding") end),
       
   572    my.make_globalkeys({modkey}, client_keytable),
       
   573    awful.key({modkey, "Shift"}, "r", function(c) c:redraw() end),
       
   574    awful.key({modkey, "Shift"}, "t", awful.client.togglemarked))
       
   575 
       
   576 
       
   577 -- SHIFTY: assign client keys to shifty for use in
       
   578 -- match() function(manage hook)
       
   579 shifty.config.clientkeys = clientkeys
       
   580 shifty.config.modkey = modkey
       
   581 
       
   582 -- Compute the maximum number of digit we need, limited to 10
       
   583 local number_row = { 
       
   584    '"', '<', '>', '(', ')',
       
   585    '@', '+', '-', '/', '*'
       
   586 }
       
   587 
       
   588 for i = 1, (shifty.config.maxtags or #number_row) do
       
   589    local k = number_row[i-1]
       
   590    globalkeys = awful.util.table.join(
       
   591       globalkeys,
       
   592       awful.key({modkey}, k, function()
       
   593             local t =  awful.tag.viewonly(shifty.getpos(i))
       
   594       end),
       
   595       awful.key({modkey, "Control"}, k, function()
       
   596             local t = shifty.getpos(i)
       
   597             t.selected = not t.selected
       
   598       end),
       
   599       awful.key({modkey, "Control", "Shift"}, k, function()
       
   600             if client.focus then
       
   601                awful.client.toggletag(shifty.getpos(i))
       
   602             end
       
   603       end),
       
   604       -- move clients to other tags
       
   605       awful.key({modkey, "Shift"}, k, function()
       
   606             if client.focus then
       
   607                t = shifty.getpos(i)
       
   608                awful.client.movetotag(t)
       
   609                awful.tag.viewonly(t)
       
   610             end
       
   611    end))
       
   612 end
       
   613 
       
   614 -- Set keys
       
   615 -- mympdwidget:append_global_keys()
       
   616 -- keychains.init(globalkeys,{})
       
   617 root.keys(globalkeys)
       
   618 
       
   619 -- local function kt2kc(kt)
       
   620 --    t = {}
       
   621 --    for _,k in ipairs(kt) do
       
   622 --       t[k.key] = { func = k.func, info = key.desc }
       
   623 --    end
       
   624 --    return t
       
   625 -- end
       
   626 -- keychains.add({modkey}, "w", "Awesome", nil, kt2kc(awesome_keys))
       
   627 -- keychains.start(5)
       
   628 
       
   629 -- Hook function to execute when focusing a client.
       
   630 client.add_signal("focus", 
       
   631                   function(c)
       
   632                      if not awful.client.ismarked(c) then
       
   633                         c.border_color = beautiful.border_focus
       
   634                         c.opacity = 1.0
       
   635                      end
       
   636 end)
       
   637 
       
   638 -- Hook function to execute when unfocusing a client.
       
   639 client.add_signal("unfocus", function(c)
       
   640                      if not awful.client.ismarked(c) then
       
   641                         c.border_color = beautiful.border_normal
       
   642                         c.opacity = 0.8
       
   643                      end
       
   644 end)
       
   645