awesome/rc.lua
changeset 11 7226709dc4c4
parent 8 0eae48be1d62
child 12 ffc02bf394cb
equal deleted inserted replaced
10:449bcf8e92c2 11:7226709dc4c4
     1 require("debug")
     1 local debug = require("debug")
     2 --
     2 --
     3 -- Standard awesome library
     3 -- Standard awesome library
     4 require("awful")
     4 local awful = require("awful")
     5 require("awful.autofocus")
     5 awful.autofocus = require("awful.autofocus")
       
     6 local wibox = require("wibox")
     6 -- Theme handling library
     7 -- Theme handling library
     7 require("beautiful")
     8 local beautiful = require("beautiful")
     8 -- Notification library
     9 -- Notification library
     9 require("naughty")
    10 local naughty = require("naughty")
    10 -- shifty - dynamic tagging library
    11 -- shifty - dynamic tagging library
    11 require("shifty")
    12 local shifty = require("shifty")
    12 -- Revelation
    13 -- Revelation
    13 require("revelation")
    14 local revelation = require("revelation")
    14 -- vicious widgets
    15 -- vicious widgets
    15 local vicious = require("vicious")
    16 local vicious = require("vicious")
    16 local wicked = require("wicked")
    17 local wicked = require("wicked")
    17 -- Load Debian menu entries
    18 -- Load Debian menu entries
    18 require("debian.menu")
    19 require("debian.menu")
    19 
    20 
    20 -- require("keychains")
    21 -- require("keychains")
    21 
    22 
    22 require("my")
    23 local my = require("my")
    23 
    24 
    24 -- {{{ Error handling
    25 -- {{{ Error handling
    25 -- Check if awesome encountered an error during startup and fell back to
    26 -- 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 -- another config (This code will only ever execute for the fallback config)
    27 if awesome.startup_errors then
    28 if awesome.startup_errors then
    30                     text = awesome.startup_errors })
    31                     text = awesome.startup_errors })
    31 end
    32 end
    32 
    33 
    33 -- Handle runtime errors after startup
    34 -- Handle runtime errors after startup
    34 do
    35 do
    35    awesome.add_signal("debug::error", my.notify_error)
    36    awesome.connect_signal("debug::error", my.notify_error)
    36 end
    37 end
    37 -- }}}
    38 -- }}}
    38 
    39 
    39 -- Variable definitions
    40 -- Variable definitions
    40 -- Themes define colours, icons, and wallpapers
    41 -- Themes define colours, icons, and wallpapers
    83       awful.layout.suit.tile.bottom,
    84       awful.layout.suit.tile.bottom,
    84       awful.layout.suit.tile.top,
    85       awful.layout.suit.tile.top,
    85       awful.layout.suit.fair,
    86       awful.layout.suit.fair,
    86       awful.layout.suit.fair.horizontal,
    87       awful.layout.suit.fair.horizontal,
    87       awful.layout.suit.max,
    88       awful.layout.suit.max,
    88       awful.layout.suit.max.fullscreen,
    89       -- awful.layout.suit.max.fullscreen,
    89       awful.layout.suit.magnifier,
    90       awful.layout.suit.magnifier,
    90       awful.layout.suit.floating
    91       awful.layout.suit.floating
    91    }
    92    }
    92 
    93 
    93 -- Define if we want to use titlebar on all applications.
    94 -- Define if we want to use titlebar on all applications.
    94 use_titlebar = true
    95 use_titlebar = true
    95 
    96 
    96 -- Remove the focus follow mouse install by shifty.
    97 -- Remove the focus follow mouse install by shifty.
    97 shifty.config.sloppy = false
    98 -- shifty.config.sloppy = false
    98 
    99 
    99 -- Shifty configured tags.
   100 -- Shifty configured tags.
   100 shifty.config.tags = {
   101 shifty.config.tags = {
   101    w1 = {
   102    w1 = {
   102       layout    = awful.layout.suit.tile,
   103       layout    = awful.layout.suit.tile,
   138    },
   139    },
   139    office = {
   140    office = {
   140       layout   = awful.layout.suit.tile,
   141       layout   = awful.layout.suit.tile,
   141       position = 6,
   142       position = 6,
   142    },
   143    },
       
   144    OZoNE = {
       
   145       layout = awful.layout.suit.max,
       
   146       position = 7,
       
   147       spawn = terminal .. " -e ssh o"
       
   148    }
   143 }
   149 }
   144 
   150 
   145 -- SHIFTY: application matching rules
   151 -- SHIFTY: application matching rules
   146 -- order here matters, early rules will be applied first
   152 -- order here matters, early rules will be applied first
   147 shifty.config.apps = {
   153 shifty.config.apps = {
   251    guess_position = true,
   257    guess_position = true,
   252 }
   258 }
   253 
   259 
   254 --  Wibox
   260 --  Wibox
   255 -- Create a textbox widget
   261 -- Create a textbox widget
   256 mytextclock = awful.widget.textclock({align = "right"})
   262 mytextclock = awful.widget.textclock()
   257 
   263 
   258 -- Create a laucher widget and a main menu
   264 -- Create a laucher widget and a main menu
   259 myawesomemenu = {
   265 myawesomemenu = {
   260    {"manual", terminal .. " -e man awesome"},
   266    {"manual", terminal .. " -e man awesome"},
   261    {"edit config",
   267    {"edit config",
   270          {"awesome", myawesomemenu, beautiful.awesome_icon},
   276          {"awesome", myawesomemenu, beautiful.awesome_icon},
   271          { "Debian", debian.menu.Debian_menu.Debian },
   277          { "Debian", debian.menu.Debian_menu.Debian },
   272          {"open terminal", terminal}}
   278          {"open terminal", terminal}}
   273 })
   279 })
   274 
   280 
   275 mylauncher = awful.widget.launcher({image = image(beautiful.awesome_icon),
   281 mylauncher = awful.widget.launcher({image = beautiful.awesome_icon,
   276                                     menu = mymainmenu})
   282                                     menu = mymainmenu})
   277 
   283 
   278 -- Create a systray
   284 -- Create a systray
   279 mysystray = widget({type = "systray", align = "right"})
   285 mysystray = wibox.widget.systray({align = "right"})
   280 
   286 
   281 -- Create a wibox for each screen and add it
   287 -- Create a wibox for each screen and add it
   282 mywibox = {}
   288 mywibox = {}
   283 mypromptbox = {}
   289 mypromptbox = {}
   284 mylayoutbox = {}
   290 mylayoutbox = {}
   325    awful.util.spawn("awsetbg -a " .. wallpaper, false, s)
   331    awful.util.spawn("awsetbg -a " .. wallpaper, false, s)
   326 
   332 
   327    -- status box
   333    -- status box
   328 
   334 
   329    -- Create a promptbox for each screen
   335    -- Create a promptbox for each screen
   330    mypromptbox[s] =
   336    mypromptbox[s] = awful.widget.prompt()
   331       awful.widget.prompt({layout = awful.widget.layout.leftright})
       
   332    -- Create an imagebox widget which will contains an icon indicating which
   337    -- Create an imagebox widget which will contains an icon indicating which
   333    -- layout we're using.  We need one layoutbox per screen.
   338    -- layout we're using.  We need one layoutbox per screen.
   334    mylayoutbox[s] = awful.widget.layoutbox(s)
   339    mylayoutbox[s] = awful.widget.layoutbox(s)
   335    mylayoutbox[s]:buttons(awful.util.table.join(
   340    mylayoutbox[s]:buttons(awful.util.table.join(
   336                              awful.button({}, 1, function() awful.layout.inc(layouts, 1) end),
   341                              awful.button({}, 1, function() awful.layout.inc(layouts, 1) end),
   337                              awful.button({}, 3, function() awful.layout.inc(layouts, -1) end),
   342                              awful.button({}, 3, function() awful.layout.inc(layouts, -1) end),
   338                              awful.button({}, 4, function() awful.layout.inc(layouts, 1) end),
   343                              awful.button({}, 4, function() awful.layout.inc(layouts, 1) end),
   339                              awful.button({}, 5, function() awful.layout.inc(layouts, -1) end)))
   344                              awful.button({}, 5, function() awful.layout.inc(layouts, -1) end)))
   340    -- Create a taglist widget
   345    -- Create a taglist widget
   341    mytaglist[s] = awful.widget.taglist.new(s,
   346    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
   342                                            awful.widget.taglist.label.all,
       
   343                                            mytaglist.buttons)
       
   344 
   347 
   345    -- Create a tasklist widget
   348    -- Create a tasklist widget
   346    mytasklist[s] = awful.widget.tasklist.new(
   349    mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
   347       function(c)
       
   348         return awful.widget.tasklist.label.currenttags(c, s)
       
   349       end,
       
   350       mytasklist.buttons)
       
   351 
       
   352 
   350 
   353    -- Create the wibox
   351    -- Create the wibox
   354    mywibox[s] = awful.wibox({position = "top", screen = s})
   352    mywibox[s] = awful.wibox({position = "top", screen = s})
   355    -- Add widgets to the wibox - order matters
   353    -- Add widgets to the wibox - order matters
   356    mywibox[s].widgets = {
   354    local left_layout = wibox.layout.fixed.horizontal()
   357       {
   355    left_layout:add(myktwidget)
   358          myktwidget,
   356    left_layout:add(mylauncher)
   359          mylauncher,
   357    if s == 1 then
   360          s == 1 and mycpuwidget or nil,
   358       left_layout:add(mycpuwidget)
   361          s == 1 and mymemwidget or nil,
   359       left_layout:add(mymemwidget)
   362          mytaglist[s],
   360    end
   363          mypromptbox[s],
   361    left_layout:add(mytaglist[s])
   364          layout = awful.widget.layout.horizontal.leftright
   362    left_layout:add(mypromptbox[s])
   365       },
   363 
   366       mylayoutbox[s],
   364    local right_layout = wibox.layout.fixed.horizontal()
   367       s == 1 and mynetwidget or nil,
   365    right_layout:add(mylayoutbox[s])
   368       mytextclock,
   366    if (s == 1) then right_layout:add(mynetwidget) end
   369       s == 1 and mysystray or nil,
   367    right_layout:add(mytextclock)
   370       mytasklist[s],
   368    if (s == 1) then right_layout:add(mysystray) end
   371       layout = awful.widget.layout.horizontal.rightleft
   369 
   372    }
   370    local layout = wibox.layout.align.horizontal()
       
   371    layout:set_left(left_layout)
       
   372    layout:set_middle(mytasklist[s])
       
   373    layout:set_right(right_layout)
       
   374    mywibox[s]:set_widget(layout)
   373 
   375 
   374    mywibox[s].screen = s
   376    mywibox[s].screen = s
   375 end
   377 end
   376 
   378 
   377 -- SHIFTY: initialize shifty
   379 -- SHIFTY: initialize shifty
   399             my.mkinteractive(function() shifty.add({nopopup = true}) end)),
   401             my.mkinteractive(function() shifty.add({nopopup = true}) end)),
   400    my.make_key("Up", "View prev",
   402    my.make_key("Up", "View prev",
   401             function () awful.tag.viewprev(); return true; end),
   403             function () awful.tag.viewprev(); return true; end),
   402    my.make_key("Down", "View next", 
   404    my.make_key("Down", "View next", 
   403             function () awful.tag.viewnext(); return true; end),
   405             function () awful.tag.viewnext(); return true; end),
   404    my.make_key("Shift+Up", "Move tag right", 
   406    -- my.make_key("Shift+Up", "Move tag right", 
   405             function()
   407    --          function()
   406                local t = awful.tag.selected()
   408    --             local t = awful.tag.selected()
   407                local s = awful.util.cycle(screen.count(), t.screen + 1)
   409    --             local s = awful.util.cycle(screen.count(), t.screen + 1)
   408                awful.tag.history.restore()
   410    --             awful.tag.history.restore()
   409                t = shifty.tagtoscr(s, t)
   411    --             t = shifty.tagtoscr(s, t)
   410                awful.tag.viewonly(t)
   412    --             awful.tag.viewonly(t)
   411                return true
   413    --             return true
   412    end),
   414    -- end),
   413    my.make_key("Shift+Down", "Move tag left", 
   415    -- my.make_key("Shift+Down", "Move tag left", 
   414             function()
   416    --          function()
   415                local t = awful.tag.selected()
   417    --             local t = awful.tag.selected()
   416                local s = awful.util.cycle(screen.count(), t.screen - 1)
   418    --             local s = screen.count() + t.screen - 1
   417                awful.tag.history.restore()
   419    --             s = awful.util.cycle(screen.count(), s)
   418                t = shifty.tagtoscr(s, t)
   420    --             awful.tag.history.restore()
   419                awful.tag.viewonly(t)
   421    --             t = shifty.tagtoscr(s, t)
   420                return true
   422    --             awful.tag.viewonly(t)
   421    end),
   423    --             return true
       
   424    -- end),
   422 }
   425 }
   423 
   426 
   424 local awesome_keys = {
   427 local awesome_keys = {
   425    my.make_key("m", "Menu", my.mkinteractive(function () 
   428    my.make_key("m", "Menu", my.mkinteractive(function () 
   426                mymainmenu:show({keygrabber=true}) 
   429                mymainmenu:show({keygrabber=true}) 
   639 -- end
   642 -- end
   640 -- keychains.add({modkey}, "w", "Awesome", nil, kt2kc(awesome_keys))
   643 -- keychains.add({modkey}, "w", "Awesome", nil, kt2kc(awesome_keys))
   641 -- keychains.start(5)
   644 -- keychains.start(5)
   642 
   645 
   643 -- Hook function to execute when focusing a client.
   646 -- Hook function to execute when focusing a client.
   644 client.add_signal("focus", 
   647 client.connect_signal("focus", 
   645                   function(c)
   648                   function(c)
   646                      -- my.notify_error("Client focus:\n" .. debug.traceback())
   649                      -- my.notify_error("Client focus:\n" .. debug.traceback())
   647                      if not awful.client.ismarked(c) then
   650                      if not awful.client.ismarked(c) then
   648                         c.border_color = beautiful.border_focus
   651                         c.border_color = beautiful.border_focus
   649                         c.opacity = 1.0
   652                         c.opacity = 1.0
   650                      end
   653                      end
   651 end)
   654 end)
   652 
   655 
   653 -- Hook function to execute when unfocusing a client.
   656 -- Hook function to execute when unfocusing a client.
   654 client.add_signal("unfocus", function(c)
   657 client.connect_signal("unfocus", function(c)
   655                      if not awful.client.ismarked(c) then
   658                      if not awful.client.ismarked(c) then
   656                         c.border_color = beautiful.border_normal
   659                         c.border_color = beautiful.border_normal
   657                         c.opacity = 0.8
   660                         c.opacity = 0.8
   658                      end
   661                      end
   659 end)
   662 end)