Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

inspirations365

macrumors regular
Original poster
Dec 28, 2008
195
0
Hey guys,

I was just recalling rather fond memories of my time spent learning Ubuntu (not), and one of my favorite little projects I undertook was configuring xscreensaver and Phosphor (I think that was them) to display pieces of the kernel in true techie spirit.

Does anyone know how I would accomplish the same effect in Snow Leopard?

Here's a link to what I'm talking about.

Also a link to how to configure it for Linux. It shouldn't be too hard to get onto SL, right?

Any help is appreciated!


EDIT***
I know things should largely be the same as they were here, but there are some significant things I must me missing since I cannot get jas's fantastic guide (along with these minor corrections to it) to work on my computer.

This time, I do have both Phosphor and the kernel ready, I just need to know how to make the script (or any other script for that matter, if anyone knows one) run properly. I keep getting the error when I run the perl script

"syntax error at /usr/local/bin/phosphor-kernel-src.pl line 3, near "while ;"
Execution of /usr/local/bin/phosphor-kernel-src.pl aborted due to compilation errors."

And yes, I did make sure I have the DATA correction after the while above.

And before anyone makes a smart remark, I posted this here because it has much more to do with kernels and things of a Linux nature than an OS X matter.


Long story short, I'm attempting to use xscreensaver and Phosphor to create a simple screensaver that displays portions of the kernel code. I'm having problems getting the Perl script to correctly run and I'm not sure what my issue could be. I've tried posting this topic here as well, but nothing's worked yet.

Any help is greatly appreciated!
 
Last edited by a moderator:
Post your code.

We need to see your actual code, exactly as you're using it on your system, not just links to other people's code.

I copied and pasted this fragment of shell script to my system, where it worked perfectly.
Code:
#!/bin/bash
file="./dummyout"

[COLOR="Blue"]cat << EOF > "$file"
#!/usr/bin/perl
srand;
rand(\$.) < 1 && (\$line = \$_) while <DATA>;
print \$line;
__DATA__
EOF
[/COLOR]
echo "data goes here" >> "$file"
echo "more data here" >> "$file"
The created perl file (dummyout) is this:
#!/usr/bin/perl
srand;
rand($.) < 1 && ($line = $_) while <DATA>;
print $line;
__DATA__
data goes here
more data here
yet more data
I tried running the above perl file, and it worked fine.

The blue-hilited part of the first fragment is exactly what the linked-to articles show. So in theory, if you're following those articles correctly, you should get a well-formed perl file. That's why we need to see exactly what your files contain.
 
There's my script and perl files respectively.
 

Attachments

  • Screen shot 2011-06-30 at 12.37.01 PM.jpg
    Screen shot 2011-06-30 at 12.37.01 PM.jpg
    465.4 KB · Views: 85
  • Screen shot 2011-06-30 at 1.21.39 PM.jpg
    Screen shot 2011-06-30 at 1.21.39 PM.jpg
    443.6 KB · Views: 92
Please post the actual text of the files.

Copy and paste the text from the files into a reply post.
Use the CODE tags as explained here:
https://forums.macrumors.com/threads/747660/

I can't run pictures, nor can I diff your pictures with the text files on my machine. And the resolution on the pictures isn't really adequate to do a visual comparison; much too jaggy, although it looks like you probably have the <DATA> in the perl file.

So assuming there really is a <DATA> in the perl file, post exactly what version of perl you're using to run this code.
 
.sh

Code:
!/bin/sh

file=/Users/inspirations365/phosphor-kernel-src.pl     # script to create
linux_src_dir=/Users/inspirations365/Documents/linux-2.6.39.2    # location of kernel src

cat << EOF > "$file"
#!/usr/bin/perl
srand;
rand(\$.) < 1 && (\$line = \$_) while <DATA>;
print \$line;
__DATA__
EOF
find -L "$linux_src_dir" -name \*.c >> $file
chmod 755 $file


.pl
Code:
#!/usr/bin/perl
srand;
rand($.) < 1 && ($line = $_) while <DATA>;
print $line;
__DATA__
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/bootp.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/bootpz.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/main.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/misc.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/tools/mkbb.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/tools/objstrip.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/alpha_ksyms.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/asm-offsets.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/binfmt_loader.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/console.c

you get the idea


Code:
ruw-172:~ inspirations365$ perl -v

This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
 
Code:
#!/usr/bin/perl
srand;
rand($.) < 1 && ($line = $_) while <DATA>;
print $line;
__DATA__
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/bootp.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/bootpz.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/main.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/misc.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/tools/mkbb.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/tools/objstrip.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/alpha_ksyms.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/asm-offsets.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/binfmt_loader.c
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/kernel/console.c
When I copy and paste that exact text into a file (dummypaste.pl), set its executable bits (chmod a+x dummypaste.pl), then enter the command line:
Code:
./dummypaste.pl
it works fine.

The perl version I have is the same as yours, so that's probably not it.

Maybe there's a problem with the length of your pl file. Try it with a shorter version, such as the truncated fragment you posted.

Or maybe the contents of /usr/local/bin/phosphor-kernel-src.pl isn't quite what you think it is. You can zip the text files and attach them to a post. Or you can upload to someplace like pastebin and post a URL here.
 
When making that test fragment into it's own file:

Code:
ruw-172:desktop inspirations365$ chmod 755 testfile.pl
chmod: Unable to change file mode on testfile.pl: Operation not permitted
ruw-172:desktop inspirations365$ sudo chmod 755 testfile.pl
ruw-172:desktop inspirations365$ /Users/inspirations365/Desktop/testfile.pl
/Users/inspirations365/Documents/linux-2.6.39.2/arch/alpha/boot/bootpz.c

That's the end of the file.

Hm...
 

Attachments

  • phosphor-kernel-src.pl.zip
    93.6 KB · Views: 89
The full-size downloadable works fine when run on my machine.

I think you should look very carefully at the full execution pathway that's triggering the error. The thing you think you're executing may not be what's actually executing. For example, if PATH is different in two execution contexts.


And I think it's weird that you don't seem to have write permissions for chmod on files in your own Desktop folder. If that's a sign of damage, maybe you have file-system damage. It could just be cargo-cult debugging, but it won't hurt to use Disk Utility and run a Verify Disk and a Verify Disk Permissions.
 
Whoa...I just got this when I ran the .pl file:

Code:
ruw-172:~ inspirations365$ /Users/inspirations365/phosphor-kernel-src.pl
/Users/inspirations365/Documents/linux-2.6.39.2/arch/mips/loongson/common/platform.c

So it is in fact, working?! Okay then, what command should I put into Phosphor to get it to run the Perl now?

If you can't see, the options are
-Computer name and time

-Text (next to it is a data entry box where I put the command in last time I wanted to do this)

-File (choosing the .pl file does not produce the desired result, but it does go through *.c files

-URL


EDIT***

Running the command from the tutorial in terminal as a test will yield the following:
Code:
 /Users/inspirations365/phosphor-kernel-src.pl | xargs cat
/*
 *  linux/fs/ext3/bitmap.c
 *
 * Copyright (C) 1992, 1993, 1994, 1995
 * Remy Card (card@masi.ibp.fr)
 * Laboratoire MASI - Institut Blaise Pascal
 * Universite Pierre et Marie Curie (Paris VI)
 */

#include <linux/buffer_head.h>
#include <linux/jbd.h>
#include <linux/ext3_fs.h>

#ifdef EXT3FS_DEBUG

static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};

unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars)
{
	unsigned int i;
	unsigned long sum = 0;

	if (!map)
		return (0);
	for (i = 0; i < numchars; i++)
		sum += nibblemap[map->b_data[i] & 0xf] +
			nibblemap[(map->b_data[i] >> 4) & 0xf];
	return (sum);
}

#endif  /*  EXT3FS_DEBUG  */
 

Attachments

  • Screen shot 2011-06-30 at 9.55.05 AM.jpg
    Screen shot 2011-06-30 at 9.55.05 AM.jpg
    416.5 KB · Views: 94
You should probably do some basic testing first.

Judging by the 4 radio-button options, the first one seems like a good start, because it has no parameters.

The "Text" one seems to be asking for some constant text to be displayed on the screensaver. That's just a guess, but it seems reasonable.

The rest I have no idea. I'd have to guess at what the Phosphor screen-saver is expecting or wanting to use. I'm willing to help with shell scripts, but downloading and running a screensaver is over the line for me.

None of the options suggests (to me) that there is an option for running a script, which is how your phosphor-kernel-src.pl script needs to be treated. Reading the pl script as a file would be wrong; you don't want to display the pl file, you want to execute it and use its output as the pathname of the file to display (a level of indirection). If there's a hook in Phosphor that runs a script, I don't see it, and can only guess what it is.

Maybe it's time for you to refer to the documentation for the screensaver.
 
Last edited:
I found this which nets me the selection I need, but it doesn't quite work still.

Still digging...

FINAL EDIT!!!!!!!!!

Got it!

Courtesy of user hf2046, here's how to get it working:

Using that same link I posted above, add the following under /Library/Screen Savers/Phosphor.saver/Contents/Resources/phosphor.xml:

Code:
<file id="program" _label="Text Program" arg="-program %"/>

Then create another shell script as a regular user (no sudo) with the contents:

Code:
#!/bin/sh -e                                                                    
cat `/path/to/phosphor-kernel-src.pl`

Backticks!!

Then go into Sys Prefs, select Phosphor, point it to your new script, and you're all set!

Thanks for all your help, chown33 and everyone who's been keeping up with this topic!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.