subscribe
Tags:
 
2010
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
2009-05-19
For a while now, after starting my computer and launching a terminal, I've been maximizing and undecorating the terminal window. Unfortunately, I was unable to find a way to use command line arguments to launch my current favorite terminal: Sakura, in maximized and undecorated mode. To put it simply, I had three options:
  • Try to find another terminal app that does what I need
  • Edit the Sakura soure code to add the maximize and undecorate option
  • Code my own app

I elected for "code my own app" and I called it muterm because it is a (m)aximized (u)ndecorated (term)inal emulator. This would also be a good introduction for anyone interested in adding a terminal emulator to a Vala project.
Here is my main.vala code:
using Gtk; using Vte; private class Term {     private Term()     {         //start with a gtk window         Window w;         //we also need a vte terminal         Terminal term;         //create our new window         new Window(Gtk.WindowType.TOPLEVEL);         //create the new terminal         term new Terminal();         //connect exiting on the terminal with quiting the app         term.child_exited.connect ( (t)=> { Gtk.main_quit(); } );         //fork a command to run when the terminal is started         term.fork_command(null,null,null,nulltruetrue,true);         //add the terminal to the window         w.add(term);         //maximize the window         w.maximize();         //undecorate the window         w.set_decorated(false);         //try to set the icon         try{             w.set_icon_from_file("/usr/share/pixmaps/gnome-term.png");         }catch(Error er)         {             //we don't really need to print this error             stdout.printf(er.message);         }         //show our window and all children of our window         w.show_all();     }     private void run()     {         //start the gtk mainloop         Gtk.main();     }     private static void main(string[] args)     {         Term t;         Gtk.init(ref args);         new Term();         t.run();     } }

The code is compiled with:
valac --pkg gtk+-2.0 --pkg vte main.vala -o muterm

It took me a while to realize that I didn't need to have values for all of the Vte.Terminal.fork_command() function. Howerver, I should allow passing a directory as an arguement and have muterm start in that directory as the `pwd`. Copying and pasting text in the terminal would also be a great idea. Maybe, we'll see what the future holds.

I'd show a screenshot, but really, how different do terminals really look?
Comments
Backspace wasn't being handled correctly when using "screen", so I needed to add the following after creating the new VTE Terminal instance:
term.set_backspace_binding(TerminalEraseBinding.ASCII_BACKSPACE);
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
1 plus 6
Answer:
required