Showing posts with label vicious. Show all posts
Showing posts with label vicious. Show all posts

2011-11-17

Updated Awesome Config (rc.lua)

A few words:


This rc.lua is the on that I use for my current desktop configuration.  Some options might not work for you (especially if you don't have Vicious installed).  Make sure that before you rely on this config in your setup that you first browse through it and make sure that your installed apps match.  The syntax is pretty simple, so if my IM app ("Pidgin") doesn't match yours, just change the name in quotes to the executable binary for your IM App.  My config assumes that you have moved the default themes into your ~/.config/awesome directory, if you have not done this, then edit accordingly.  Realistically, this should be used as more of a guide to doing some simple customizations to your existing configs and not as a "guaranteed to work replacement".

If you have any questions regarding my config or how to modify your own with some added widgets, menus, keybinding defaults, etc then hit me up on my Google+ Profile.


The Config:


===================================================================================


-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- Vicious Widgets
require("vicious")


-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/home/darthlukan/.config/awesome/themes/default/theme.lua")


-- This is used later as the default terminal and editor to run.
terminal = "terminator"
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e " .. editor


-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"


-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
    awful.layout.suit.floating,
    awful.layout.suit.tile,
    awful.layout.suit.tile.left,
    awful.layout.suit.tile.bottom,
    awful.layout.suit.tile.top,
    awful.layout.suit.fair,
    awful.layout.suit.fair.horizontal,
    awful.layout.suit.spiral,
    awful.layout.suit.spiral.dwindle,
    awful.layout.suit.max,
    awful.layout.suit.max.fullscreen,
    awful.layout.suit.magnifier
}
-- }}}


-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
    -- Each screen has its own tag table.
    tags[s] = awful.tag({ 'Terms', 'Net', 'Work', 'Dev', 'Coms', 'Down', 'Vids', 'Music', 'Misc' }, s, layouts[1])
end
-- }}}


-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
   { "manual", terminal .. " -e man awesome" },
   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
   { "restart", awesome.restart },
   { "quit", awesome.quit }
}
mydevmenu = {
   { "Spyder", "spyder"},
   { "Gedit", "gedit" },
   { "Bluefish", "bluefish" },
   { "CodeBlocks", "codeblocks"},
   { "VIM", terminal .. " -e vim" } 
}
mycustommenu = {
   { "Irc", terminal .. " -e screen weechat-curses" },
   { "IM", "pidgin" },
   { "Email", terminal .. " -e screen alpine" },
   { "Chrome", "chromium" },
   { "uzbl Browser", "uzbl-browser" },
   { "Image Viewer", "viewnior" }, 
   { "Music", terminal .. " -e screen cmus" },
   { "PCmanFM", "pcmanfm" },
   { "MC", terminal .. " -e screen mc" },
   { "rtorrent", terminal .. " -e screen rtorrent" },
   { "Monitor", terminal .. " -e htop" },
   { "Pulse Volume", "pavucontrol" }
}
mymainmenu = awful.menu({ items = { { "Dev", mydevmenu, beautiful.awesome_icon },
                   { "common", mycustommenu, beautiful.awesome_icon },
                                    { "awesome", myawesomemenu, beautiful.awesome_icon },
                                    { "open terminal", terminal }
                                  }
                        })


mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
                                     menu = mymainmenu })
-- }}}


-- {{{ Wibox
-- Start Vicious Widgets Config
-- Gmail Widget
-- Initilize widget
gmailwidget = widget({ type = "textbox" })
-- Register widget
vicious.register(gmailwidget, vicious.widgets.gmail, "Gmail: ${count}", 200)


-- Naughty Notifications on new email (WIP)
-- CODE
-- End Naughty Notifications on new email


-- CPU Graph
-- Initialize widget
cpuwidget = awful.widget.graph()
-- Graph properties
cpuwidget:set_width(25)
cpuwidget:set_background_color("#494B4F")
cpuwidget:set_color("#FF5656")
cpuwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
-- Register widget
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 2)


-- CPU Text Widget
-- Initialize widget
cputextwidget = widget({ type = "textbox" })
-- Register widget
vicious.register(cputextwidget, vicious.widgets.cpu, "CPU: $1%", 4)


-- RAM Graph
-- Initialize widget
memwidget = awful.widget.graph()
-- Graph properties
memwidget:set_width(25)
memwidget:set_background_color("#494B4F")
memwidget:set_color("#FF5656")
memwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
-- Register widget
vicious.register(memwidget, vicious.widgets.mem, "$1", 3)


-- Mem Text Widget
memtextwidget = widget({ type = "textbox" })
-- Register widget
vicious.register(memtextwidget, vicious.widgets.mem, "RAM: $1%", 5)
-- End Vicious Widgets Config


-- Separators (thanks anrxc)
sepline = widget({ type = "textbox" })
sepline.text = "|"
sepspace = widget({ type= "textbox" })
sepspace.text = " "


-- Create a textclock widget
mytextclock = awful.widget.textclock({ align = "right" })


-- Create a systray
mysystray = widget({ type = "systray" })


-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
                    awful.button({ }, 1, awful.tag.viewonly),
                    awful.button({ modkey }, 1, awful.client.movetotag),
                    awful.button({ }, 3, awful.tag.viewtoggle),
                    awful.button({ modkey }, 3, awful.client.toggletag),
                    awful.button({ }, 4, awful.tag.viewnext),
                    awful.button({ }, 5, awful.tag.viewprev)
                    )
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
                     awful.button({ }, 1, function (c)
                                              if c == client.focus then
                                                  c.minimized = true
                                              else
                                                  if not c:isvisible() then
                                                      awful.tag.viewonly(c:tags()[1])
                                                  end
                                                  -- This will also un-minimize
                                                  -- the client, if needed
                                                  client.focus = c
                                                  c:raise()
                                              end
                                          end),
                     awful.button({ }, 3, function ()
                                              if instance then
                                                  instance:hide()
                                                  instance = nil
                                              else
                                                  instance = awful.menu.clients({ width=250 })
                                              end
                                          end),
                     awful.button({ }, 4, function ()
                                              awful.client.focus.byidx(1)
                                              if client.focus then client.focus:raise() end
                                          end),
                     awful.button({ }, 5, function ()
                                              awful.client.focus.byidx(-1)
                                              if client.focus then client.focus:raise() end
                                          end))


for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = awful.widget.layoutbox(s)
    mylayoutbox[s]:buttons(awful.util.table.join(
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)


    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist(function(c)
                                              return awful.widget.tasklist.label.currenttags(c, s)
                                          end, mytasklist.buttons)


    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", height = "18", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
        {
            mylauncher,
            mytaglist[s],
            mypromptbox[s],
            layout = awful.widget.layout.horizontal.leftright
        },
        mylayoutbox[s], sepspace,
        mytextclock, sepspace, 
        s == 1 and mysystray or nil,
        sepline, sepspace, memwidget.widget, sepspace, memtextwidget,
        sepspace, sepline, sepspace, cpuwidget.widget, sepspace, cputextwidget,
        sepspace, sepline, sepspace, gmailwidget, sepspace,
        sepline, sepspace, 
        mytasklist[s],
        layout = awful.widget.layout.horizontal.rightleft
    }
end
-- }}}


-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
    awful.button({ }, 3, function () mymainmenu:toggle() end),
    awful.button({ }, 4, awful.tag.viewnext),
    awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}


-- {{{ Key bindings
globalkeys = awful.util.table.join(
    awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
    awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
    awful.key({ modkey,           }, "Escape", awful.tag.history.restore),


    awful.key({ modkey,           }, "j",
        function ()
            awful.client.focus.byidx( 1)
            if client.focus then client.focus:raise() end
        end),
    awful.key({ modkey,           }, "k",
        function ()
            awful.client.focus.byidx(-1)
            if client.focus then client.focus:raise() end
        end),
    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),


    -- Layout manipulation
    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
    awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
    awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
    awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
    awful.key({ modkey,           }, "Tab",
        function ()
            awful.client.focus.history.previous()
            if client.focus then
                client.focus:raise()
            end
        end),


    -- Standard program
    awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
    awful.key({ modkey, "Control" }, "r", awesome.restart),
    awful.key({ modkey, "Shift"   }, "q", awesome.quit),


    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
    awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
    awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
    awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
    awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
    awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
    awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
    awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),


    awful.key({ modkey, "Control" }, "n", awful.client.restore),


    -- Prompt
    awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),


    awful.key({ modkey }, "x",
              function ()
                  awful.prompt.run({ prompt = "Run Lua code: " },
                  mypromptbox[mouse.screen].widget,
                  awful.util.eval, nil,
                  awful.util.getdir("cache") .. "/history_eval")
              end)
)


clientkeys = awful.util.table.join(
    awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
    awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
    awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
    awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
    awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
    awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
    awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
    awful.key({ modkey,           }, "n",
        function (c)
            -- The client currently has the input focus, so it cannot be
            -- minimized, since minimized clients can't have the focus.
            c.minimized = true
        end),
    awful.key({ modkey,           }, "m",
        function (c)
            c.maximized_horizontal = not c.maximized_horizontal
            c.maximized_vertical   = not c.maximized_vertical
        end)
)


-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
   keynumber = math.min(9, math.max(#tags[s], keynumber));
end


-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
    globalkeys = awful.util.table.join(globalkeys,
        awful.key({ modkey }, "#" .. i + 9,
                  function ()
                        local screen = mouse.screen
                        if tags[screen][i] then
                            awful.tag.viewonly(tags[screen][i])
                        end
                  end),
        awful.key({ modkey, "Control" }, "#" .. i + 9,
                  function ()
                      local screen = mouse.screen
                      if tags[screen][i] then
                          awful.tag.viewtoggle(tags[screen][i])
                      end
                  end),
        awful.key({ modkey, "Shift" }, "#" .. i + 9,
                  function ()
                      if client.focus and tags[client.focus.screen][i] then
                          awful.client.movetotag(tags[client.focus.screen][i])
                      end
                  end),
        awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
                  function ()
                      if client.focus and tags[client.focus.screen][i] then
                          awful.client.toggletag(tags[client.focus.screen][i])
                      end
                  end))
end


clientbuttons = awful.util.table.join(
    awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
    awful.button({ modkey }, 1, awful.mouse.client.move),
    awful.button({ modkey }, 3, awful.mouse.client.resize))


-- Set keys
root.keys(globalkeys)
-- }}}


-- {{{ Rules
awful.rules.rules = {
    -- All clients will match this rule.
    { rule = { },
      properties = { border_width = beautiful.border_width,
                     border_color = beautiful.border_normal,
                     focus = true,
                     keys = clientkeys,
                     buttons = clientbuttons } },
    { rule = { class = "MPlayer" },
      properties = { floating = true } },
    { rule = { class = "pinentry" },
      properties = { floating = true } },
    { rule = { class = "gimp" },
      properties = { floating = true } },
    -- Set Firefox to always map on tags number 2 of screen 1.
    -- { rule = { class = "Firefox" },
    --   properties = { tag = tags[1][2] } },
}
-- }}}


-- {{{ Signals
-- Signal function to execute when a new client appears.
client.add_signal("manage", function (c, startup)
    -- Add a titlebar
    -- awful.titlebar.add(c, { modkey = modkey })


    -- Enable sloppy focus
    c:add_signal("mouse::enter", function(c)
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
            and awful.client.focus.filter(c) then
            client.focus = c
        end
    end)


    if not startup then
        -- Set the windows at the slave,
        -- i.e. put it at the end of others instead of setting it master.
        awful.client.setslave(c)


        -- Put windows in a smart way, only if they does not set an initial position.
        if not c.size_hints.user_position and not c.size_hints.program_position then
            awful.placement.no_overlap(c)
            awful.placement.no_offscreen(c)
        end
    end
end)


client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)


-- { Autostart some things
os.execute("xscreensaver -nosplash &") --screensaver daemon
os.execute("volwheel &") -- volwheel system tray applet
os.execute("dropbox &") -- dropbox service
os.execute("nm-applet &") -- NetworkManager applet
-- }
-- }}}


=====================================================================================


Phew! That's a lot of text.  Hopefully this is helpful to you.  I'll get to work on re-writing my Awesome How To as soon as I find some time in my schedule.  Until then, this should get you started if you're clever :)

Enjoy!

darthlukan@gmail.com

2009-11-16

Adventures with Awesome-3.4.1-Part1-The Basics


              
#TODO: Add screenshots


        I promised a walk-through of how to setup an rc.lua with widgets and other personalizations in Awesome, and here I am to come through :)  First thing is first, installing Awesome.  I will assume that you are familiar with your linux distribution enough to be able to install a package.  For Sabayon users you can open up your favorite terminal and type:

equo update && equo install awesome

Once the package is complete, enter this command:

cp /etc/xdg/awesome/rc.lua /home/yourname/.config/awesome

If you get a complaint about the awesome directory not being there, create it (as user)

mkdir ~/.config/awesome  

and then follow the previous command to copy the stock rc.lua to your home directory.

To alleviate any issues of permissions, as root: chown yourname /home/yourname/.config/awesome/rc.lua

Remember! you will still have to be root to edit the rc.lua in /etc/xdg/awesome.

Now that all of that is out of the way, let's get to personalizing Awesome.  Open the run prompt (at the top of the screen) by typing mod4+r (mod4 = windows key on most US keymaps).  You will notice a small "run" dialog at the top of your screen on the statusbar.  Enter the run command for your text editor of choice (gedit, bluefish-unstable, emacs, etc), once your editor is up on your screen, open your rc.lua (from within your ~/.config/awesome directory) and take a look at what is going on.  Here is a look at the top of my rc.lua:



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.  -- Vicious Widgets
10. require("vicious")



As you can see there is quite a bit going on here :)  Lines 1 - 10 are telling awesome what libraries to open, for now we won't worry about this, just know that what is contained in that block is what's required for awesome to open.


12.-- {{{ Variable definitions
13.-- Themes define colours, icons, and wallpapers
14.beautiful.init("/home/darthlukan/.config/awesome/themes/default/theme.lua")


Lines 12 - 14 are the first of what I think of as the "eye candy" configs.  Here is where we specify our themes to be used.  There are infinite possibilities to theming awesome since the themes are really just config files themselves where arguments for colors and images can be made (among other things).  Awesome by default comes with three themes, Default, Zenburn, and Sky.  More on themes in  later How To.  For now just keep in mind that there are several themes available to you and some user submitted ones can be found on the Awesome wiki.



16. -- This is used later as the default terminal and editor to run.
17. terminal = "lilyterm"
18. editor = os.getenv("EDITOR") or "vim"
19. editor_cmd = terminal .. " -e " .. editor


Now we move on to lines 16 - 19.  As you can see in the screen shot, I have selected lilyterm as my terminal of choice, your rc.lua (assuming no changes from stock) most-likely shows Terminal = "xterm".  To change this simply do as I did and within the quotes enter the run command for your terminal of choice ("Eterm", "rxvt", "aterm", etc).  You will also see the line (18) specifying the terminal editor of choice, I prefer vim, so I left it there, but you can change this to match your preference as well ("nano", "vim", "pico", etc).


20. -- Default modkey.
21. -- Usually, Mod4 is the key with a logo between Control and Alt.
22. -- If you do not like this or do not have such a key,
23. -- I suggest you to remap Mod4 to another key using xmodmap or 24. other tools.
25. -- However, you can use another modifier like Mod1, but it may 26. interact with others.
27. modkey = "Mod4"


I won't touch on the next few lines (21 - 26) only because I have not myself adjusted these settings (for lack of a reason to) and I don't want to give bad information.  However, the mod4 key in my case is the "winkey", it's just about the only useful things that I have found for windows (yes that's a stab at an inferior OS :P ).


For the sake of ensuring that we have our bearings straight, I've included the layout arguments in the screenshot.  But really we are going to skip this and get right into the tags.  Your rc.lua (if stock) does not look the same on these lines, instead you have numbers:


tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)


Notice that there are no quotes ( ' ' or " " ), that is because you have numerical values.  To change the names of your tags (desktops) simply add either single (' ') or double (" ") quotes with your desired names within the quotes as you see in mine above.

Now we are going to take a break from this config file, I've thrown a lot at you and really by now you are looking at the default awesome background on your desktop and wonder, "when can I change this?".  So we are going to skip ahead a little and change that wallpaper :)

There are a couple of ways to do this, however, we are still at the basics level, so I'm going to show you the easiest way.  The following needs to be done as root using whichever text editor that you choose, here I'll use gedit:


# gedit /usr/share/awesome/themes/default/theme.lua


Once you have the file opened in your text editor, scroll down to line 77 (theme.wallpaper_cmd = )
and point the command to your desired background; in my case it is the same background as my SLiM theme.  You will have to restart awesome (or logout and log back in) for the change to take effect, but yes, it is truly as easy as that.  To restart awesome you can use key combinations (mod4+shift+r) or you can right-click on the desktop and in the awesome menu select "restart" or "quit".  If you select quit, awesome will close out completely and you will be sent back to your login manager, you will have to then log back in just as you would if you had turned on your computer.

With all of that done, you should now have Awesome setup for basic desktop use.  In the next part we will dive into changing themes, adding custom menus, and creating some simple widgets using Vicious!  If you are a more advanced user and feel that you have what it takes to dive right into customizing awesome, feel free to visit the Awesome wiki and have a look at all of the possibilities that have been posted there.  If you would rather play it safe, I'll have more up tomorrow.  For now, I'll leave you with a nice screenshot of some simple things that are possible with awesome :)  Enjoy:


-DarthLukan

2009-11-15

Adventures with Awesome-3.4.1

#TODO: Add new screenshot

So I have been using the Awesome window manager on Sabayon Linux (above screenshot) for the better part of a month as my primary window manager and am in love! Although first developed as a "tiling" window manager, Awesome has begun to change into quite the floating window manager as well. It's configuration is not very difficult at all (coming from me that is saying a lot) and is even easier if you are familiar with Lua code (I am not).

Awesome is configured by editing a single config file (~/.config/awesome/rc.lua) by default, which offers A LOT of functionality from default keybindings to background images, to menus, to you get the idea. It can optionally be extended by the use of external libraries to create widgets

#TODO: Add Images

Your tastes may vary, but as you can see I prefer a more simple interface. My widget library of choice so far is Vicious, however there are several others which can be found here at the Awesome Wiki. I chose Vicious because of a recommendation from Adrian C. (anrxc) who also happens to be a Vicious developer (pun intended). Vicious allows you to spare yourself the added typing of standard widgets by using a single line of code ( vicious.register() ).

Soon I will use this space to give a walk-through of sorts of how I edited the default rc.lua and how to create widgets with vicious. For now however, I have other things to do :)

Good Night!