forked from perseo22/pacmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pac
executable file
·123 lines (103 loc) · 4.76 KB
/
pac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl
###################################################################
# This file is part of PAC( Perl Auto Connector)
#
# Copyright (C) 2010-2016 David Torrejon Vaquerizas
#
# 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/>.
###################################################################
$|++;
BEGIN {
if ( grep( { /^-{1,2}(help|h)$/gi } @ARGV ) ) {
print "\n";
print "Usage: pac [options]\n";
print "Options:\n";
print "\t--help : this help\n";
print "\t--no-backup : do no create alternative PAC config files as a backup (faster shutdown)\n";
print "\t--start-shell : start a local terminal\n";
print "\t--password=<pwd> : automatically logon with given password without prompting user\n";
print "\t--start-uuid=<uuid>[:<cluster] : start connection in cluster (if given)\n";
print "\t--edit-uuid=<uuid> : edit connection\n";
print "\t--dump-uuid=<uuid> : dump data for given connection\n";
print "\t--scripts : open scripts window\n";
print "\t--start-script=<script> : start given script\n";
print "\t--preferences : open global preferences dialog\n";
print "\t--quick-conn : open the Quick Connect dialog on startup\n";
print "\t--list-uuids : list existing connections/groups and their UUIDs\n";
print "\t--no-splash : no splash screen on startup\n";
print "\t--iconified : make PAC go to tray once started\n";
print "\t--readonly : start PAC in read only mode (no config changes allowed)\n";
print "\n";
print "See 'man pac' for more info.\n";
print "\n";
exit 0;
}
}
###################################################################
# START: Import Modules
use FindBin qw ( $RealBin $Bin $Script );
use lib $RealBin . '/lib', $RealBin . '/lib/ex', $RealBin . '/lib/edit';
use File::Copy;
# Standard
use strict;
use warnings;
use PACMain;
# END: Import Modules
###################################################################
###################################################################
# START: Define GLOBAL variables
my $INIT_CFG_FILE = $RealBin . '/res/pac.yml';
my $CFG_DIR = $ENV{'HOME'} . '/.config/pac';
my $OLD_CFG_DIR = $ENV{'HOME'} . '/.pac';
my $CFG_FILE = $CFG_DIR . '/pac.cfg';
my $PAC;
# END: Define GLOBAL variables
###################################################################
###################################################################
# START: MAIN program
print "PAC started ($Script) with PID $$\n";
# Check for Unity's systray-whitelist presence of 'pac'
my $wl = `gsettings get com.canonical.Unity.Panel systray-whitelist 2>/dev/null`;
chomp $wl;
if ( ( $? eq 0 ) && ( ! grep( /'pac'/, $wl ) ) ) {
print " - Adding 'pac' to Unity's 'systray-whitelist'\n";
$wl =~ s/'\s*]/', 'pac']/;
`gsettings set com.canonical.Unity.Panel systray-whitelist "$wl"`;
}
# Check for the existance of some directories
-d $ENV{'HOME'} . '/.config' or mkdir( $ENV{'HOME'} . '/.config' );
-d $ENV{'HOME'} . '/.config/autostart' or mkdir( $ENV{'HOME'} . '/.config/autostart' );
# Move old $HOME/.pac/ config dir to new location $HOME/.config/pac/
( ( ! -d $CFG_DIR ) && ( -d $OLD_CFG_DIR ) ) and system( "mv $OLD_CFG_DIR $CFG_DIR" );
( -d $CFG_DIR || -l $CFG_DIR ) or mkdir( $CFG_DIR );
-d $CFG_DIR . '/screenshots' or mkdir( $CFG_DIR . '/screenshots' );
-d $CFG_DIR . '/session_logs' or mkdir( $CFG_DIR . '/session_logs' );
-d $CFG_DIR . '/sockets' or mkdir( $CFG_DIR . '/sockets' );
-d $CFG_DIR . '/tmp' or mkdir( $CFG_DIR . '/tmp' );
-d $CFG_DIR . '/scripts' or mkdir( $CFG_DIR . '/scripts' );
-d $CFG_DIR . '/scripts/sample1.pl' or copy( $RealBin . '/res/sample1.pl', $CFG_DIR . '/scripts/' );
-d $CFG_DIR . '/scripts/sample2.pl' or copy( $RealBin . '/res/sample2.pl', $CFG_DIR . '/scripts/' );
-d $CFG_DIR . '/scripts/sample3.pl' or copy( $RealBin . '/res/sample3.pl', $CFG_DIR . '/scripts/' );
-d $CFG_DIR . '/scripts/sample4.pl' or copy( $RealBin . '/res/sample4.pl', $CFG_DIR . '/scripts/' );
# Start PAC!!
if ( ! ( $PAC = PACMain -> new( @ARGV ) ) ) {
print STDERR "PAC not starting. PAC already running?\n";
exit 0
}
#use Data::Dumper; print Dumper( PACUtils::_getXWindowsList );
$PAC -> start;
print "Finished $Script (PID:$$)...\n";
exit 0;
# END: MAIN program
###################################################################