Skip to content

Commit

Permalink
expose Guake startup script to the pref window (fix #198)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaetan Semet <[email protected]>
  • Loading branch information
gsemet committed Apr 22, 2015
1 parent ce9f882 commit d7e9ec3
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Verison 0.7.0:
- Add shortcut for transparency level (#481)
- Add label to tell user how to disable a shortcut (#488)
- Expose cursor_shape and blink cursor method in pref window (#505)
- some window management bug fixes (#506, #445)
- expose Guake startup script to the pref window (#198)

Version 0.6.2:
- Packaging issue fixes
Expand Down
47 changes: 46 additions & 1 deletion data/prefs.glade
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
<widget class="GtkTable" id="table5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkCheckButton" id="use_trayicon">
Expand Down Expand Up @@ -373,6 +373,51 @@
<property name="y_options"/>
</packing>
</child>
<child>
<widget class="GtkEntry" id="startup_script">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">Path to a bash script that would be automatically executed when guake starts, unless you specify --no-startup-script.

This would typically use the configuration by command line feature of guake:

#!/bin/bash

sleep 5 # it is advised to wait a bit guake has been successfully started

guake -r "main" -e "cd ~/projects/myproject/main"
guake -r "prod" -e "cd ~/projects/myproject/prod"
</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<signal name="changed" handler="on_startup_script_changed" swapped="no"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="lbl_startup_script">
<property name="width_request">160</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Path to script to execute on Guake start</property>
<property name="use_markup">True</property>
<property name="single_line_mode">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
Expand Down
4 changes: 2 additions & 2 deletions dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ fi

if [[ $NO_INSTALL == true ]]; then
gconftool-2 --install-schema-file=data/guake.schemas
PYTHONPATH=src python src/guake/main.py
PYTHONPATH=src python src/guake/main.py --no-startup-script
else
sudo make install && gconftool-2 --install-schema-file=/usr/local/etc/gconf/schemas/guake.schemas || exit 1

guake --quit 2> /dev/null
guake
guake --no-startup-script
fi
16 changes: 9 additions & 7 deletions src/guake/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def main():
action='store_true', default=False,
help=_('Says to Guake go away =('))

parser.add_option('-u', '--no-startup-script', dest='execute_startup_script',
action='store_false', default=True,
help=_('Do not execute the start up script'))

options = parser.parse_args()[0]

instance = None
Expand Down Expand Up @@ -196,23 +200,21 @@ def main():
remote_object.show_about()
only_show_hide = False

if options.quit:
remote_object.quit()
only_show_hide = False

if already_running and only_show_hide:
# here we know that guake was called without any parameter and
# it is already running, so, lets toggle its visibility.
remote_object.show_hide()

if not already_running:
if options.execute_startup_script and not already_running:
startup_script = instance.client.get_string(KEY("/general/startup_script"))
if startup_script:
print("Calling startup script: ", startup_script)
print("Calling startup script:", startup_script)
pid = subprocess.Popen([startup_script], shell=True, stdin=None, stdout=None,
stderr=None, close_fds=True)
print("Script started with pid", pid)
print("Startup script started with pid:", pid)
# Please ensure this is the last line !!!!
else:
print("--no-startup-script argument defined, so don't execute the startup script")
return already_running


Expand Down
6 changes: 6 additions & 0 deletions src/guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ def on_quick_open_enable_toggled(self, chk):
def on_quick_open_in_current_terminal_toggled(self, chk):
self.client.set_bool(KEY('/general/quick_open_in_current_terminal'), chk.get_active())

def on_startup_script_changed(self, edt):
self.client.set_string(KEY('/general/startup_script'), edt.get_text())

def on_window_losefocus_toggled(self, chk):
"""Changes the activity of window_losefocus in gconf
"""
Expand Down Expand Up @@ -769,6 +772,9 @@ def load_configs(self):
value = self.client.get_bool(KEY('/general/quick_open_in_current_terminal'))
self.get_widget('quick_open_in_current_terminal').set_active(value)

value = self.client.get_string(KEY('/general/startup_script'))
self.get_widget('startup_script').set_text(value)

# If Guake is configured to use a screen that is not currently attached,
# default to 'primary display' option.
screen = self.get_widget('config-window').get_screen()
Expand Down

0 comments on commit d7e9ec3

Please sign in to comment.