#!/usr/bin/perl # http://bbs.archlinux.org/viewtopic.php?pid=395002 use Switch; use strict; use File::Basename; #################### ## Config options ## #################### ## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ## my $distro = "Archlinux"; my $myArchVersion = "ArchLinux (Core Dump)"; ## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ## my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background"; ## Takes a screen shot if set to 0 ## my $shot = 0; ## Command to run to take screen shot ## my $command = "scrot -d 10"; ## What colors to use for the variables. ## my $textcolor = "\e[0m"; ## Prints little debugging messages if set to 0 ## my $quite = 1; ######################## ## Script starts here ## ######################## ## Define some thing to work with strict ## my @line = (); my $found = 0; my $DE = "NONE"; my $WM = "Beryl"; ## Hash of WMs and the process they run ## my %WMlist = ("Beryl", "beryl", "Fluxbox", "fluxbox", "Openbox", "openbox", "Blackbox", "blackbox", "Xfwm4", "xfwm4", "Metacity", "metacity", "Kwin", "kwin", "FVWM", "fvwm", "Enlightenment", "enlightenment", "IceWM", "icewm", "Window Maker", "wmaker", "PekWM","pekwm" ); ## Hash of DEs and the process they run ## my %DElist = ("Gnome", "gnome-session", "Xfce4", "xfce-mcs-manage", "KDE", "ksmserver"); ## Get Kernel version ## if ( $display =~ "Kernel"){ print "\::$textcolor Finding Kernel version\n" unless $quite == 1; my $kernel = `uname -r`; $kernel =~ s/\s+/ /g; $kernel = " Kernel:$textcolor $kernel"; push(@line, "$kernel"); } ## Find running processes ## print "\::$textcolor Getting processes \n" unless $quite == 1; my $processes = `ps -A | awk {'print \$4'}`; ## Find DE ## while( (my $DEname, my $DEprocess) = each(%DElist) ) { print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1; if ( $processes =~ m/$DEprocess/ ) { $DE = $DEname; print "\::$textcolor DE found as $DE\n" unless $quite == 1; if( $display =~ m/DE/ ) { push(@line, " DE:$textcolor $DE"); } last; } } ## Find WM ## while( (my $WMname, my $WMprocess) = each(%WMlist) ) { print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1; if ( $processes =~ m/$WMprocess/ ) { $WM = $WMname; print "\::$textcolor WM found as $WM\n" unless $quite == 1; if( $display =~ m/WM/ ) { push(@line, " WM:$textcolor $WM"); } last; } } ## Find WM theme ## if ( $display =~ m/Win_theme/ ){ switch($WM) { case "Openbox" { print "\::$textcolor Finding $WM theme\n" unless $quite == 1; open(FILE, "$ENV{HOME}/.config/openbox/rc.xml") || die "\e[0;31m\n"; while( ) { if( /(.+)<\/name>/ ) { while ( $found == 0 ) { print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; push(@line, " WM Theme:$textcolor $1"); $found = 1; } } } close(FILE); } case "Metacity" { print "\::$textcolor Finding $WM theme\n" unless $quite == 1; my $gconf = `gconftool-2 -g /apps/metacity/general/theme`; print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1; chomp ($gconf); push(@line, " WM Theme:$textcolor $gconf"); } case "Fluxbox" { print "\::$textcolor Finding $WM theme\n" unless $quite == 1; open(FILE, "$ENV{HOME}/.fluxbox/init") || die "\e[0;31m\n"; while( ) { if( /session.styleFile:.*\/(.+)/ ) { print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; push(@line, " WM Theme:$textcolor $1"); } } close(FILE); } case "Blackbox" { print "\::$textcolor Finding $WM theme\n" unless $quite == 1; open(FILE, "$ENV{HOME}/.blackboxrc") || die "\e[0;31m\n"; while( ) { if( /session.styleFile:.*\/(.+)/ ) { print "\::$textcolor $WM theme found as $1\n" unless $quite == 1; push(@line, " WM Theme:$textcolor $1"); } } close(FILE); } case "Xfwm4" { print "\::$textcolor Finding $WM theme\n" unless $quite == 1; open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml") || die "\e[0;31m\n"; while( ) { if( /