photo
Jordan Sissel
geek

Thu, 07 Aug 2003

ion-devel rocks me sideways

I finally got off my lazy ass and learned to do kludge and lua stuff for ion-devel. I'm *so* glad I did.
With the new lua5 usage in ion-devel, you can basically script anything in key bindings. Using different means, I wrote two keybindings that let me view and rename frame region names (the physical frames themselves, not the deskspace name or the program name).
kpress(DEFAULT_MOD.."F10", function(reg) 
	    query_query(reg, "rename: ", nil, function(msg)
	       query_message(reg,"Set current region name to: "..msg)
	       region_set_name(reg,msg)
	       end,nil)
	  end),
press("F10", function(reg)
             query_message(reg, "name: " .. region_name(reg))
             end),
	     
These bindings were added to mplex_bindings.
Using nested, anonymous functions, we acheive our goals. Hitting "F10" in ion will now print the name of the currently-focused frame. ALT+F10 will prompt you to change it's name. Neat, eh?

I also did a bunch of kludge stuff for gaim, mozilla (firebird, really, but it'll work for mozilla), and gimp. Gimp required a bit of work telling what windows to go where since there are quite a few windows that can pop up.

So how do I do this kludge nonsense?
You'll need a tool that comes standard with XFree86, xprop This tool allows you to identify the class and instance of a given window. Simply type this command in a shell:
xprop WM_CLASS
The cursor will now turn into a crosshairs and you will need to click on the window you want to discover. For instance, clicking on one of my xterms produces this output:
WM_CLASS(STRING) = "xterm", "XTerm"
Now, the first word "xterm" is the instance. "XTerm" is the class. Now to make this a working kludge that'll send any programs matching this to a specific frame, you need to write a valid winprop entry.

winprop {
   class = "XTerm" 
   instance = "xterm"
   target = "target_frame"
}

We'll need a frame called 'target_frame' for this to work, so using the ALT+F10 keybinding from above, we can name a given frame. Restart ion with the F11 key (unless you've rebound that) and your kludge will now work. Run an xterm from anywhere in ion, and it'll be placed inside that frame.

In the screenshot on the right, you can see gimp in the works. All of those windows were placed in their own frames automatically, without me having to move a single one of them!

Comments: 0 (view comments)
Tags:
Permalink: /geekery/44
posted at: 12:07

Neat vim/screen trick.

For some time I've been wanting to be able to pop open a small split-pane in vim to run simple commands like, oh.. I don't know.. javac and such. Just for temporary, quick shell access.
Tonight, as I was browsing through the screen manpage, I saw that screen allowed you to split the window into different regions. Using this and a quick vim key mapping, I was able to do it without much trouble!

The vim keymapping:
map \s :silent !screen -X split<CR>:silent !screen -X focus down<CR>:silent !screen -X screen screener.sh<CR>:redraw!<CR>

Contents of screener.sh

$SHELL; screen -X remove

Thanks to screen being smart, you don't have to specify what screen session to send these commands to, which made it 10000% easier, as we don't have to bother trying to figure out which screen session is running vim. You could optionally add a :!screen -X resize >whatever< before the screener.sh :! execution to resize the lower frame to a specific size. See the screen manpage for more information on how to use screen -X and the resize command.

The results of hitting \s in vim can be found in the screenshot on the right. After logging out of that shell, the newly-split screen disappears and returns you to your original, full-screen vim.

Comments: 0 (view comments)
Tags:
Permalink: /productivity/39
posted at: 06:39

another lame hack (ALH)

So I got bored and after discovering that java doesn't let you (Or to my knowledge) access enviroment variables.
ENVS=`env | sed -e 's/"/\"/g' | sed -e 's/^(.*)=(.*)$/-D1="2"/' | \
      sed -e 's,.$,& \\,' && echo "$*"`
sh -c "java ${ENVS}" 
Put that in a shell script and call it with the same parameters you'd normally call java with. ie;
./lamehack.sh test
This will run 'java test' except it also passes a bunch of -D definitions for use in System.getProperty(). For example, you could now do: System.getProperty("DISPLAY") to grab the DISPLAY enviroment variable.

Comments: 0 (view comments)
Tags: , ,
Permalink: /oneliners/37
posted at: 02:19

xapply rocks me

I have a lot of mail boxes that need sorting from the various lists I subscribe too, and sorting by hand or on "viewing" is annoying, so I got bored and made use of xapply and the 6 processors on fury.csh to sort all of my mailboes.

find ./ -type d | xapply -f -P6 'echo "Sorting %1" && mhthread -fast -lock %1 && echo "Done sorting %1"' -

The cwd was ~/mail/ and directories under here are all mailboxes. So, xapply uses 6 parallel processes to call mhthread on each mailbox that was found.

Comments: 0 (view comments)
Tags: ,
Permalink: /oneliners/36
posted at: 02:14

Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '08 Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials SSH Tunneling (Video)

Tag Cloud

Calendar

< August 2003 >
SuMoTuWeThFrSa
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
31      

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati