updated on Thu Jan 19 12:17:07 UTC 2012
[aur-mirror.git] / archinfo / archinfo.pl
blob979b8a08c467ed4e857e33bb3701ad5ab68113e8
1 #!/usr/bin/perl
2 # From http://bbs.archlinux.org/viewtopic.php?id=24208 #
4 use Switch;
5 use strict;
6 use File::Basename;
8 ####################
9 ## Config options ##
10 ####################
12 ## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ##
13 my $distro = "Archlinux";
14 my $myArchVersion = "ArchLinux (Core Dump)";
16 ## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ##
17 my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background";
19 ## Takes a screen shot if set to 0 ##
20 my $shot = 0;
21 ## Command to run to take screen shot ##
22 my $command = "scrot -d 10";
24 ## What colors to use for the variables. ##
25 my $textcolor = "\e[0m";
27 ## Prints little debugging messages if set to 0 ##
28 my $quite = 1;
32 ########################
33 ## Script starts here ##
34 ########################
35 ## Define some thing to work with strict ##
36 my @line = ();
37 my $found = 0;
38 my $DE = "NONE";
39 my $WM = "Beryl";
41 ## Hash of WMs and the process they run ##
42 my %WMlist = ("Beryl", "beryl",
43 "Fluxbox", "fluxbox",
44 "Openbox", "openbox",
45 "Blackbox", "blackbox",
46 "Xfwm4", "xfwm4",
47 "Metacity", "metacity",
48 "Kwin", "kwin",
49 "FVWM", "fvwm",
50 "Enlightenment", "enlightenment",
51 "IceWM", "icewm",
52 "Window Maker", "wmaker",
53 "PekWM","pekwm" );
55 ## Hash of DEs and the process they run ##
56 my %DElist = ("Gnome", "gnome-session",
57 "Xfce4", "xfce-mcs-manage",
58 "Xfce4.6", "xfconfd",
59 "KDE", "ksmserver");
61 ## Get Kernel version ##
62 if ( $display =~ "Kernel"){
63 print "\::$textcolor Finding Kernel version\n" unless $quite == 1;
64 my $kernel = `uname -r`;
65 $kernel =~ s/\s+/ /g;
66 $kernel = " Kernel:$textcolor $kernel";
67 push(@line, "$kernel");
70 ## Find running processes ##
71 print "\::$textcolor Getting processes \n" unless $quite == 1;
72 my $processes = `ps -A | awk {'print \$4'}`;
74 ## Find DE ##
75 while( (my $DEname, my $DEprocess) = each(%DElist) ) {
76 print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1;
77 if ( $processes =~ m/$DEprocess/ ) {
78 $DE = $DEname;
79 print "\::$textcolor DE found as $DE\n" unless $quite == 1;
80 if( $display =~ m/DE/ ) {
81 push(@line, " DE:$textcolor $DE");
83 last;
87 ## Find WM ##
88 while( (my $WMname, my $WMprocess) = each(%WMlist) ) {
89 print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1;
90 if ( $processes =~ m/$WMprocess/ ) {
91 $WM = $WMname;
92 print "\::$textcolor WM found as $WM\n" unless $quite == 1;
93 if( $display =~ m/WM/ ) {
94 push(@line, " WM:$textcolor $WM");
96 last;
100 ## Find WM theme ##
101 if ( $display =~ m/Win_theme/ ){
102 switch($WM) {
103 case "Openbox" {
104 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
105 open(FILE, "$ENV{HOME}/.config/openbox/rc.xml")
106 || die "\e[0;31m<Failed>\n";
107 while( <FILE> ) {
108 if( /<name>(.+)<\/name>/ ) {
109 while ( $found == 0 ) {
110 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
111 push(@line, " WM Theme:$textcolor $1");
112 $found = 1;
116 close(FILE);
118 case "Metacity" {
119 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
120 my $gconf = `gconftool-2 -g /apps/metacity/general/theme`;
121 print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1;
122 chomp ($gconf);
123 push(@line, " WM Theme:$textcolor $gconf");
125 case "Fluxbox" {
126 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
127 open(FILE, "$ENV{HOME}/.fluxbox/init")
128 || die "\e[0;31m<Failed>\n";
129 while( <FILE> ) {
130 if( /session.styleFile:.*\/(.+)/ ) {
131 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
132 push(@line, " WM Theme:$textcolor $1");
135 close(FILE);
137 case "Blackbox" {
138 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
139 open(FILE, "$ENV{HOME}/.blackboxrc")
140 || die "\e[0;31m<Failed>\n";
141 while( <FILE> ) {
142 if( /session.styleFile:.*\/(.+)/ ) {
143 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
144 push(@line, " WM Theme:$textcolor $1");
147 close(FILE);
149 case "Xfwm4" {
150 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
151 switch($DE) {
152 case "Xfce4" {
153 open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml")
154 || die "\e[0;31m<Failed>\n";
155 while( <FILE> ) {
156 if( /<option name="Xfwm\/ThemeName" type="string" value="(.+)"\/>/ ) {
157 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
158 push(@line, " WM Theme:$textcolor $1");
161 close(FILE);
163 case "Xfce4.6" {
164 my $xfconf = `xfconf-query -c xfwm4 -p /general/theme`;
165 chomp($xfconf);
166 push(@line, " WM Theme:$textcolor $xfconf");
170 case "Kwin" {
171 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
172 open(FILE, "$ENV{HOME}/.kde/share/config/kwinrc")
173 || die "\e[0;31m<Failed>\n";
174 while( <FILE> ) {
175 if( /PluginLib=kwin3_(.+)/ ) {
176 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
177 push(@line, " WM Theme:$textcolor $1");
180 close(FILE);
182 case "Enlightenment" {
183 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
184 my $remote = `enlightenment_remote -theme-get theme` ;
185 if( $remote =~ m/.*FILE="(.+).edj"/ ) {
186 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
187 push(@line, " WM Theme:$textcolor $1");
190 case "IceWM" {
191 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
192 open(FILE, "$ENV{HOME}/.icewm/theme")
193 || die "\e[0;31m<Failed>\n";
194 while( <FILE> ) {
195 if( /Theme="(.+)\/.*.theme/ ) {
196 while( $found == 0 ) {
197 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
198 push(@line, " WM Theme:$textcolor $1");
199 $found = 1;
203 close(FILE);
205 case "PekWM" {
206 print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
207 open(FILE, "$ENV{HOME}/.pekwm/config")
208 || die "\e[0;31m<Failed>\n";
209 while( <FILE> ) {
210 if( /Theme.*\/(.*)"/ ) {
211 print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
212 push(@line, " WM Theme:$textcolor $1");
215 close(FILE);
220 ## Find Theme Icon and Font ##
221 if ( $display =~ m/[Theme, Icons, Font, Background]/) {
222 switch($DE) {
223 case "Gnome" {
224 print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
225 if ( $display =~ m/Theme/ ) {
226 my $gconf = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
227 chomp ($gconf);
228 print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
229 push(@line, " GTK Theme:$textcolor $gconf");
231 if ( $display =~ m/Icons/ ) {
232 my $gconf = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
233 chomp ($gconf);
234 push(@line, " Icons:$textcolor $gconf");
236 if ( $display =~ m/Font/ ) {
237 my $gconf = `gconftool-2 -g /desktop/gnome/interface/font_name`;
238 chomp ($gconf);
239 push(@line, " Font:$textcolor $gconf");
241 if ( $display =~ m/Background/ ) {
242 my $gconf = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
243 chomp ($gconf);
244 my $bname = basename($gconf);
245 push(@line, " Background:$textcolor $bname");
249 case "Xfce4" {
250 my @sort = ();
251 print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
252 open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
253 || die "\e[0;31m<Failed>\n";
254 while( <FILE> ) {
255 if ( $display =~ m/Theme/ ) {
256 if (/<option name="Net\/ThemeName" type="string" value="(.+)"\/>/ ) {
257 print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
258 unshift(@sort, " GTK Theme:$textcolor $1");
261 if ( $display =~ m/Icons/ ) {
262 if (/<option name="Net\/IconThemeName" type="string" value="(.+)"\/>/ ) {
263 print "\::$textcolor Icons found as $1\n" unless $quite == 1;
264 unshift(@sort, " Icons:$textcolor $1");
267 if ( $display =~ m/Font/ ) {
268 if ( /<option name="Gtk\/FontName" type="string" value="(.+)"\/>/ ) {
269 print "\::$textcolor Font found as $1\n" unless $quite == 1;
270 unshift(@sort, " Font:$textcolor $1");
274 close(FILE);
275 ## Sort variables so they're ordered "Theme Icon Font" ##
276 foreach my $i (@sort) {
277 push(@line, "$i");
280 case "Xfce4.6" {
281 my @sort = ();
282 print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
283 if ( $display =~ m/Theme/ ) {
284 my $xfconf = `xfconf-query -c xsettings -p /Net/ThemeName`;
285 chomp($xfconf);
286 push(@line, " GTK Theme:$textcolor $xfconf");
288 if ( $display =~ m/Icons/ ) {
289 my $xfconf = `xfconf-query -c xsettings -p /Net/IconThemeName`;
290 chomp($xfconf);
291 push(@line, " Icons:$textcolor $xfconf");
293 if ( $display =~ m/Font/ ) {
294 my $xfconf = `xfconf-query -c xsettings -p /Gtk/FontName`;
295 chomp($xfconf);
296 push(@line, " Font:$textcolor $xfconf");
298 if ( $display =~ m/Background/ ) {
299 my $xfconf = `xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path`;
300 chomp($xfconf);
301 my $bname = basename($xfconf);
302 push(@line, " Background:$textcolor $bname");
305 case "KDE" {
306 print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
307 open(FILE, "$ENV{HOME}/.kde/share/config/kdeglobals")
308 || die "\e[0;31m<Failed>\n";
309 while( <FILE> ) {
310 if ( $display =~ m/Theme/ ) {
311 if ( /widgetStyle=(.+)/ ) {
312 print "\::$textcolor Wiget Style found as $1\n" unless $quite == 1;
313 push(@line, " Wiget Style:$textcolor $1");
315 if (/colorScheme=(.+).kcsrc/ ) {
316 print "\::$textcolor Color Scheme found as $1\n" unless $quite == 1;
317 push(@line, " Color Scheme:$textcolor $1");
320 if ( $display =~ m/Icons/ ) {
321 if ( /Theme=(.+)/ ) {
322 print "\::$textcolor Icons found as $1\n" unless $quite == 1;
323 push(@line, " Icons:$textcolor $1");
326 if ( $display =~ m/Font/ ) {
327 if ( /font=(.+)/ ) {
328 my $font = (split/,/, $1)[0];
329 print "\::$textcolor Font found as $font\n" unless $quite == 1;
330 push(@line, " Font:$textcolor $font");
334 close(FILE);
337 else {
338 my @files = ("$ENV{HOME}/.gtkrc-2.0", "$ENV{HOME}/.gtkrc.mine",);
339 foreach my $file (@files) {
340 if ( -e $file ) {
341 print "\::$textcolor Opening $file\n" unless $quite == 1;
342 open(FILE, $file)
343 || die "\e[0;31m<Failed>\n";
344 while( <FILE> ) {
345 if ( $display =~ m/Theme/ ) {
346 if( /include ".*themes\/(.+)\/gtk-(1|2)\.0\/gtkrc"/ ){
347 print "\::$textcolor GTK theme found as $1\n" unless $quite == 1;
348 push(@line, " GTK Theme:$textcolor $1");
351 if ( $display =~ m/Icons/ ) {
352 if( /.*gtk-icon-theme-name.*"(.+)"/ ) {
353 print "\::$textcolor Icons found as $1\n" unless $quite == 1;
354 push(@line, " Icons:$textcolor $1");
357 if ( $display =~ m/Font/ ) {
358 if( /.*gtk-font-name.*"(.+)"/ ) {
359 print "\::$textcolor Font found as $1\n" unless $quite == 1;
360 push(@line, " Font:$textcolor $1");
364 close(FILE);
371 ## Display the system info ##
373 if ( $distro =~ m/Archlinux/ ) {
375 ## Get Archlinux version ##
376 if ( $display =~ "OS"){
377 print "\::$textcolor Finding Archlinux version\n" unless $quite == 1;
378 my $version = $myArchVersion;
379 $version =~ s/\s+/ /g;
380 $version = " OS:$textcolor $version";
381 unshift(@line, "$version");
384 my $c1 = "\e[1;36m";
385 my $c2 = "\e[0;36m";
387 system("clear");
389 print "
390 ${c1} -`
391 ${c1} .o+`
392 ${c1} `ooo/
393 ${c1} `+oooo:
394 ${c1} `+oooooo:
395 ${c1} -+oooooo+:
396 ${c1} `/:-:++oooo+: $c1@line[0]
397 ${c1} `/++++/+++++++: $c1@line[1]
398 ${c1} `/++++++++++++++: $c1@line[2]
399 ${c1} `/+++${c2}ooooooooooooo/` $c1@line[3]
400 ${c2} ./ooosssso++osssssso+` $c1@line[4]
401 ${c2} .oossssso-````/ossssss+` $c1@line[5]
402 ${c2} -osssssso. :ssssssso. $c1@line[6]
403 ${c2} :osssssss/ osssso+++. $c1@line[7]
404 ${c2} /ossssssss/ +ssssooo/- $c1@line[8]
405 ${c2} `/ossssso+/:- -:/+osssso+-
406 ${c2} `+sso+:-` `.-/+oso:
407 ${c2} `++:. `-/+/
408 ${c2} .` ``
409 ${c2}
410 \e[0m";
413 system("scrot -d 1");