You are not logged in.

#1 2006-08-18 15:15:23

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Screenshot info grabber - in development!

OK, all the time in the screenshots thread we get "What gtk theme is that?", "What is that in the corner?", blah blah blah.

Now, while we try to encourage people to post that with their screenie why don't we make a simple script that grabs info from from the gtkrc's, .xinitrc, etc, and outputs into a nice cowsay-like soundbite?

If we pkg it we can throw in a depends and/or a variety of screenshot taking commands.  Then all you have to do it get your nice screenie up, open a term, run foo and *bingo* all the info and no need to run a screenshot command.  Easy :-P

It'll take some good awk skills so it'll practice for me!  I'll post the basic outline later.

.:update:.

There has been some great work made on this so I have moved the thread here for more attention.

Offline

#2 2006-08-18 15:18:26

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Screenshot info grabber - in development!

Can you list what info you'd want?

Offline

#3 2006-08-18 15:45:54

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: Screenshot info grabber - in development!

Why?  Are you bored?

I figured:

From .xinitrc
Anything that follows exec that will give us window manager and few startup apps in many cases.

once we have a few of those in an array we can try and get a few version=`@app --version`, type grabs

Grab the font and theme name from gtkrc2 and wherever KDE keeps it....just for starters...

A list of screenshot commands people use would be good.  Then we can use which to check which apps are installed and use the appropriate command.

Offline

#4 2006-08-18 16:29:16

Cagnulein
Member
From: Modena, Italy
Registered: 2006-04-03
Posts: 260
Website

Re: Screenshot info grabber - in development!

i think it's a nice idea...i offer myself as beta tester when you'll have something

/me tracks this topic  :oops:

Offline

#5 2006-08-18 17:22:53

detto
Member
Registered: 2006-01-23
Posts: 510

Re: Screenshot info grabber - in development!

indeed a nice idea!
want to beta test too if possible big_smile

atm i make my screenshots with 'scrot' if it helps.
btw to the gtkrc thing: iirc xfce, gnome, gtk-alone(no of both dm in use) and kde use slightly diffrent places for them? well i dont know, but if its the case it would be more difficult to program this i think roll

cheers,
detto

Offline

#6 2006-08-19 21:54:48

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: Screenshot info grabber - in development!

hmmmmm well, i just installed arch LAST night.  So far, I really like it wink  Saw this post and thought i'd get it started.  I didn't write it in awk, but in bash.  It requires 4 programs but usually you want these anyway.  Not sure WHAT all you wanted in the list/output, but at least this is a start. Hope you like it.

#!/bin/bash
# Arch Screenshot Taker
# Script takes a screenshot after a 4 second delay, and writes to the image file data.

# Do some error checking
# Requires 4 programs (all useful anyway ;) )...  wrjpgcom,imagemagick,rdjpgcom,jhead
if [[ -z $( type -p wrjpgcom ) ]]; then echo -e "The program wrjpgcom -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p convert ) ]]; then echo -e "ImageMagick -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p rdjpgcom ) ]]; then echo -e "The program wrjpgcom -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p jhead ) ]]; then echo -e "The program jhead -- NOT INSTALLED !";exit ;fi

# Check to make sure that a name was given after the command name.
if [[ -z "$1" ]] ; then
        echo " ";
        echo "          ######### COMMAND FAILED ########## ";
        echo "          USAGE: $0 screenshotname";
        echo "          EXAMPLE: $0 screenshot1";
        echo "          Note: There is a 5 second delay after starting";
        echo "          the program before the screenshot is taken.";
        echo "          ######### COMMAND FAILED ########## ";echo " ";
else

# Move to the users root directory to store screenshots
cd ~
# Take the screenshot. Change 5 second delay by changing from "pause 5" to something else.
import -window root -pause 5 ${1}.jpg # 5 second delay before screenshot is taken.

# Find some information we want written to the metadata of the image.
windowmanager=`grep -v "#" ~/.xinitrc | grep "exec" > /tmp/wm; cut -b 11- /tmp/wm;rm -f /tmp/wm`
jhead ${1}.jpg > /tmp/wm
filename=`grep "File name" /tmp/wm`
filesize=`grep "File size" /tmp/wm`
filedate=`grep "File date" /tmp/wm`
resolution=`grep "Resolution" /tmp/wm`
rm -f /tmp/wm
processor=`uname -mip`
kernel=`uname -sr`


# REPLACE COMMENTS - First write replaces all comments
wrjpgcom -replace -comment "Screenshot by $USER" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg

# Append Comments - All following writes to meta data are appended, instead of replaced.
# wrjpgcom -comment "The window manager is $windowmanager" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "---------------------------------" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "${filename}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "${filesize}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "${filedate}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "${resolution}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "Window Mngr  : ${windowmanager}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "Kernel       : ${kernel}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
wrjpgcom -comment "Processor    : ${processor}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg

# Echo out the Meta Data stored on the image.
echo "";
rdjpgcom ${1}.jpg
# Note Konqueror only reads the LAST comment entered... but rdjpcon will read them ALL.

fi
exit 0

Output on the command line looks like this:

[crouse@crouse ~]$ ./archshot.sh screen4.jpg

Screenshot by crouse
---------------------------------
File name    : screen4.jpg
File size    : 84072 bytes
File date    : 2006:08:19 16:44:29
Resolution   : 1024 x 768
Window Mngr  : kde
Kernel       : Linux 2.6.17-ARCH
Processor    : i686 Intel(R) Xeon(TM) CPU 1.70GHz GenuineIntel

[crouse@crouse ~]$             

Offline

#7 2006-08-20 08:38:39

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: Screenshot info grabber - in development!

Well, I guess that is start but you only have one thing on there that people ask about in the screenshot thread!  I like the idea of gathering kernel info etc but it's not really important in this context.  People are much more interested in what apps are running in the screenshot, what gtk/kde/openbox theme it is, what icon set is being used, what font, etc, etc.

I like the implementation though!  Here are a few changes I would make though so it is a bit more easy to expand:

--- ast.orig    2006-08-20 09:25:41.000000000 +0100
+++ ast    2006-08-20 09:34:47.000000000 +0100
@@ -2,6 +2,11 @@
 # Arch Screenshot Taker
 # Script takes a screenshot after a 4 second delay, and writes to the image file data.
 
+jpg_txt()
+{
+    wrjpgcom -comment "${1}" ${shotname}.jpg > _${shotname}.jpg ; mv _${shotname}.jpg ${shotname}.jpg
+}
+
 # Do some error checking
 # Requires 4 programs (all useful anyway ;) )...  wrjpgcom,imagemagick,rdjpgcom,jhead
 if [[ -z $( type -p wrjpgcom ) ]]; then echo -e "The program wrjpgcom -- NOT INSTALLED !";exit ;fi
@@ -20,14 +25,16 @@
         echo "          ######### COMMAND FAILED ########## ";echo " ";
 else
 
+shotname=${1}
+
 # Move to the users root directory to store screenshots
-cd ~
+cd $HOME
 # Take the screenshot. Change 5 second delay by changing from "pause 5" to something else.
-import -window root -pause 5 ${1}.jpg # 5 second delay before screenshot is taken.
+import -window root -pause 5 ${shotname}.jpg # 5 second delay before screenshot is taken.
 
 # Find some information we want written to the metadata of the image.
 windowmanager=`grep -v "#" ~/.xinitrc | grep "exec" > /tmp/wm; cut -b 11- /tmp/wm;rm -f /tmp/wm`
-jhead ${1}.jpg > /tmp/wm
+jhead ${shotname}.jpg > /tmp/wm
 filename=`grep "File name" /tmp/wm`
 filesize=`grep "File size" /tmp/wm`
 filedate=`grep "File date" /tmp/wm`
@@ -38,22 +45,23 @@
 
 
 # REPLACE COMMENTS - First write replaces all comments
-wrjpgcom -replace -comment "Screenshot by $USER" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
+wrjpgcom -replace -comment "Screenshot by $USER" ${shotname}.jpg > _${shotname}.jpg ; mv _${shotname}.jpg ${shotname}.jpg
 
 # Append Comments - All following writes to meta data are appended, instead of replaced.
-# wrjpgcom -comment "The window manager is $windowmanager" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "---------------------------------" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "${filename}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "${filesize}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "${filedate}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "${resolution}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "Window Mngr  : ${windowmanager}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "Kernel       : ${kernel}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
-wrjpgcom -comment "Processor    : ${processor}" ${1}.jpg > _${1}.jpg ; mv _${1}.jpg ${1}.jpg
+# jpg_txt "The window manager is $windowmanager"
+
+jpg_txt "---------------------------------"
+jpg_txt "${filename}"
+jpg_txt "${filesize}"
+jpg_txt "${filedate}"
+jpg_txt "${resolution}"
+jpg_txt "Window Mngr  : ${windowmanager}"
+jpg_txt "Kernel       : ${kernel}"
+jpg_txt "Processor    : ${processor}"
 
 # Echo out the Meta Data stored on the image.
 echo "";
-rdjpgcom ${1}.jpg
+rdjpgcom ${shotname}.jpg
 # Note Konqueror only reads the LAST comment entered... but rdjpcon will read them ALL.
 
 fi

I hope I understood it properly and didn't break it!

Offline

#8 2006-08-20 16:01:35

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: Screenshot info grabber - in development!

Thanks, Yeah..... the only thing i "knew" for sure was that you would want the window manager name probably..... and i wasn't quite sure how to figure out what apps/themes were running.... i've only been running arch for 2 days wink  (linux for years..but have just started with arch)

It might be possible to pull out some data from a

ps auxf > /tmp/ps  ........ shows all the currently running processes, but i'm running kde right now, so i'm not sure what all/where to look for other wm processes.

Interesting idea... and i look forward to seeing what else everyone comes up with and where to find specific information.

Offline

#9 2006-09-23 15:52:52

TomE
Member
Registered: 2005-08-06
Posts: 164

Re: Screenshot info grabber - in development!

I started this when I first seen this thread and its come up again recently, its very hack-ish with a mix of awk and sed.
It supports Xfce,Gnome,Openbox and Openbox-Gnome, but adding support of other DE should be easy.

#!/bin/bash
if [ "$1" = "-e" ]; then
    DE="$2"
    if [ "$2" = "Xfce" ];then
        WM=`grep Xfwm/ThemeName ~/.config/xfce4/mcs_settings/xfwm4.xml | awk -F "value="" {'print $2'} | sed s@"/>@@g`
        UI=`grep Net/ThemeName ~/.config/xfce4/mcs_settings/gtk.xml | awk -F "value="" {'print $2'} | sed s@"/>@@g`
    elif [ "$2" = "Gnome" ]; then
        WM=`gconftool-2 -g /apps/metacity/general/theme`
        UI=`gconftool-2 -g /desktop/gnome/interface/gtk_theme`
    elif [ "$2" = "Openbox" ]; then
        THEME_LINE=`grep -n "<theme>" ~/.config/openbox/rc.xml | cut -d ":" -f1`
        WM=` sed -n $(($THEME_LINE+1))p ~/.config/openbox/rc.xml | sed s/.*<name>// | sed s/<name>//`
        UI=`grep include ~/.gtkrc-2.0 | grep gtk-2.0 | awk -F "/gtk-2.0/gtkrc" {'print $1'} | awk -F "/" {'print $NF'}`
    elif [ "$2" = "Openbox-Gnome" ];then
        THEME_LINE=`grep -n "<theme>" ~/.config/openbox/rc.xml | cut -d ":" -f1`
        WM=` sed -n $(($THEME_LINE+1))p ~/.config/openbox/rc.xml | sed s/.*<name>// | sed s/<name>//`
        UI=`gconftool-2 -g /desktop/gnome/interface/gtk_theme`
    else
        echo "Environment $2 not surported"
        exit
    fi
elif [ "$1" = "-h" ]; then
    echo "-e <environment> - Get info for surrported environments.
    surrported environment:
        Xfce,Gnome,Openbox,Openbox-Gnome
or you do "environment WM UI""
    exit
else
    DE=$1
    UI=$2
    WM=$3
fi

echo ""$'e[0;34m'"
              __
          _=(SDGJT=_
        _GTDJHGGFCVS)                OS: "$'e[0;37m'"`cat /etc/arch-release`"$'e[0;34m'"
       ,GTDJGGDTDFBGX0               Kernel: "$'e[0;37m'"`uname -r`"$'e[0;34m'"
      JDJDIJHRORVFSBSVL"$'e[0;30m'"-=+=,_"$'e[0;34m'"        DE: "$'e[0;37m'"$DE"$'e[0;34m'"
     IJFDUFHJNXIXCDXDSV,"$'e[0;30m'"  "DEBL"$'e[0;34m'"      WM Theme: "$'e[0;37m'"$WM"$'e[0;34m'"
    |LKDSDJTDU=OUSCSBFLD."$'e[0;30m'"   '?ZWX,"$'e[0;34m'"   UI Theme: "$'e[0;37m'"$UI"$'e[0;34m'"
    LMDSDSWH='   `?DCBOSI"$'e[0;30m'"    DRDS],"$'e[0;34m'"
   SDDFDFH'        `0YEWD,"$'e[0;30m'"   )HDROD"$'e[0;34m'"
  !KMDOCG           '&GSU|"$'e[0;30m'"_GFHRGO'"$'e[0;34m'"
  HKLSGP'           "$'e[0;30m'"__"$'e[0;34m'"TKM0"$'e[0;30m'"GHRBV)'"$'e[0;34m'"
 JSNRVW'       "$'e[0;30m'"__+MNAEC"$'e[0;34m'"IOI,"$'e[0;30m'"BN'"$'e[0;34m'"
 HELK['  "$'e[0;30m'"  __,=OFFXCBGHC"$'e[0;34m'"FD)
JKGHEH"$'e[0;30m'"_-#DASDFSLSV='"$'e[0;34m'"    'EF
!EHTI                    !H
 `0F'                    '!
"

To run it do "script -e xfce" or gnome/whatever.

Offline

#10 2006-09-24 16:58:42

rab
Member
Registered: 2006-06-15
Posts: 185

Re: Screenshot info grabber - in development!

I actually like this idea, So i've spent 20 minutes working up a script like it. Not the best or "universalist", but i'll try to get it as close as possible.

#!/usr/bin/perl

use Switch;

@wm = ("metacity", "fluxbox", "openbox",
       "blackbox", "wmii", "wm", "compiz",
       "emerald");
@de = ("gnome");
## You can add more if needed 
$x = 0;
$y = 0;
$defaultde = 0;
$found = 0;
$quite = 0; #Prints 'debugging' messages
$version = `cat /etc/arch-release`;
$version =~ s/s+/ /g;
$kernel = `uname -r`;
$kernel =~ s/s+/ /g;

if( @ARGV < 1 ) {
    print "No enviroment selected, going by defaults..n" unless $quite == 1;
    $defaultde = 1;
} else {
    while( $x < @de && $found == 0) {
        if( $ARGV[0] =~ /$de[$x]/i ) {
            print "DE($ARGV[0]) supported...n" unless $quite == 1;
            $found = 1;
        }
        $x++;
    }

    die("$ARGV[0] is NOT supported...n") unless $found == 1;

    $x = 0;
    $found = 0;
}

if( $defaultde == 1 ) {
    if( !open(GTKRC, "<", "$ENV{HOME}/.gtkrc-2.0")  ) {
        print ".gtkrc-2.0 not found...n";
    } else {
        while( <GTKRC> ) {
            if( /include "$ENV{HOME}/.themes/(.+)/gtk-(1|2).0/gtkrc"/ ){
                $GTKTHEME = $1;
            }
            if( /gtk-icon-theme-name.*=.*"(.+)"/ ) {
                $GTKICON = $1;
            }
            if( /gtk-font-name.*=.*"(.+)"/ ) {
                $GTKFONT = $1;
            }
        }
        close(GTKRC);
    }

    if( !open(FEH, "<", "$ENV{HOME}/.fehbg") ) {
        print "Feh file not found...n";
    } else {
        while( <FEH> ) {
            if( /feh .+ $ENV{HOME}(.+)/ ) {
                $1 =~ /.*/(.+)$/;
                $WALL = $1;
            }
        }
        close(FEH);
    }

    open(XINT, "<", "$ENV{HOME}/.xinitrc")
        || die("$!nFailed to open "~/.xinitrc" for reading...n");

    while( <XINT> ) {
        next if /^#/;
        next if /^s+/;
            @exec = split(/&/);
            foreach (@exec) {
                s/^s+/n/;
                s/s+$//;
                next if /eval `cat .+/.fehbg`/;
                /exec (.+)/ && push(@startup, $1);
            }
    }
    close(XINT);
    
    ## Processes First
    findWM();
    
    ## Couldn't find a WM in PS? Lets check the .xinitrc
    if( $WMS eq "" ) {
        $WMS = "Unknown";
        print "Now checking your .xinitrc for a WM...n" unless $quite == 1;
        while( $x < @wm && $found == 0) {
            while( $y < @startup ) {
                print "Trying '$wm[$x]' with '$startup[$y]'n" unless $quite == 1;
                if( $wm[$x] eq $startup[$y] ) {
                    $WMS = $wm[$x];
                    print "Found $WMS as WMn" unless $quite == 1;
                    #unshift(@startup, $WMS);
                    # Could save the rest of the array for 
                    # showing what else EXEC's ? 
                    # Who knows, you decide!
                    $found = 1;
                    last;
                } 
                $y++;
            }
            $y = 0;
            $x++;
        }
        getWMtheme($WMS) unless $found == 0;
    }
} else {
    grabDEinfo($ARGV[0]);
}       


print "e[0;34m
              __
          _=(SDGJT=_
        _GTDJHGGFCVS)                OS: e[0;37m$versione[0;34m
       ,GTDJGGDTDFBGX0               Kernel: e[0;37m$kernele[0;34m
      JDJDIJHRORVFSBSVLe[0;30m-=+=,_e[0;34m        WM: e[0;37m$WMSe[0;34m
     IJFDUFHJNXIXCDXDSV,e[0;30m  "DEBLe[0;34m      WM Theme: e[0;37m$WMTHEMEe[0;34m
    |LKDSDJTDU=OUSCSBFLD.e[0;30m   '?ZWX,e[0;34m   GTK Theme: e[0;37m$GTKTHEMEe[0;34m
    LMDSDSWH='   `?DCBOSIe[0;30m    DRDS],e[0;34m  Icons: e[0;37m$GTKICONe[0;34m
   SDDFDFH'        `0YEWD,e[0;30m   )HDRODe[0;34m  Wallpaper: e[0;37m$WALLe[0;34m
  !KMDOCG           '&GSU|e[0;30m_GFHRGOe[0;34m    GTK Font: e[0;37m$GTKFONTe[0;34m
  HKLSGP'           e[0;30m__e[0;34mTKM0e[0;30mGHRBV)e[0;34m
 JSNRVW'       e[0;30m__+MNAECe[0;34mIOI,e[0;30mBNe[0;34m
 HELK['  e[0;30m  __,=OFFXCBGHCe[0;34mFD)
JKGHEHe[0;30m_-#DASDFSLSV=e[0;34m     'EF
!EHTI                    !H
`0F'                     '!
";

sub getWMtheme {
    my $wm = shift @_;

    switch ($wm) {
        case "openbox" {
            open(FILE, "<", "$ENV{HOME}/.config/openbox/rc.xml")
                || die("$!nFailed to open OpenBox rc.xml...n");
            while( <FILE> ) {
                if( /<name>(.+)</name>/ ) { 
                    print "OB Theme found as $1n" unless $quite == 1;
                    $WMTHEME = $1;
                           last;
                   }
                }
            close(FILE);
        }
        case "metacity" {
            $WMTHEME = `gconftool-2 -g /apps/metacity/general/theme`;
        }
        case "fluxbox" {
            open(FILE, "<", "$ENV{HOME}/.fluxbox/init")
                || die("$!nFailed to open Fluxbox init file...n");
            while( <FILE> ) {
                if( /session.styleFile: /.+/(.+)$/ ) {
                    print "FB Theme found as $1n";
                    $WMTHEME = $1;
                    last;
                }
            }
            close(FILE);
        }
        case "blackbox" {
            open(FILE, "<", "$ENV{HOME}/.blackboxrc")    
                || die("$!nFailed to open Blackbox .blackboxrc file...n");
                        while( <FILE> ) {
                                if( /session.styleFile: /.+/(.+)$/ ) {
                                        print "BB Theme found as $1n";
                    $WMTHEME = $1;
                    last;
                }
            }
            close(FILE);
        }
        else {
            $WMTHEME = "Unknown";
        }
    }
}
sub grabDEinfo {
    my $de = shift @_;

    switch($de) {
        case /gnome/i {
            $GTKTHEME = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
            $GTKICON = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
            $WALL = `gconftool-2 -g /desktop/gnome/background/picture_filename`;
            $GTKFONT = `gconftool-2 -g /desktop/gnome/interface/font_name`;
            $WALL =~ //.*/(.+)$/;
            findWM();
        }
    }
}
sub findWM {
    my $x = 0;
    my $found = 0;
    $WMS = "Unknown";
    $WMTHEME = "Unknown";

    print "Trying to find your WM...n" unless $quite == 1;
    
    while( $x < @wm && $found == 0) {
        print "Testing $wm[$x] in the PS list..n";
        $WMS = `ps -A | awk '{print $4}' | grep $wm[$x]`;
        $WMS =~ s/n//;
        
        if( $WMS =~ /^$wm[$x]$/ ) {
            print "Found $WMS as your WM..n" unless $quite == 1;
            getWMtheme($WMS);
            $found = 1;
        }
        $x++;
    }    
    
    $found == 0 && print "WM not found, Maybe your WM isn't in the array?...n" unless $quite == 1;
}

picqn6.png

[!!] Updated:: 0.2

Checks through the PS list for a DE, rather than basing it on .xinitrc
Added untested support for GNOME
Added more WM Theme checks ( Blackbox, Openbox, Metacity, Fluxbox). Please MSG me with more WM that you use and their config files


rawr

Offline

#11 2006-09-24 18:56:14

barebones
Member
Registered: 2006-04-30
Posts: 235

Re: Screenshot info grabber - in development!

I tried using your script, but it errors out for me. It's probabily because I don't use feh to set my background.

$ ./info.pl 
No enviroment selected, going by defaults..
No such file or directory
Failed to open "~/.fehbg" for reading...

Offline

#12 2006-09-24 19:06:27

rab
Member
Registered: 2006-06-15
Posts: 185

Re: Screenshot info grabber - in development!

What DE do you use? I added GNOME support, but its still untested...


rawr

Offline

#13 2006-09-24 23:12:02

barebones
Member
Registered: 2006-04-30
Posts: 235

Re: Screenshot info grabber - in development!

I'm running fluxbox. Also, I use esetroot to set the background, if thats of any use.

Offline

#14 2006-09-24 23:13:57

rab
Member
Registered: 2006-06-15
Posts: 185

Re: Screenshot info grabber - in development!

Any luck with the updated script? ( not with the wallpaper part )


rawr

Offline

#15 2006-09-24 23:19:20

barebones
Member
Registered: 2006-04-30
Posts: 235

Re: Screenshot info grabber - in development!

No, the new script fails the same way that the first one does. If you need any other info, let me know. I just mentioned that I use esetroot because thats the only lead I had on what might be causing this.

Offline

#16 2006-09-24 23:30:06

rab
Member
Registered: 2006-06-15
Posts: 185

Re: Screenshot info grabber - in development!

Try now, it should run through if it found certin files or not


rawr

Offline

#17 2006-09-25 03:28:16

barebones
Member
Registered: 2006-04-30
Posts: 235

Re: Screenshot info grabber - in development!

Yeah, it works now, although it doesn't find anything past my WM. Also, after running it, the normal text in my terminal turned from white to the blue used in the output. Perhaps you didn't turn off the output color after you were done?

Offline

#18 2006-09-25 05:43:25

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: Screenshot info grabber - in development!

btw, you can use imagemagic to write the text you script generates on the screenshot itself smile

Offline

#19 2006-09-25 10:57:44

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Re: Screenshot info grabber - in development!

Great work, guys!  If you can iron out the bugs I'll add a link to the next screenshot thread smile

To be honest the background is not a major concern - i mean what use is the name anyway?  I rename all the backgrounds I D/L so that is no use to anyone.

As long as you can get GTK theme, icons, WM/DE, that's great.  What about KDE though?

You also need to add ion3, fvwm, ratpoison, dwm to the wm list smile

Am going to sticky this to the desktop env forum so more people see it.

Offline

#20 2006-09-25 12:00:26

Kermit
Member
From: Chorzów, Poland
Registered: 2006-03-25
Posts: 78

Re: Screenshot info grabber - in development!

dtw wrote:

To be honest the background is not a major concern - i mean what use is the name anyway?  I rename all the backgrounds I D/L so that is no use to anyone.

So we can give a special parametr where user might input the URL for backgorunds. For example:

./screen -u http://iamforg.com/forggie.jpg

Kermit.

Offline

#21 2006-09-25 19:33:22

sweiss
Member
Registered: 2004-02-16
Posts: 635

Re: Screenshot info grabber - in development!

I haven't started digging around for this, but if anyone wants to implement it for KDE, plenty of information can be found in ~/.kde/share/config/kdeglobals.

Maybe I'll do that bit if I got time on the weekend.

Offline

#22 2006-09-25 23:12:07

Global Havok
Member
Registered: 2006-02-20
Posts: 79

Re: Screenshot info grabber - in development!

If you guys are interested the code i edited to read the gtk settings from gtkrc-2.0 instead of gconf let me know.

Edit: nevermind  smile

Offline

#23 2006-09-26 00:40:19

rab
Member
Registered: 2006-06-15
Posts: 185

Re: Screenshot info grabber - in development!

Updated::
+ recoded to be based of the PS list

If you want more WM to be supported please post their config files, Also i still need KDE's files.

XFCE is yet to be tested. Please post any errors, mistakes or improvements.

#!/usr/bin/perl

use Switch;

@wm = ("fluxbox", "openbox", "blackbox",
       "xfwm", "metacity");
%de = ("gnome", "gnome-session",
       "xfce", "xfce",
       "kde", "kde");
$quite = 0; # Prints little debugging messages if set to 0;
$tryWP = 1; # trys to find your wallpaper if set to 0;

## Dont alter after this ##
my $isDE = 0;
my $version = `cat /etc/arch-release`;
my $kernel = `uname -r`;
$version =~ s/s+/ /g;
$kernel =~ s/s+/ /g;

parsePS(2);
$isDE == 0 && print "No DE found, not running one?..n" unless $quite == 1;

if( $isDE == 0 ) {
    if( !open(GTKRC, "<", "$ENV{HOME}/.gtkrc-2.0")  ) {
        print "$ENV{HOME}.gtkrc-2.0 -> $!...n";
    } else {
        while( <GTKRC> ) {
            if( /include "$ENV{HOME}/.themes/(.+)/gtk-(1|2).0/gtkrc"/ ){
                $THEME = $1;
            }
            if( /gtk-icon-theme-name.*=.*"(.+)"/ ) {
                $ICON = $1;
            }
            if( /gtk-font-name.*=.*"(.+)"/ ) {
                $FONT = $1;
            }
        }
        close(GTKRC);
    }

    ## Processes First
    parsePS(1);
    
    ## Couldn't find a WM in PS
    $WM =~ /Unknown/ && print "No WM found, yours isn't on the list?...n" unless $quite == 1;
} else {
    grabDEinfo($DE);
}       


print "e[0;34m
              __
          _=(SDGJT=_
        _GTDJHGGFCVS)                OS: e[0;37m$versione[0;34m
       ,GTDJGGDTDFBGX0               Kernel: e[0;37m$kernele[0;34m
      JDJDIJHRORVFSBSVLe[0;30m-=+=,_e[0;34m        DE: e[0;37m$DEe[0;34m
     IJFDUFHJNXIXCDXDSV,e[0;30m  "DEBLe[0;34m      WM: e[0;37m$WMe[0;34m
    |LKDSDJTDU=OUSCSBFLD.e[0;30m   '?ZWX,e[0;34m   WM Theme: e[0;37m$WMTHEMEe[0;34m
    LMDSDSWH'   `?DCBOSIe[0;30m     DRDS],e[0;34m  Theme: e[0;37m$THEMEe[0;34m
   SDDFDFH'        `0YEWD,e[0;30m   )HDRODe[0;34m  Icons: e[0;37m$ICONe[0;34m
  !KMDOCG            &GSU|e[0;30m_GFHRGO'e[0;34m   Font: e[0;37m$FONTe[0;34m
  HKLSGP'           e[0;30m__e[0;34mTKM0e[0;30mGHRBV)'e[0;34m
 JSNRVW'       e[0;30m__+MNAECe[0;34mIOI,e[0;30mBN'e[0;34m
 HELK['  e[0;30m  __,=OFFXCBGHCe[0;34mFD)
JKGHEHe[0;30m_-#DASDFSLSV='e[0;34m    'EF
!EHTI                    !H
 `0F'                    '!
";

sub parsePS {
    my $x = 0;
    my $y = 0;
    my $found = 0;
    my $psl = `ps -A | awk {'print $4'}`;
    @psl = split(/n/, $psl);

    switch (shift @_) {
        case 1 {
            $WM = "Unknown";
            while( $x < @wm && $found == 0 ) {
                while( $y < @psl ) {
                    print "Testing '$psl[$y]' with '$wm[$x]'n" unless $quite == 1;
                    if( $psl[$y] =~ /$wm[$x]/ ) {
                        $WM = $wm[$x];
                        print "WM found as $WMn" unless $quite == 1;
                        getWMtheme();
                        $found = 1;
                        last;
                    }
                    $y++;
                }
                $y = 0;
                $x++;
                $found == 1 && last;
            }
        }
        case 2 {
            $isDE = 0;
            $DE = "None";
            while( ($dev, $devid) = each(%de) ) {
                while( $x < @psl ) {
                    print "Testing '$psl[$x]' with '$devid'n" unless $quite == 1;
                    if( $psl[$x] =~ /$devid/ ) {
                        $DE = $dev;
                        print "DE found as $DEn" unless $quite == 1;
                        $found = 1;
                        $isDE = 1;
                        last;
                    }
                    $x++;
                }
                $x = 0;
                $found == 1 && last;
            }
        }
    }
}

sub getWMtheme {

    switch($WM) {
        case "openbox" {
            open(FILE, "<", "$ENV{HOME}/.config/openbox/rc.xml")
                || die("$!nFailed to open OpenBox rc.xml...n");
            while( <FILE> ) {
                if( /<name>(.+)</name>/ ) { 
                    print "OB Theme found as $1n" unless $quite == 1;
                    $WMTHEME = $1;
                           last;
                   }
                }
            close(FILE);
        }
        case "metacity" {
            $WMTHEME = `gconftool-2 -g /apps/metacity/general/theme`;
        }
        case "fluxbox" {
            open(FILE, "<", "$ENV{HOME}/.fluxbox/init")
                || die("$!nFailed to open Fluxbox init file...n");
            while( <FILE> ) {
                if( /session.styleFile: /.+/(.+)$/ ) {
                    print "FB Theme found as $1n";
                    $WMTHEME = $1;
                    last;
                }
            }
            close(FILE);
        }
        case "blackbox" {
            open(FILE, "<", "$ENV{HOME}/.blackboxrc")    
                || die("$!nFailed to open Blackbox .blackboxrc file...n");
                        while( <FILE> ) {
                                if( /session.styleFile: /.+/(.+)$/ ) {
                                        print "BB Theme found as $1n";
                    $WMTHEME = $1;
                    last;
                }
            }
            close(FILE);
        }
        case "xfwm" {
            open(FILE, "<", "$ENV{HOME}/.config/xfce4/mcs_settings/xfwm4.xml")
                || die("XFCE4 -> $!...n");
            while( <FILE> ) {
                if( /<option name="Xfwm/ThemeName" type="string" value="(.+)"/>/ ) {
                    $WMTHEME = $1;
                }
            }
            close(FILE);
        }
        else {
            $WMTHEME = "Unknown";
        }
    }
}

sub grabDEinfo {

    switch(shift @_) {
        case "gnome" {
            $THEME = `gconftool-2 -g /desktop/gnome/interface/gtk_theme`;
            $ICON = `gconftool-2 -g /desktop/gnome/interface/icon_theme`;
            $FONT = `gconftool-2 -g /desktop/gnome/interface/font_name`;
            parsePS(1);            
        }
        case "xfce" {
            open(FILE, "<", "$ENV{HOME}/.config/xfce4/mcs_settings/gtk.xml")
                || die("XFCE4 GTK -> $!...n");
            while( <FILE> ) {
                if( /<option name="Gtk/FontName" type="string" value="(.+)"/>/ ) {
                    $FONT = $1;
                }
                if( /<option name="Net/IconThemeName" type="string" value="(.+)"/>/ ) {
                    $ICON = $1;
                }
                if( /<option name="Net/ThemeName" type="string" value="(.+)"/>/ ) {
                    $THEME = $1;
                }
            }
            close(FILE);
            parsePS(1);
        }
    }
}

rawr

Offline

#24 2006-09-26 02:38:27

stonecrest
Member
From: Boulder
Registered: 2005-01-22
Posts: 1,190

Re: Screenshot info grabber - in development!

xfce now works here wink

              __
          _=(SDGJT=_
        _GTDJHGGFCVS)                OS: Arch Linux 0.7.2 (Gimmick) 
       ,GTDJGGDTDFBGX0               Kernel: 2.6.18-ARCH 
      JDJDIJHRORVFSBSVL-=+=,_        DE: xfce
     IJFDUFHJNXIXCDXDSV,  "DEBL      WM: xfwm
    |LKDSDJTDU=OUSCSBFLD.   '?ZWX,   WM Theme: Gilouche
    LMDSDSWH'   `?DCBOSI     DRDS],  Theme: MurrinaGraphite
   SDDFDFH'        `0YEWD,   )HDROD  Icons: Tango
  !KMDOCG            &GSU|_GFHRGO'   Font: Verdana 8
  HKLSGP'           __TKM0GHRBV)'
 JSNRVW'       __+MNAECIOI,BN'
 HELK['    __,=OFFXCBGHCFD)
JKGHEH_-#DASDFSLSV='    'EF
!EHTI                    !H
 `0F'                    '!

There's still the bug that the color doesn't get turned off though, and it turns your prompt blue.


I am a gated community.

Offline

#25 2006-09-26 03:46:26

thaswiftness
Member
Registered: 2006-05-05
Posts: 42

Re: Screenshot info grabber - in development!

The gtk-theme and icon-theme weren't working for me. I guessed it was because my gtk theme is in /usr/share/themes and I specify my icon theme in gtkrc.mine. So I changed/added to your script a little. I'm not a programmer really, so take it as you will.
Just the part I added to.

parsePS(2);
$isDE == 0 && print "No DE found, not running one?..n" unless $quite == 1;

if( $isDE == 0 ) {
   if( !open(GTKRC, "<ENV> $!...n";
   } else {
      while( <GTKRC> ) {
         if( /include "/usr/share/themes/(.+)/gtk-(1|2).0/gtkrc"/ ){
            $THEME = $1;
         }
         if( /gtk-icon-theme-name.*=.*"(.+)"/ ) {
            $ICON = $1;
         }
         if( /gtk-font-name.*=.*"(.+)"/ ) {
            $FONT = $1;
         }
      }
      close(GTKRC);
   if( !open(GTKRCMINE, "<ENV> $!...n";
   } else {
      while ( <GTKRCMINE> ) {
      if( /gtk-icon-theme-name.*=.*"(.+)"/ ) {
         $ICON = $1;
      }
   }
   close(GTKRCMINE);

   }
}

At least it works completely for me now big_smile

[URL=http://img138.imageshack.us/img138/3822/screenscriptmx6.png]screenscriptmx6.th.png[/URL]

Offline

Board footer

Powered by FluxBB