Skip to content

Commit

Permalink
Add option to start minimized
Browse files Browse the repository at this point in the history
Fixes #681: you can start Terminal minimized. Handy when starting 
Terminal with a command at login time, but you don't want a window to be
displayed.
  • Loading branch information
stan-janssen committed Mar 28, 2023
1 parent cba3358 commit 7795c4b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class Terminal.Application : Gtk.Application {
public int minimum_width;
public int minimum_height;
private bool minimized = false;

private string commandline = "\0"; // used to temporary hold the argument to --commandline=
private uint dbus_id = 0;
Expand Down Expand Up @@ -38,6 +39,8 @@ public class Terminal.Application : Gtk.Application {
add_main_option ("working-directory", 'w', 0, OptionArg.FILENAME, _("Set shell working directory"), "DIR");
// -e flag is used for running single strings as a command line
add_main_option ("execute", 'e', 0, OptionArg.FILENAME_ARRAY, _("Run a program in terminal"), "PROGRAM");
// -m flag starts terminal in a minimized state
add_main_option ("minimized", 'm', 0, OptionArg.NONE, _("Open terminal in a minimized state"), null);
// -x flag is used for using the rest of the command line in the new tab/window
add_main_option (
"commandline", 'x', 0, OptionArg.FILENAME, _("Run remainder of line as a command in terminal"), "COMMAND"
Expand Down Expand Up @@ -127,6 +130,10 @@ public class Terminal.Application : Gtk.Application {
options.insert ("commandline", "^&ay", commandline.escape ());
}

if (options.contains ("minimized")) {
minimized = true;
}

return -1;
}

Expand Down Expand Up @@ -214,7 +221,11 @@ public class Terminal.Application : Gtk.Application {
window.add_tab_with_working_directory (working_directory, null, new_tab);
}

window.present ();
if (minimized) {
window.iconify ();
} else {
window.present ();
}
return 0;
}

Expand Down

0 comments on commit 7795c4b

Please sign in to comment.