CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by patrickstein on Fri 21st Aug 19:19 (modification of post by view diff)
download | new post

  1. #!/usr/bin/perl
  2. use Switch;
  3. use strict;
  4. use File::Basename;
  5.  
  6. ####################
  7. ## Config options ##
  8. ####################
  9.  
  10. ## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ##
  11. my $distro = "Ubuntu";
  12.  
  13. ## what values to display. Use "OS Kernel DE WM win_theme Theme Font Icons" ##
  14. my $display = "OS Kernel DE WM Win_theme Theme Icons Font Background";
  15.  
  16. ## Takes a screen shot if set to 0 ##
  17. my $shot = 1;
  18. ## Command to run to take screen shot ##
  19. my $command = "scrot -d 3";
  20.  
  21. ## What colors to use for the variables. ##
  22. my $textcolor = "\e[0m";
  23.  
  24. ## Prints little debugging messages if set to 0 ##
  25. my $quite = 1;
  26.  
  27.  
  28.  
  29. ########################
  30. ## Script starts here ##
  31. ########################
  32. ## Define some thing to work with strict ##
  33. my @line = ();
  34. my $found = 0;
  35. my $DE = "NONE";
  36. my $WM = "NONE";
  37.  
  38. ## Hash of WMs and the process they run ##
  39. my %WMlist = ("Beryl", "beryl",
  40.               "Compiz", "compiz",
  41.               "Emerald", "emerald",
  42.               "Fluxbox", "fluxbox",
  43.               "Openbox", "openbox",
  44.               "Blackbox", "blackbox",
  45.               "Xfwm4", "xfwm4",
  46.               "Metacity", "metacity",
  47.               "Kwin", "kwin",
  48.               "FVWM", "fvwm",
  49.               "Enlightenment", "enlightenment",
  50.               "IceWM", "icewm",
  51.               "Window Maker", "wmaker",
  52.               "PekWM","pekwm" );
  53.  
  54. ## Hash of DEs and the process they run ##     
  55. my %DElist = ("Gnome", "gnome-panel",
  56.               "Xfce4", "xfce-mcs-manage",
  57.               "KDE", "ksmserver");
  58.  
  59. ## Get Kernel version ##
  60. if ( $display =~ "Kernel"){
  61.   print "\::$textcolor Finding Kernel version\n" unless $quite == 1;
  62.   my $kernel = `uname -r`;
  63.   $kernel =~ s/\s+/ /g;
  64.   $kernel = " Kernel:$textcolor $kernel";
  65.   push(@line, "$kernel");
  66. }
  67.  
  68. ## Find running processes ##
  69. print "\::$textcolor Getting processes \n" unless $quite == 1;
  70. my $processes = `ps -A | awk {'print \$4'}`;
  71.  
  72. ## Find DE ##
  73. while( (my $DEname, my $DEprocess) = each(%DElist) ) {
  74.   print "\::$textcolor Testing $DEname process: $DEprocess \n" unless $quite == 1;
  75.   if ( $processes =~ m/$DEprocess/ ) {
  76.     $DE = $DEname;
  77.     print "\::$textcolor DE found as $DE\n" unless $quite == 1;
  78.     if( $display =~ m/DE/ ) {
  79.       push(@line, " DE:$textcolor $DE");
  80.     }
  81.     last;
  82.   }
  83. }
  84.  
  85. ## Find WM ##
  86. while( (my $WMname, my $WMprocess) = each(%WMlist) ) {
  87.  print "\::$textcolor Testing $WMname process: $WMprocess \n" unless $quite == 1;
  88.   if ( $processes =~ m/$WMprocess/ ) {
  89.     $WM = $WMname;
  90.     print "\::$textcolor WM found as $WM\n" unless $quite == 1;
  91.     if( $display =~ m/WM/ ) {
  92.       push(@line, " WM:$textcolor $WM");
  93.     }
  94.     last;
  95.   }
  96. }
  97.  
  98. ## Find WM theme ##
  99. if ( $display =~ m/Win_theme/ ){
  100.   switch($WM) {
  101.     case "Openbox" {
  102.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  103.       open(FILE, "$ENV{HOME}/.config/openbox/rc.xml")
  104.       || die "\e[0;31m<Failed>\n";
  105.       while( <FILE> ) {
  106.         if( /<name>(.+)<\/name>/ ) {
  107.           while ( $found == 0 ) {
  108.             print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  109.             push(@line, " WM Theme:$textcolor $1");
  110.             $found = 1;
  111.           }
  112.         }
  113.       }
  114.       close(FILE);
  115.     }
  116.     case "Compiz" {
  117. # commented for Heliodor
  118. #      print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  119. #      open(FILE, "$ENV{HOME}/.emerald/themes/Azurite-22px/theme.ini")
  120. #      || die "\e[0;31m<Failed>\n";
  121. #      while( <FILE> ) {
  122. #        if( /name=(.+)/ ) {
  123. #          print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  124. #          push(@line, " WM Theme:$textcolor $1");
  125. #        }
  126. #      }
  127. #      close(FILE);
  128. # Get the heliodor(metacity) theme
  129.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  130.       my $gconf = `gconftool-2 -g /apps/metacity/general/theme`;
  131.       print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1;
  132.       chomp ($gconf);
  133.       push(@line, " GWD Theme:$textcolor $gconf");
  134.         }
  135.     case "Metacity" {
  136.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  137.       my $gconf = `gconftool-2 -g /apps/metacity/general/theme`;
  138.       print "\::$textcolor $WM theme found as $gconf\n" unless $quite == 1;
  139.       chomp ($gconf);
  140.       push(@line, " WM Theme:$textcolor $gconf");
  141.     }
  142.     case "Fluxbox" {
  143.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  144.       open(FILE, "$ENV{HOME}/.fluxbox/init")
  145.       || die "\e[0;31m<Failed>\n";
  146.       while( <FILE> ) {
  147.         if( /session.styleFile:.*\/(.+)/ ) {
  148.           print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  149.           push(@line, " WM Theme:$textcolor $1");
  150.         }
  151.       }
  152.       close(FILE);
  153.     }
  154.     case "Blackbox" {
  155.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  156.       open(FILE, "$ENV{HOME}/.blackboxrc")
  157.       || die "\e[0;31m<Failed>\n";
  158.       while( <FILE> ) {
  159.         if( /session.styleFile:.*\/(.+)/ ) {
  160.           print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  161.           push(@line, " WM Theme:$textcolor $1");
  162.         }
  163.       }
  164.       close(FILE);
  165.     }
  166.     case "Xfwm4" {
  167.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  168.       open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml")
  169.       || die "\e[0;31m<Failed>\n";
  170.       while( <FILE> ) {
  171.         if( /<option name="Xfwm\/ThemeName" type="string" value="(.+)"\/>/ ) {
  172.           print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  173.           push(@line, " WM Theme:$textcolor $1");
  174.         }
  175.   }
  176.       close(FILE);
  177.     }
  178.     case "Kwin" {
  179.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  180.       open(FILE, "$ENV{HOME}/.kde/share/config/kwinrc")
  181.       || die "\e[0;31m<Failed>\n";
  182.       while( <FILE> ) {
  183.         if( /PluginLib=kwin3_(.+)/ ) {
  184.           print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  185.           push(@line, " WM Theme:$textcolor $1");
  186.         }
  187.       }
  188.       close(FILE);
  189.     }
  190.     case "Enlightenment" {
  191.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  192.       my $remote = `enlightenment_remote -theme-get theme` ;
  193.       if( $remote =~ m/.*FILE="(.+).edj"/ ) {
  194.         print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  195.         push(@line, " WM Theme:$textcolor $1");
  196.       }     
  197.     }       
  198.     case "IceWM" {
  199.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  200.       open(FILE, "$ENV{HOME}/.icewm/theme")
  201.       || die "\e[0;31m<Failed>\n";
  202.       while( <FILE> ) {
  203.         if( /Theme="(.+)\/.*.theme/ ) {
  204.           while( $found == 0 ) {
  205.             print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  206.             push(@line, " WM Theme:$textcolor $1");
  207.             $found = 1;
  208.           }
  209.         }
  210.       }   
  211.       close(FILE);
  212.     }   
  213.     case "PekWM" {
  214.       print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
  215.       open(FILE, "$ENV{HOME}/.pekwm/config")
  216.       || die "\e[0;31m<Failed>\n";
  217.       while( <FILE> ) {
  218.         if( /Theme.*\/(.*)"/ ) {
  219.             print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
  220.             push(@line, " WM Theme:$textcolor $1");
  221.         }
  222.       }
  223.       close(FILE);
  224.     }
  225.   }   
  226. }     
  227.      
  228. ## Find Theme Icon and Font ##
  229. if ( $display =~ m/[Theme, Icons, Font, Background]/) {
  230.   switch($DE) {
  231.     case "Gnome" {
  232.       print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
  233.       if ( $display =~ m/Theme/ ) {
  234.         my $gconf = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
  235.         chomp ($gconf);
  236.         print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
  237.         push(@line, " GTK Theme:$textcolor $gconf");
  238.       }
  239.       if ( $display =~ m/Icons/ ) {
  240.         my $gconf = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
  241.         chomp ($gconf);
  242.         push(@line, " Icons:$textcolor $gconf");
  243.       }
  244.       if ( $display =~ m/Font/ ) {
  245.         my $gconf = `gconftool-2 -g /desktop/gnome/interface/font_name`;
  246.         chomp ($gconf);
  247.         push(@line, " Font:$textcolor $gconf");
  248.       }
  249.           if ( $display =~ m/Background/ ) {
  250.         my $gconf = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
  251.         chomp ($gconf);
  252.                 my $bname = basename($gconf);
  253.                 push(@line, " Background:$textcolor $bname");
  254.       }
  255.  
  256.     }
  257.     case "Xfce4" {
  258.       my @sort = ();
  259.       print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
  260.       open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
  261.       || die "\e[0;31m<Failed>\n";
  262.       while( <FILE> ) {
  263.      if ( $display =~ m/Theme/ ) {
  264.           if (/<option name="Net\/ThemeName" type="string" value="(.+)"\/>/ ) {
  265.             print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
  266.             unshift(@sort, " GTK Theme:$textcolor $1");
  267.           }
  268.         }
  269.         if ( $display =~ m/Icons/ ) {
  270.           if (/<option name="Net\/IconThemeName" type="string" value="(.+)"\/>/ ) {
  271.             print "\::$textcolor Icons found as $1\n" unless $quite == 1;
  272.             unshift(@sort, " Icons:$textcolor $1");
  273.           }
  274.         }
  275.         if ( $display =~ m/Font/ ) {
  276.           if ( /<option name="Gtk\/FontName" type="string" value="(.+)"\/>/ ) {
  277.             print "\::$textcolor Font found as $1\n" unless $quite == 1;
  278.             unshift(@sort, " Font:$textcolor $1");
  279.           }
  280.         }
  281.       }
  282.       close(FILE);
  283.       ## Sort variables so they're ordered "Theme Icon Font" ##
  284.       foreach my $i (@sort) {
  285.         push(@line, "$i");
  286.       }
  287.     }
  288.     case "KDE" {
  289.       print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
  290.       open(FILE, "$ENV{HOME}/.kde/share/config/kdeglobals")
  291.       || die "\e[0;31m<Failed>\n";
  292.       while( <FILE> ) {
  293.         if ( $display =~ m/Theme/ ) {
  294.           if ( /widgetStyle=(.+)) {
  295.             print "\::$textcolor Wiget Style found as $1\n" unless $quite == 1;
  296.             push(@line, " Wiget Style:$textcolor $1");
  297.           }
  298.           if (/colorScheme=(.+).kcsrc/ ) {
  299.             print "\::$textcolor Color Scheme found as $1\n" unless $quite == 1;
  300.             push(@line, " Color Scheme:$textcolor $1");
  301.           }
  302.         }
  303.         if ( $display =~ m/Icons/ ) {
  304.           if ( /Theme=(.+)/ ) {
  305.             print "\::$textcolor Icons found as $1\n" unless $quite == 1;
  306.             push(@line, " Icons:$textcolor $1");
  307.           }
  308.         }   
  309.         if ( $display =~ m/Font/ ) {
  310.           if ( /font=(.+)/ ) {
  311.             my $font = (split/,/, $1)[0];
  312.             print "\::$textcolor Font found as $font\n" unless $quite == 1;
  313.             push(@line, " Font:$textcolor $font");
  314.           }
  315.         }
  316.       }
  317.       close(FILE);
  318.  
  319.     }
  320.     else {
  321.       my @files = ("$ENV{HOME}/.gtkrc-2.0", "$ENV{HOME}/.gtkrc.mine",);
  322.       foreach my $file (@files) {
  323.         if ( -e $file ) {
  324.           print "\::$textcolor Opening $file\n" unless $quite == 1;
  325.           open(FILE, $file)
  326.           || die "\e[0;31m<Failed>\n";
  327.           while( <FILE> ) {
  328.             if ( $display =~ m/Theme/ ) {
  329.               if( /include ".*themes\/(.+)\/gtk-(1|2)\.0\/gtkrc"/ ){
  330.                 print "\::$textcolor GTK theme found as $1\n" unless $quite == 1;
  331.                 push(@line, " GTK Theme:$textcolor $1");
  332.               }
  333.             }
  334.             if ( $display =~ m/Icons/ ) {
  335.               if( /.*gtk-icon-theme-name.*"(.+)"/ ) {
  336.                 print "\::$textcolor Icons found as $1\n" unless $quite == 1;
  337.                 push(@line, " Icons:$textcolor $1");
  338.               }
  339.             }
  340.             if ( $display =~ m/Font/ ) {
  341.               if( /.*gtk-font-name.*"(.+)"/ ) {
  342.                 print "\::$textcolor Font found as $1\n" unless $quite == 1;
  343.                 push(@line, " Font:$textcolor $1");
  344.              }
  345.             }
  346.           }
  347.           close(FILE);
  348.         }
  349.       }
  350.     }
  351.   }
  352. }
  353.  
  354. ## Display the system info ##
  355.  
  356. if ( $distro =~ m/Archlinux/ ) {
  357.  
  358. ## Get Archlinux version ##
  359. if ( $display =~ "OS"){
  360.   print "\::$textcolor Finding Archlinux version\n" unless $quite == 1;
  361.   my $version = `cat /etc/arch-release`;
  362.   $version =~ s/\s+/ /g;
  363.   $version = " OS:$textcolor $version";
  364.   unshift(@line, "$version");
  365. }
  366.  
  367. my $c1 = "\e[0;32m";
  368. my $c2 = "\e[1;32m";
  369.  
  370. print "$c1              __
  371. $c1          _=(SDGJT=_
  372. $c1        _GTDJHGGFCVS)                $c1@line[0]
  373. $c1       ,GTDJGGDTDFBGX0               $c1@line[1]
  374. $c1      JDJDIJHRORVFSBSVL$c2-=+=,_        $c1@line[2]
  375. $c1     IJFDUFHJNXIXCDXDSV,$c2  \"DEBL      $c1@line[3]
  376. $c1    [LKDSDJTDU=OUSCSBFLD.$c2   '?ZWX,   $c1@line[4]
  377. $c1   ,LMDSDSWH'     \`DCBOSI$c2     DRDS], $c1@line[5]
  378. $c1   SDDFDFH'         !YEWD,$c2   )HDROD  $c1@line[6]
  379. $c1  !KMDOCG            &GSU|$c2\_GFHRGO'   $c1@line[7]
  380. $c1  HKLSGP'$c2           __$c1\TKM0$c2\GHRBV)'    $c1@line[8]
  381. $c1 JSNRVW'$c2       __+MNAEC$c1\IOI,$c2\BN'
  382. $c1 HELK['$c2    __,=OFFXCBGHC$c1\FD)
  383. $c1 ?KGHE $c2\_-#DASDFLSV='$c1    'EF
  384. $c1 'EHTI                   !H
  385. $c1  \`0F'                   '!
  386. \e[0m";
  387. }
  388.  
  389.  
  390. if ( $distro =~ m/None/ ) {
  391. my $color = "\e[0;34m";
  392.   foreach my $filled ( @line ) {
  393.     print "$color $filled\n"
  394.   }
  395. }
  396.  
  397. if ( $distro =~ m/Debian/ ) {
  398.  
  399. ## Get Debian version ##
  400. if ( $display =~ "OS"){
  401.   print "\::$textcolor Finding Debian version\n" unless $quite == 1;
  402.   my $version = `cat /etc/Debian_release`;
  403.   $version =~ s/\s+/ /g;
  404.   $version = " OS:$textcolor $version";
  405.   unshift(@line, "$version");
  406. }
  407.  
  408. my $c1 = "\e[0;31m";
  409.  
  410. print "
  411. $c1       _,met\$\$\$\$\$gg.
  412. $c1    ,g\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P.
  413. $c1  ,g\$\$P\"\"       \"\"\"Y\$\$.\".              @line[0]
  414. $c1 ,\$\$P'              \`\$\$\$.              @line[1]
  415. $c1',\$\$P       ,ggs.     \`\$\$b:            @line[2]
  416. $c1\`d\$\$'     ,\$P\"'   .    \$\$\$             @line[3]
  417. $c1 \$\$P      d\$'     ,    \$\$P             @line[4]
  418. $c1 \$\$:      \$\$.   -    ,d\$\$'             @line[5]
  419. $c1 \$\$\;      Y\$b._   _,d\$P'               @line[6]
  420. $c1 Y\$\$.    \`.\`\"Y\$\$\$\$P\"'                  @line[7]
  421. $c1 \`\$\$b      \"-.__                       @line[8]
  422. $c1  \`Y\$\$
  423. $c1   \`Y\$\$.
  424. $c1     \`\$\$b.
  425. $c1       \`Y\$\$b.
  426. $c1          \`\"Y\$b._
  427. $c1              \`\"\"\"\"
  428. \e[0m";   
  429. }       
  430.  
  431. if ( $distro =~ m/Ubuntu/ ) {
  432.  
  433. ## Get Ubuntu version ##
  434. if ( $display =~ "OS"){
  435.   print "\::$textcolor Finding Ubuntu version\n" unless $quite == 1;
  436.   my $version = `head -3 /etc/lsb-release |cut -d"=" -f2`;
  437.   $version =~ s/\s+/ /g;
  438.   $version = " OS:$textcolor $version";
  439.   unshift(@line, "$version");
  440. }
  441.  
  442. my $c1 = "\e[0;31m";
  443. my $c2 = "\e[0;33m";
  444. my $c3 = "\e[0;35m";
  445.  
  446. print "
  447.                $c1.-.
  448.          $c3.-'``$c1(   )     @line[0]
  449.       $c2,` $c3      $c1`-'$c3.$c1     @line[1]
  450.      $c2/    $c3'``-.   `$c1     @line[2]
  451.    $c3.-.  $c2,       $c3`___:$c1     @line[3]
  452.   $c3(   )$c2:        $c1 ___      @line[4]
  453.    $c3`-'  $c2`       $c1,   :     @line[5]
  454.      $c2`    $c1`..-`   ,     @line[6]
  455.       $c2`./ $c1     $c2.-.$c1`     @line[7]
  456.          $c1`-..-$c2(   )$c1     @line[8]
  457.                $c2`-'
  458. \e[0m";
  459. }
  460.  
  461. #return 0;     
  462. ## Run screen shot graper ##
  463. `$command` unless $shot != 0;

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me