diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2005-07-27 08:08:05 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2005-07-27 08:08:05 +0000 |
commit | f4f246d4a12ce137e1e73b8c0d590da3d9337b5f (patch) | |
tree | 87fe6a5fff61ba70a489710837010150c7d203b6 /perl-install/standalone | |
parent | 4cb36e102e377ddfd1cdd52d8edce3141518183e (diff) | |
download | drakx-backup-do-not-use-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar drakx-backup-do-not-use-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.gz drakx-backup-do-not-use-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.bz2 drakx-backup-do-not-use-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.xz drakx-backup-do-not-use-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.zip |
- Started implementation of configurable, partially interactive print
queue auto setup.
Diffstat (limited to 'perl-install/standalone')
-rwxr-xr-x | perl-install/standalone/autosetupprintqueues | 53 | ||||
-rwxr-xr-x | perl-install/standalone/printerdrake | 12 |
2 files changed, 55 insertions, 10 deletions
diff --git a/perl-install/standalone/autosetupprintqueues b/perl-install/standalone/autosetupprintqueues index 3b72980f7..c8c3d54fd 100755 --- a/perl-install/standalone/autosetupprintqueues +++ b/perl-install/standalone/autosetupprintqueues @@ -24,25 +24,62 @@ use standalone; use printer::printerdrake; use printer::main; +# Read mode in which we will run +my $commandline = join('', @ARGV); +$commandline =~ /-(auto|nogui|gui|waitforgui)\b/; +my $gui = $1; +$gui ||= "auto"; + +if ($gui ne "nogui") { + # Auto-detect whether we go in non-X mode or not + my $desktopuser = `cat /var/run/console.lock`; + if (!$desktopuser) { + if ($gui eq "auto") { + # Non-X mode + $gui = "nogui"; + } elsif ($gui eq "waitforgui") { + # Wait until a user logs in on the system's X console + while (!($desktopuser = `cat /var/run/console.lock`)) { + sleep(5); + } + # Wait for the window manager to start + sleep(10); + $gui = "gui"; + } else { + # "gui" was requested but no user logged in + die "Cannot start in '--gui' mode, no user logged in!\n"; + } + } else { + # X mode (a user is logged in) + $gui = "gui"; + } + + if ($gui eq "gui") { + # Allow root's windows to be opened on the user's display and + # start printerdrake then, in a mode to do nothing else than + # automatically setting up print queues. + system "export DISPLAY=\"localhost:0.0\"; USER=$desktopuser; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost +localhost > /tmp/pderror 2>&1\"; /usr/sbin/printerdrake --onlyautoqueue >> /tmp/pderror 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost -localhost >> /tmp/pderror 2>&1\""; + exit 0; + } +} + # Data structure for printer data my $printer; -# Dummy variable needed to call the subroutines of the printerdrak.pm module -# The real data structure is not needed for non-interactive mode +# Dummy variable needed to call the subroutines of the printerdrake.pm +# module. The real data structure is not needed for non-interactive +# non-X mode my $in; # Run the subroutines of printerdrake.pm in non-interactive non-X mode $::noX = 1; +# Subroutines of printerdrake.pm used for automatic setup of print queues +$::autoqueue = 1; + # Do not let printerdrake ask for the spooler $printer->{SPOOLER} ||= 'cups'; -# Were we in expert mode last time? -$printer->{expert} = printer::main::get_usermode(); - -# Do not auto-install queues in expert mode -exit 0 if $printer->{expert}; - # Get info about already installed print queues eval { $printer = printer::main::getinfo('') }; diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake index be0716c79..2c4cc8eb2 100755 --- a/perl-install/standalone/printerdrake +++ b/perl-install/standalone/printerdrake @@ -57,6 +57,10 @@ my $in = 'interactive'->vnew('su', if_(!$::isEmbedded, 'printer-mdk')); my $commandline = $_; +# Suppress some wait messages to avoid windows popping up if no new print +# queue has to be set up +$commandline =~ /-onlyautoqueue/ and $::autoqueue = 1; + # Data structure for GTK2 main window my $us = {}; $us->{VERSION} = '10.2'; @@ -64,8 +68,9 @@ $us->{VERSION} = '10.2'; # Check whether Foomatic is installed and install it if necessary #printer::printerdrake::install_foomatic($in); -my $w = $in->wait_message(N("Printerdrake"), - N("Reading data of installed printers...")); +my $w = $::autoqueue || + $in->wait_message(N("Printerdrake"), + N("Reading data of installed printers...")); # Get what was installed before eval { $printer = printer::main::getinfo('') }; @@ -107,6 +112,9 @@ $printer->{SPOOLER} ||= 'cups'; # Initialization printer::printerdrake::init($printer, $security, $in, undef); +# Stop here when we are supposed to only automatically set up print queues +$commandline =~ /-onlyautoqueue/ and exit 0; + # GTK2 main window my $stringsearch = ''; |