Συντονιστές: pros, sokoban4ever

#!/usr/bin/perl
use Switch;
use strict;
use File::Basename;
####################
## Config options ##
####################
## What distro logo to use to use, Available "Archlinux Debian Ubuntu None" ##
my $distro = "Ubuntu";
## 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 = 1;
## Command to run to take screen shot ##
my $command = "scrot -d 0.2";
## 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 = "NONE";
## Hash of WMs and the process they run ##
my %WMlist = ("Beryl", "beryl",
"Compiz", "compiz",
"Emerald", "emerald",
"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-panel",
"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<Failed>\n";
while( <FILE> ) {
if( /<name>(.+)<\/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 "Compiz" {
# commented for Heliodor
# print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
# open(FILE, "$ENV{HOME}/.emerald/themes/Azurite-22px/theme.ini")
# || die "\e[0;31m<Failed>\n";
# while( <FILE> ) {
# if( /name=(.+)/ ) {
# print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
# push(@line, " WM Theme:$textcolor $1");
# }
# }
# close(FILE);
# Get the heliodor(metacity) theme
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, " GWD Theme:$textcolor $gconf");
}
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<Failed>\n";
while( <FILE> ) {
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<Failed>\n";
while( <FILE> ) {
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<Failed>\n";
while( <FILE> ) {
if( /<option name="Xfwm\/ThemeName" type="string" value="(.+)"\/>/ ) {
print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
push(@line, " WM Theme:$textcolor $1");
}
}
close(FILE);
}
case "Kwin" {
print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
open(FILE, "$ENV{HOME}/.kde/share/config/kwinrc")
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if( /PluginLib=kwin3_(.+)/ ) {
print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
push(@line, " WM Theme:$textcolor $1");
}
}
close(FILE);
}
case "Enlightenment" {
print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
my $remote = `enlightenment_remote -theme-get theme` ;
if( $remote =~ m/.*FILE="(.+).edj"/ ) {
print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
push(@line, " WM Theme:$textcolor $1");
}
}
case "IceWM" {
print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
open(FILE, "$ENV{HOME}/.icewm/theme")
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if( /Theme="(.+)\/.*.theme/ ) {
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 "PekWM" {
print "\::$textcolor Finding $WM theme\n" unless $quite == 1;
open(FILE, "$ENV{HOME}/.pekwm/config")
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if( /Theme.*\/(.*)"/ ) {
print "\::$textcolor $WM theme found as $1\n" unless $quite == 1;
push(@line, " WM Theme:$textcolor $1");
}
}
close(FILE);
}
}
}
## Find Theme Icon and Font ##
if ( $display =~ m/[Theme, Icons, Font, Background]/) {
switch($DE) {
case "Gnome" {
print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
if ( $display =~ m/Theme/ ) {
my $gconf = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
chomp ($gconf);
print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
push(@line, " GTK Theme:$textcolor $gconf");
}
if ( $display =~ m/Icons/ ) {
my $gconf = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
chomp ($gconf);
push(@line, " Icons:$textcolor $gconf");
}
if ( $display =~ m/Font/ ) {
my $gconf = `gconftool-2 -g /desktop/gnome/interface/font_name`;
chomp ($gconf);
push(@line, " Font:$textcolor $gconf");
}
if ( $display =~ m/Background/ ) {
my $gconf = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
chomp ($gconf);
my $bname = basename($gconf);
push(@line, " Background:$textcolor $bname");
}
}
case "Xfce4" {
my @sort = ();
print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
open(FILE, "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if ( $display =~ m/Theme/ ) {
if (/<option name="Net\/ThemeName" type="string" value="(.+)"\/>/ ) {
print "\::$textcolor GTK Theme found as $1\n" unless $quite == 1;
unshift(@sort, " GTK Theme:$textcolor $1");
}
}
if ( $display =~ m/Icons/ ) {
if (/<option name="Net\/IconThemeName" type="string" value="(.+)"\/>/ ) {
print "\::$textcolor Icons found as $1\n" unless $quite == 1;
unshift(@sort, " Icons:$textcolor $1");
}
}
if ( $display =~ m/Font/ ) {
if ( /<option name="Gtk\/FontName" type="string" value="(.+)"\/>/ ) {
print "\::$textcolor Font found as $1\n" unless $quite == 1;
unshift(@sort, " Font:$textcolor $1");
}
}
}
close(FILE);
## Sort variables so they're ordered "Theme Icon Font" ##
foreach my $i (@sort) {
push(@line, "$i");
}
}
case "KDE" {
print "\::$textcolor Finding $DE variables\n" unless $quite == 1;
open(FILE, "$ENV{HOME}/.kde/share/config/kdeglobals")
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if ( $display =~ m/Theme/ ) {
if ( /widgetStyle=(.+)/ ) {
print "\::$textcolor Wiget Style found as $1\n" unless $quite == 1;
push(@line, " Wiget Style:$textcolor $1");
}
if (/colorScheme=(.+).kcsrc/ ) {
print "\::$textcolor Color Scheme found as $1\n" unless $quite == 1;
push(@line, " Color Scheme:$textcolor $1");
}
}
if ( $display =~ m/Icons/ ) {
if ( /Theme=(.+)/ ) {
print "\::$textcolor Icons found as $1\n" unless $quite == 1;
push(@line, " Icons:$textcolor $1");
}
}
if ( $display =~ m/Font/ ) {
if ( /font=(.+)/ ) {
my $font = (split/,/, $1)[0];
print "\::$textcolor Font found as $font\n" unless $quite == 1;
push(@line, " Font:$textcolor $font");
}
}
}
close(FILE);
}
else {
my @files = ("$ENV{HOME}/.gtkrc-2.0", "$ENV{HOME}/.gtkrc.mine",);
foreach my $file (@files) {
if ( -e $file ) {
print "\::$textcolor Opening $file\n" unless $quite == 1;
open(FILE, $file)
|| die "\e[0;31m<Failed>\n";
while( <FILE> ) {
if ( $display =~ m/Theme/ ) {
if( /include ".*themes\/(.+)\/gtk-(1|2)\.0\/gtkrc"/ ){
print "\::$textcolor GTK theme found as $1\n" unless $quite == 1;
push(@line, " GTK Theme:$textcolor $1");
}
}
if ( $display =~ m/Icons/ ) {
if( /.*gtk-icon-theme-name.*"(.+)"/ ) {
print "\::$textcolor Icons found as $1\n" unless $quite == 1;
push(@line, " Icons:$textcolor $1");
}
}
if ( $display =~ m/Font/ ) {
if( /.*gtk-font-name.*"(.+)"/ ) {
print "\::$textcolor Font found as $1\n" unless $quite == 1;
push(@line, " Font:$textcolor $1");
}
}
}
close(FILE);
}
}
}
}
}
## Display the system info ##
if ( $distro =~ m/Archlinux/ ) {
## Get Archlinux version ##
if ( $display =~ "OS"){
print "\::$textcolor Finding Archlinux version\n" unless $quite == 1;
my $version = `cat /etc/arch-release`;
$version =~ s/\s+/ /g;
$version = " OS:$textcolor $version";
unshift(@line, "$version");
}
my $c1 = "\e[0;32m";
my $c2 = "\e[1;32m";
print "$c1 __
$c1 _=(SDGJT=_
$c1 _GTDJHGGFCVS) $c1@line[0]
$c1 ,GTDJGGDTDFBGX0 $c1@line[1]
$c1 JDJDIJHRORVFSBSVL$c2-=+=,_ $c1@line[2]
$c1 IJFDUFHJNXIXCDXDSV,$c2 \"DEBL $c1@line[3]
$c1 [LKDSDJTDU=OUSCSBFLD.$c2 '?ZWX, $c1@line[4]
$c1 ,LMDSDSWH' \`DCBOSI$c2 DRDS], $c1@line[5]
$c1 SDDFDFH' !YEWD,$c2 )HDROD $c1@line[6]
$c1 !KMDOCG &GSU|$c2\_GFHRGO' $c1@line[7]
$c1 HKLSGP'$c2 __$c1\TKM0$c2\GHRBV)' $c1@line[8]
$c1 JSNRVW'$c2 __+MNAEC$c1\IOI,$c2\BN'
$c1 HELK['$c2 __,=OFFXCBGHC$c1\FD)
$c1 ?KGHE $c2\_-#DASDFLSV='$c1 'EF
$c1 'EHTI !H
$c1 \`0F' '!
\e[0m";
}
if ( $distro =~ m/None/ ) {
my $color = "\e[0;34m";
foreach my $filled ( @line ) {
print "$color $filled\n"
}
}
if ( $distro =~ m/Debian/ ) {
## Get Debian version ##
if ( $display =~ "OS"){
print "\::$textcolor Finding Debian version\n" unless $quite == 1;
my $version = `cat /etc/Debian_release`;
$version =~ s/\s+/ /g;
$version = " OS:$textcolor $version";
unshift(@line, "$version");
}
my $c1 = "\e[0;31m";
print "
$c1 _,met\$\$\$\$\$gg.
$c1 ,g\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P.
$c1 ,g\$\$P\"\" \"\"\"Y\$\$.\". @line[0]
$c1 ,\$\$P' \`\$\$\$. @line[1]
$c1',\$\$P ,ggs. \`\$\$b: @line[2]
$c1\`d\$\$' ,\$P\"' . \$\$\$ @line[3]
$c1 \$\$P d\$' , \$\$P @line[4]
$c1 \$\$: \$\$. - ,d\$\$' @line[5]
$c1 \$\$\; Y\$b._ _,d\$P' @line[6]
$c1 Y\$\$. \`.\`\"Y\$\$\$\$P\"' @line[7]
$c1 \`\$\$b \"-.__ @line[8]
$c1 \`Y\$\$
$c1 \`Y\$\$.
$c1 \`\$\$b.
$c1 \`Y\$\$b.
$c1 \`\"Y\$b._
$c1 \`\"\"\"\"
\e[0m";
}
if ( $distro =~ m/Ubuntu/ ) {
## Get Ubuntu version ##
if ( $display =~ "OS"){
print "\::$textcolor Finding Ubuntu version\n" unless $quite == 1;
my $version = `head -3 /etc/lsb-release |cut -d"=" -f2`;
$version =~ s/\s+/ /g;
$version = " OS:$textcolor $version";
unshift(@line, "$version");
}
my $c1 = "\e[2;31m";
my $c2 = "\e[0;33m";
my $c3 = "\e[0;31m";
my $c4 = "\e[1;31m";
print "
$c1\llKXXx.
$c1\OMMMMMN'
$c3\.,coxkOOOkd.$c1\,MMMMMMMx $c4 @line[0]
$c2\,. $c3\;WMMMMMMMMMO.$c1\llXMMMWx. $c4 @line[1]
$c2\llNMK. $c3\.XMMMMMMMMMNd,,,;,. $c4 @line[2]
$c2\;XMMMMN, $c3\.xxollldOXMMMMMMMMx $c4 @line[3]
$c2\dMMMMMMMk $c3\.lXMMMMMMX. $c4 @line[4]
$c2\;MMMMMMX' $c3\xxMMMMMMK $c4 @line[5]
$c3\;kXNXx,$c2\'KMMMW. $c3\xxMMMMMMc $c4 @line[6]
$c3\:MMMMMMM;$c2\'MMMk $c4 @line[7]
$c3\;MMMMMMW,$c2\'MMMk $c1\.llllll, $c4 @line[8]
$c3\'oOOOo'$c2\:XMMMW' $c1\OMMMMMM:
$c2\;MMMMMMW: $c1\.OMMMMMM0
$c2\ccWMMMMMMO $c1\,xWMMMMMM0.
$c2\'KMMMMX. $c1\.00kddxkKWMMMWNNMWo
$c2\:KM0. $c1\,WMMMMMMMMMXc'$c2\,;;,.
$c2\. $c1\;WMMMMMMMMMk.$c2\dWMMMM0.
$c1\.;codxxddl.$c2\,MMMMMMMx
$c2\xMMMMMK.
$c2\,OK0c
\e[0m";
}
#return 0;
## Run screen shot graper ##
`$command` unless $shot != 0;
perl info.pl

cyberpython έγραψε:Gourgi είσαι θεός!!!

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class DesktopEnvironmentInfo {
private final String UNIX_PRINT_PROC_CMD = "ps -A";
private String desktopName;
private String windowManager;
private String widgetTheme;
private String iconTheme;
private Hashtable<String, String> wmList;
private Hashtable<String, String> deList;
/**
* Default constructor
*/
public DesktopEnvironmentInfo() {
initialize();
Vector<String> runningProcesses = listRunningProcessesOnUnix();
//printStringVector(runningProcesses, System.out);
this.desktopName = findDesktopName(runningProcesses);
this.windowManager = findWMName(runningProcesses);
findThemeAndIconTheme(this.desktopName);
}
/**
*
* @return The name of the current Desktop Environment : <br>
* <ul>
* <b>gnome</b> - for GNOME
* <b>kde</b> - for KDE
* <b>xfce4</b> - for XFCE
* <b>unknown</b> - for other desktop environments
* </ul>
*/
public String getDesktopEnvironmentName() {
return this.desktopName;
}
/**
*
* @return The name of the current Window Manager : <br>
* <ul>
* <b>beryl</b> - for Beryl
* <b>compiz</b> - for Compiz
* <b>emerald</b> - for Emerald
* <b>fluxbox</b> - for Fluxbox
* <b>openbox</b> - for Openbox
* <b>blackbox</b> - for Blackbox
* <b>xfwm</b> - for Xfwm
* <b>metacity</b> - for Metacity
* <b>kwin</b> - for Kwin
* <b>fvwm</b> - for FVWM
* <b>enlightenment</b> - for Enlightenment
* <b>icewm</b> - for IceWM
* <b>wmaker</b> - for Window Maker
* <b>pekwm</b> - for PekWM
* <b>unknown</b> - for other Window Managers
* </ul>
*/
public String getWindowManagerName() {
return this.windowManager;
}
/**
*
* @return The name of the current icon widgetTheme.<br>
* If the dekstop environment is not Gnome/KDE/XFCE or the
* icon theme could not be determined then "unknown" is returned.<br>
* ***WARNING*** : On KDE if the user has not changed the default
* icon theme then the result will be "default.kde".
*/
public String getIconThemeName() {
return this.iconTheme;
}
/**
*
* @return The name of the current widgetTheme.<br>
* If the dekstop environment is not Gnome/KDE/XFCE or the
* widget theme could not be determined then "unknown" is returned.<br>
* ***WARNING*** : On KDE if the user has not changed the default
* widget theme then the result will be "default".
*/
public String getWidgetThemeName() {
return this.widgetTheme;
}
private void initialize() {
this.wmList = new Hashtable<String, String>();
this.wmList.put("beryl", "Beryl");
this.wmList.put("compiz", "Compiz");
this.wmList.put("emerald", "Emerald");
this.wmList.put("fluxbox", "Fluxbox");
this.wmList.put("openbox", "Openbox");
this.wmList.put("blackbox", "Blackbox");
this.wmList.put("xfwm4", "Xfwm4");
this.wmList.put("metacity", "Metacity");
this.wmList.put("kwin", "Kwin");
this.wmList.put("fvwm", "FVWM");
this.wmList.put("enlightenment", "Enlightenment");
this.wmList.put("icewm", "IceWM");
this.wmList.put("wmaker", "Window Maker");
this.wmList.put("pekwm", "PekWM");
this.deList = new Hashtable<String, String>();
this.deList.put("xfce-mcs-manage", "xfce4");
this.deList.put("ksmserver", "kde");
}
/**
* Determines the name of the current desktop environment.
* For GNOME it uses the JAVA VM System property sun.desktop
* For KDE and XFCE checks the running processes to find out
* which DE is currently active.
* @return The name of the current Desktop Environment : <br>
* <ul>
* <b>gnome</b> - for GNOME
* <b>kde</b> - for KDE
* <b>xfce4</b> - for XFCE
* <b>unknown</b> - for other desktop environments
* </ul>
*/
private String findDesktopName(Vector<String> processes) {
String name = System.getProperty("sun.desktop");
if (name != null) {
name = name.toLowerCase();
if (name.equals("gnome")) {
return "gnome";
}
}
Enumeration en = deList.keys();
while (en.hasMoreElements()) {
String deProc = (String) en.nextElement();
String deName = deList.get(deProc);
if (processes.contains(deProc)) {
return deName;
}
}
return "unknown";
}
/**
* Determines the name of the current window manager by
* checking the running processes.
* @return The name of the current Window Manager : <br>
* <ul>
* <b>beryl</b> - for Beryl
* <b>compiz</b> - for Compiz
* <b>emerald</b> - for Emerald
* <b>fluxbox</b> - for Fluxbox
* <b>openbox</b> - for Openbox
* <b>blackbox</b> - for Blackbox
* <b>xfwm</b> - for Xfwm
* <b>metacity</b> - for Metacity
* <b>kwin</b> - for Kwin
* <b>fvwm</b> - for FVWM
* <b>enlightenment</b> - for Enlightenment
* <b>icewm</b> - for IceWM
* <b>wmaker</b> - for Window Maker
* <b>pekwm</b> - for PekWM
* <b>unknown</b> - for other Window Managers
* </ul>
*/
private String findWMName(Vector<String> processes) {
Enumeration en = wmList.keys();
while (en.hasMoreElements()) {
String wmProc = (String) en.nextElement();
String wmName = wmList.get(wmProc);
if (processes.contains(wmProc)) {
return wmName;
}
}
return "unknown";
}
private void findThemeAndIconTheme(String deName) {
this.widgetTheme = "unknown";
this.iconTheme = "unknown";
if (deName != null) {
deName = deName.toLowerCase();
if (deName.equals("gnome")) {
final String GET_GTK_THEME_CMD = "gconftool-2 -g /desktop/gnome/interface/gtk_theme";
Vector<String> cmdResults = execCommand(GET_GTK_THEME_CMD);
if (cmdResults.size() > 0) {
this.widgetTheme = cmdResults.get(0);
}
final String GET_ICON_THEME_CMD = "gconftool-2 -g /desktop/gnome/interface/icon_theme";
cmdResults = execCommand(GET_ICON_THEME_CMD);
if (cmdResults.size() > 0) {
this.iconTheme = cmdResults.get(0);
}
}//Done with Gnome
else if (deName.equals("kde")) {
this.widgetTheme = "default";
this.iconTheme = "default.kde";
String userHome = System.getProperty("user.home");
if (userHome != null) {
File kdeglobals = new File(userHome + "/.kde/share/config/kdeglobals");
try {
BufferedReader br = new BufferedReader(new FileReader(kdeglobals));
String line;
boolean f1 = false;
boolean f2 = false;
boolean finished = false;
while (((line = br.readLine()) != null) && (finished == false)) {
line = line.trim();
if (line.equals("[General]")) {
boolean done = false;
while (((line = br.readLine()) != null) && (done == false)) {
line = line.trim();
if (line.startsWith("widgetStyle")) {
int start = line.indexOf("=");
this.widgetTheme = line.substring(start + 1);
done = true;
}
}
f1 = true;
}
if (line.equals("[Icons]")) {
boolean done = false;
while (((line = br.readLine()) != null) && (done == false)) {
line = line.trim();
if (line.startsWith("Theme")) {
int start = line.indexOf("=");
this.iconTheme = line.substring(start + 1);
done = true;
}
}
f2 = true;
}
finished = f1 && f2;
if (line == null) {
break;
}
}
} catch (Exception e) {
}
}
}//Done with KDE
else if (deName.equals("xfce4")) {
String userHome = System.getProperty("user.home");
if (userHome != null) {
File xfceGTKSettings = new File(userHome + "/.config/xfce4/mcs_settings/gtk.xml");
try {
BufferedReader br = new BufferedReader(new FileReader(xfceGTKSettings));
String line;
boolean f1 = false;
boolean f2 = false;
boolean finished = false;
while (((line = br.readLine()) != null) && (finished == false)) {
line = line.trim();
if (line.startsWith("<option name=\"Net/ThemeName\"")) {
int start_index = line.lastIndexOf("=") + 2;
int end_index = line.lastIndexOf("\"");
this.widgetTheme = line.substring(start_index, end_index);
f1 = true;
}
if (line.startsWith("<option name=\"Net/IconThemeName\"")) {
int start_index = line.lastIndexOf("=") + 2;
int end_index = line.lastIndexOf("\"");
this.iconTheme = line.substring(start_index, end_index);
f2 = true;
}
finished = f1 && f2;
if (line == null) {
break;
}
}
} catch (Exception e) {
}
}
}//Done with XFCE
}
}
/**
* Helper function to execute external processes
* @param cmd The command to be executed
* @return A Vector of strings representing the commands output
*/
private Vector<String> execCommand(String cmd) {
Vector<String> result = new Vector<String>();
Runtime rt = Runtime.getRuntime();
try {
Process p = rt.exec(cmd);
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = new String();
while ((line = input.readLine()) != null) {
result.add(line);
}
input.close();
} catch (IOException ioe) {
System.err.println(ioe.toString());
}
return result;
}
/**
* Lists the running processes on a Unix machine by invoking the 'ps -A' command
* @return A Vector of strings representing the names of the running processes
*/
private Vector<String> listRunningProcessesOnUnix() {
Vector<String> v = execCommand("ps -A");
Vector<String> result = new Vector<String>(v.size());
Enumeration e = v.elements();
while (e.hasMoreElements()) {
String[] s = ((String) e.nextElement()).split("\\s");
result.add(s[s.length - 1]);
}
return result;
}
public static void main(String[] args) {
DesktopEnvironmentInfo de = new DesktopEnvironmentInfo();
System.out.println("Desktop Environment: " + de.getDesktopEnvironmentName());
System.out.println("Window manager: " + de.getWindowManagerName());
System.out.println("Widgets Theme: " + de.getWidgetThemeName());
System.out.println("Icon theme: " + de.getIconThemeName());
}
}
DesktopEnvironmentInfo.javajavac DesktopEnvironmentInfo.javajava DesktopEnvironmentInfo

Επιστροφή στην Περιβάλλον Εργασίας / Εμφάνιση / Εφέ / Customization
Μέλη σε αυτή την Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες