Gnome Terminal profile scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I'd like to publish two Python scripts I've written to enhance the
usability of gnome-terminal. These scripts allow you to create a pull
down menu in the gnome-panel with gnome-terminal sessions.

- gnome-terminal-menu.py adds all the defined Gnome Terminal sessions to
the Gnome menu.

- gnome-terminal-new-profile.py creates a new Gnome Terminal session to
start a SSH connection to the supplied parameter. ie:
 gnome-terminal-new-profile.py server.gnome.nl creates a new session
which connects to server.gnome.nl.

The new gnome menu (directory) can be added to the gnome-panel to allow
quick connect by choosing "add to panel", "copy launcher from menu",
click "gnome-terminal" and press Add.

Please let me know if you found this usefull.

greetings,
Dick
#!/usr/bin/python

# Gnome Terminal Menu - Script to create Gnome Menu entries for gnome-terminal sessions
# Copyright (C) 2009 Dick Marinus
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gconf
import os

home = os.path.expanduser("~")+'/'

c = gconf.client_get_default()
profile_list = c.get_list('/apps/gnome-terminal/global/profile_list','string')


f = open(home+'.local/share/desktop-directories/gnometerminal.directory','w')
f.write('''[Desktop Entry]
Encoding=UTF-8
Icon=/usr/share/icons/gnome/scalable/apps/gnome-terminal.svg
Name=gnome-terminal
Type=Directory
''')

try:
    os.mkdir(home + '.config/menus/applications-merged/')
except OSError:
    pass

menu = open(home+'.config/menus/applications-merged/gnome-terminal.menu','w')
menu.write('''
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd";>
<Menu>
  <Name>Applications</Name>
  <Menu>
    <Name>gnome-terminal</Name>
    <Directory>gnometerminal.directory</Directory>
''')

try:
    os.mkdir(home + '.local/share/applications/gnometerminal/')
except OSError:
    pass

for profile in profile_list:
    host = profile.replace('@46@','.')
    desktop = open(home + '.local/share/applications/gnometerminal/%s.desktop' % host,'w')
    desktop.write('''[Desktop Entry]
Name=%s
Exec=gnome-terminal --window-with-profile=%s
Terminal=false
Encoding=UTF-8
Type=Application
Icon=/usr/share/pixmaps/gnome-terminal.png
''' % (host,host))
    desktop.close()

    menu.write('''    <Include>
        <Filename>gnometerminal-%s.desktop</Filename>
    </Include>
''' % host)

menu.write('''  </Menu>
</Menu>
''')
menu.close()
#!/usr/bin/python

# gnome-terminal-new-profile - Utility to create new gnome-terminal SSH profiles
# Copyright (C) 2009 Dick Marinus
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gconf
import sys
c = gconf.client_get_default()

for host in sys.argv[1:]:
    escaped = host.replace('.','@46@')
    new = '/apps/gnome-terminal/profiles/%s/' % escaped
    for entry in c.all_entries('/apps/gnome-terminal/profiles/Default'):
        k = entry.key.split('/')[-1]
        v = entry.value
        if k == 'custom_command':
            v = gconf.Value(gconf.VALUE_STRING)
            v.set_string('ssh '+host)
        if k == 'use_custom_command':
            v = gconf.Value(gconf.VALUE_BOOL)
            v.set_bool(True)
        if k == 'visible_name':
            v = gconf.Value(gconf.VALUE_STRING)
            v.set_string(host)

        c.set(new+k, v)

    profile_list = c.get_list('/apps/gnome-terminal/global/profile_list','string')
    if not escaped in profile_list:
        profile_list.append(escaped)
        c.set_list('/apps/gnome-terminal/global/profile_list','string',profile_list)
_______________________________________________
gnome-list mailing list
gnome-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gnome-list

[Index of Archives]     [Fedora Desktop]     [Trinity Users]     [KDE]     [Gimp]     [Yosemite News]

  Powered by Linux