Posts Tagged ‘custom-scripts’

Porting Windows behaviour to Linux :)

Wednesday, July 7th, 2010

In the olden days when I still used Windows, I loved having the ALT+PrintScreen keycombo around, it makes a screen capture of only the currently active window, nicely cropped and everything. This saves you the hassle of aligning it pixel-perfect in Paint. On Linux, at least using awesome, I haven’t been able to do this, so I wrote a quick script that allows me to do that and a bit more.

grabw is a bash script that allows you to

  1. Take a screenshot of a window by X window ID
  2. Take a screenshot of a window the user first has to click, using xwininfo
  3. The above two with or without asking for a filename using Zenity’s file selection dialogue window

Combine this with awesome’s ability to spawn processes on the fly and pass parameters (such as window IDs, *hint hint*) this is one feature I’m glad to have back

grabw 0.2 has been released into public domain, you can find it on my projects page.

Gentoo, awesome and themes

Thursday, February 25th, 2010

I’ve been a Gentoo user since forever, and for some time I’ve been using awesome for a window manager instead of the desktop environments Gnome or KDE. One thing I never got around to change was the wallpaper. My terminals are pseudo-transparent, and I never disliked the default ‘awesome’ wallpaper. @ZackLeonhart’s bitching and moaning changed that.

Turns out that aside from editing the system-wide theme script, by default located in /usr/share/awesome/themes/* (which I consider to be a BadThink™), there is no straight forward way of doing it nicely in the Gentoo provided default setup. So here’s what you do.

  1. Create yourself a lua.rc in ${HOME}/.config/awesome
    $ cp /etc/xdg/awesome/rc.lua ~/.config/awesome
  2. Recursively copy all themes from the system-wide dirs to your local configdir.
    $ cp -rvf /usr/share/awesome/themes ~/.config/awesome
  3. In your copy of lua.rc you will find a variable called theme_path, change it to theme_path = os.getenv("HOME") .. "/.config/awesome/themes/path/to/theme.lua"
  4. Edit the variable theme.wallpaper_cmd to contain the string "eval `cat ~/.fehbg`"
  5. Choose a wallpaper you like, execute $ feh --bg-scale /path/to/wallpaper.jpg

And you’re done! If you want to change your wallpaper, simply use feh again with a random other file, and make sure the file is readable when awesome is starting up, and it’ll set it up automagically. Basically, awesome’s ‘beautiful’ library takes your typed out command and executes that in order to set the wallpaper, feh has a convenient way of storing the default wallpaper by simply dumping the command that was used to set it up in the first place in a configuration file in your home directory, hence the eval `cat whatever` trick.

Screenshot of my new wallpaper in Awesome

Screenshot of my new wallpaper in Awesome

P.S.: Don’t think you can leave out the call to os.getenv() in step 3, awesome doesn’t expand the tilde (’~'), so the path it’ll try to access will be invalid.

P.P.S.: This is more of a note for me, in case I ever lose my epic new wallpaper. It can be found here.