Ticket #93: 0001-Use-user-shell-by-default.patch

File 0001-Use-user-shell-by-default.patch, 5.1 KB (added by SnapShot, 3 years ago)
  • data/guake.schemas

    From 0cc4bbbcd79226ae0bdd22dc34f12cf561486d28 Mon Sep 17 00:00:00 2001
    From: Aleksandar Krsteski <alekrsteski@gmail.com>
    Date: Wed, 4 Mar 2009 00:58:58 +0100
    Subject: [PATCH] Use user shell by default.
    
    Guake should use user shell defined for the user in /etc/passwd by
    default. Also add an option to select user shell in preferences so the
    user can return to user shell option after selection another shell.
    Implementation uses the user shell by passing None to vte command
    argument. Also fallback to user shell if default_shell option defines
    invalid path.
    ---
     data/guake.schemas |    7 ++++---
     src/guake.py       |   21 +++++++++++++++------
     src/prefs.py       |   17 +++++++++++++++--
     3 files changed, 34 insertions(+), 11 deletions(-)
    
    diff --git a/data/guake.schemas b/data/guake.schemas
    index f439dd5..1f69379 100644
    a b  
    66            <applyto>/apps/guake/general/default_shell</applyto> 
    77            <owner>guake</owner> 
    88            <type>string</type> 
    9             <default>/bin/bash</default> 
     9            <default></default> 
    1010            <locale name="C"> 
    1111                <short>Path to the default shell.</short> 
    12                 <long>Path to the default shell. If an invalid shell is placed 
    13                 here, guake will fallback to bash.</long> 
     12                <long>Path to the default shell. Set to empty to 
     13                use default user shell. If invalid path is set 
     14                here, guake will fallback to user shell.</long> 
    1415            </locale> 
    1516        </schema> 
    1617 
  • src/guake.py

    diff --git a/src/guake.py b/src/guake.py
    index 114c1d7..985045f 100644
    a b  
    894894        """Return all parameters to be passed to the fork_command 
    895895        method of a vte terminal. 
    896896        """ 
    897         argv = None 
    898         shell = self.client.get_string(KEY('/general/default_shell')) or 'sh' 
     897        # use dictionary to pass named params to work around command 
     898        # parameter in fork_command not accepting None as argument. 
     899        # When we pass None as command, vte starts the default user shell. 
     900        params = {} 
     901 
     902        shell = self.client.get_string(KEY('/general/default_shell')) 
     903        if shell and os.path.exists(shell): 
     904            params['command'] = shell 
     905 
    899906        login_shell = self.client.get_bool(KEY('/general/use_login_shell')) 
    900907        if login_shell: 
    901             argv = ['-'] 
     908            params['argv'] = ['-'] 
     909 
     910        params['directory'] = self.get_current_dir() 
     911        params['loglastlog'] = login_shell 
    902912 
    903         directory = self.get_current_dir() 
    904         return shell, argv, None, directory, login_shell, False, False 
     913        return params 
    905914 
    906915    def add_tab(self, *args): 
    907916        """Adds a new tab to the terminal notebook. 
     
    915924        last_added = len(self.term_list) 
    916925        self.term_list.append(box.terminal) 
    917926 
    918         pid = box.terminal.fork_command(*self.get_fork_params()) 
     927        pid = box.terminal.fork_command(**self.get_fork_params()) 
    919928        self.pid_list.append(pid) 
    920929 
    921930        # Adding a new radio button to the tabbar 
  • src/prefs.py

    diff --git a/src/prefs.py b/src/prefs.py
    index d4ab770..3045c0b 100644
    a b  
    3838# rest of the combo too. 
    3939SHELLS_FILE = '/etc/shells' 
    4040 
     41# string to show in prefereces dialog for user shell option 
     42USER_SHELL_VALUE = _('<user shell>') 
     43 
    4144# translating our types to vte types 
    4245ERASE_BINDINGS = {'ASCII DEL': 'ascii-delete', 
    4346                  'Escape sequence': 'delete-sequence', 
     
    98101        if not citer: 
    99102            return 
    100103        shell = combo.get_model().get_value(citer, 0) 
    101         self.client.set_string(KEY('/general/default_shell'), shell) 
     104        # we unset the value (restore to default) when user chooses to use 
     105        # user shell as guake shell interpreter. 
     106        if shell == USER_SHELL_VALUE: 
     107            self.client.unset(KEY('/general/default_shell')) 
     108        else: 
     109            self.client.set_string(KEY('/general/default_shell'), shell) 
    102110 
    103111    def on_use_login_shell_toggled(self, chk): 
    104112        """Changes the activity of use_login_shell in gconf 
     
    358366        """ 
    359367        # default_shell 
    360368        combo = self.get_widget('default_shell') 
     369        # get the value for defualt shell. If unset, set to USER_SHELL_VALUE. 
     370        value = self.client.get_string(KEY('/general/default_shell')) or \ 
     371                USER_SHELL_VALUE 
    361372        for i in combo.get_model(): 
    362             if i[0] == self.client.get_string(KEY('/general/default_shell')): 
     373            if i[0] == value: 
    363374                combo.set_active_iter(i.iter) 
    364375 
    365376        # login shell 
     
    449460        fill the default_shell combobox. 
    450461        """ 
    451462        cb = self.get_widget('default_shell') 
     463        # append user shell as first option 
     464        cb.append_text(USER_SHELL_VALUE) 
    452465        if os.path.exists(SHELLS_FILE): 
    453466            lines = open(SHELLS_FILE).readlines() 
    454467            for i in lines: