The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Kernel Screensaver?

    Discussion in 'Linux Compatibility and Software' started by inspirations365, Jun 29, 2011.

  1. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Hey guys!

    It's been a couple of years! I was here before asking about this very same subject in this thread, and now I'm trying to get the same thing to work on Snow Leopard. I know things should largely be the same, 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.

    Any help is GREATLY appreciated! :cool:
     
  2. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    I'm not a Perl programmer, but it seems Jas' shell script suffered from the vBulletin software eating anything enclosed in a less-than-symbol "<", some text, and a greater than symbol ">".

    You could edit line 3 of the generated perl script so that the while semi-colon becomes
    while space less-than-symbol DATA greater-than-symbol semi-colon. or while "<"DATA">"; without the double-quotes ".
     
  3. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Thanks for your reply!

    I've tried both
    Code:
    "(DATA)"
    ^Pretend that's bracketed...as well as
    Code:
    <"DATA">
    and the result is the same:

    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.


    Ugh...I hate this feeling of being close and hitting these small snags...but such is the life of a programmer, right?
     
  4. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    I downloaded Phosphor for Mac last night and didn't see an option for executing a text program. I looked around in the directores and found phosphor.xml, but it seems that the options presented to the user are contained in another Perl script...
     
  5. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    You mean...none of these options will allow me to do the screensaver thing? This is the release I got off the xscreensaver site yesterday...
     

    Attached Files:

  6. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    Maybe this will make it a bit clearer?

    [​IMG]
     
  7. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Can you describe which changes you made?

    I notice you don't have any of the "\" slashes on the rand or print lines of your program. Is this intentional? Does your program run when you tested it?

    Can you also tell me what the "-w" flag will do in this context?

    Thanks, timberwolf!

    EDIT***

    Gave it a try editing the .sh file to mimic yours, "\"s and all. No dice. I even changed the DATA variable back and forth again to make sure it wasn't causing any issues.
     
  8. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    The phosphor-kernel-script.sh is a shell script (program) used to create the phosphor-kernel-src.pl perl script (program).

    Oops, I really should have said, I was debugging and hence editing phosphor-kernel-src.pl program, rather than editing the shell script and rerunning that to generate a new version of the perl script. The backslashes get consumed by the shell as the shell script is interpreted - mmmm, what do I mean? Try the following in a terminal:

    echo Fred

    then try

    echo "Fred"

    Do you see the double quotes on the second echo output, no because the shell strips them off. To generate the perl script correctly certain characters that would be stripped off by the shell interpreter have to be protected, so the backslash is used to escape those characters.

    The phosphor-kernel-script.sh effectively only needs to be run once (assuming it generated the resultant perl program correctly, if you want you can delete the shell script once you've created the perl script.

    The -w switches on extra warning messages, or least that's what I vaguely remember, I've always put that switch on - and it didn't help on this occasion :)

    You could also read the man page for perl to find out about the -w switch i.e. type in a terminal: man perl

    In the man viewer, type the letter q to quit.
     
  9. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30

    Oooh, did it work for you? Should I be working on the shell script instead of the program, assuming I create it correctly?
     
  10. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    Okay, the only bit I added was the DATA and <, and > symbols on the line. Yes, I can run the perl script and it generates the path/filename of a random kernel source file.

    For completeness, I've edited the shell script, so you can see what it is supposed to look like. This would be so much easier if the vBulletin software would allow verbatim code quotes :(

    [​IMG]
     
  11. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Same script, different result.
    *rant rant rant*
     

    Attached Files:

  12. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    What does generated perl code look like?

    The shell script is just being used to create the perl code file and then appending all the .c source filenames to the perl file.
     
  13. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Looks like it's generating the files properly...idk.
     

    Attached Files:

  14. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    What are the errors generated when you try to execute phosphor-kernel-src.pl ?

    Also note the actual location of Perl on your Mac. Open up Terminal and enter which perl at the prompt. Mine was in /opt/local/bin/perl - that needs to be adjusted at the top of phosphor-kernel-src.pl.

    I've gotten the Perl script to work on my Mac...

    One quick note - I tried some different ways to pipe the output of the Perl script into the phosphor screensaver and it didn't work...
     
  15. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30


    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
    
    ruw-172:~ inspirations365$ which perl
    /usr/bin/perl
    
    It looks the same in the screnshot of my .pl file.

    The error I'm getting is always the same:
    Code:
    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.
     
  16. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    What version of Perl do you have? Are you running Snow Leopard?
     
  17. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    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)
    Yep, 10.6.8.


    Actually I think I got it running. This is my output when the .pl is run in terminal:
    Code:
    ruw-172:~ inspirations365$ /Users/inspirations365/phosphor-kernel-src.pl
    /Users/inspirations365/Documents/linux-2.6.39.2/arch/mips/loongson/common/platform.c
    ?! I didn't change anything...I don't know...

    Now I need the correct command to put into Phosphor to get it to display the contents of the files.
     
  18. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    It was posted somewhere in the original thread, note the space around the pipe symbol seem to be necessary.

    /Users/inspirations365/phosphor-kernel-src.pl | xargs cat
     
  19. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    No dice. Putting that in the text field just echos the command back on the screen.

    EDIT***

    Running the command from 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 ([email protected])
     * 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  */
     
  20. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    Yeah, it's not going to work out of the box.

    If you're interested, the preferences are stored under /Library/Screen Savers/Phosphor.saver/Contents/Resources. There you'll find two files, phosphor.xml and xscreensaver-text (another Perl script).

    The Perl script is somehow used to generate the output that's printed to the screen - executing with the --program switch gives the right output.

    I just don't know what files need to be modified in order to show the text-program option under System Preferences.
     
  21. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    Well, that sucks. And there's frighteningly little documentation in this matter on the internet. The only person I can tell that's solved this issue is the one who's guide I linked to in my original post- but he never says specifically how he does it!

    I'll keep at it. Thanks!
     
  22. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    Just got it working!

    This is how I did it - I added the following line to the phosphor.xml file (thanks to this link - http://eins.serverbox.org/chad/index.php?option=com_content&task=view&id=100&Itemid=29):

    PHP:
    <file id='program' _label="Text Program" arg="-program %"/>
    Then create yet another shell script (mind the backticks):

    Code:
    #!/bin/sh -e                                                                   
    cat `/path/to/phosphor-kernel-src.pl`
    
    Make the new script executable with chmod u+x script-name

    Go to System Preferences and select the new shell script and behold - kernel source as a screensaver...

    Here are some screenshots -

    Phosphor Options pane after modifying phosphor.xml:
    Screen shot 2011-06-30 at 4.33.49 PM.png
    The new option appears right under the 'Fade' slider.

    Phosphor Screensaver Preview pane:
    Screen shot 2011-06-30 at 4.34.15 PM.png
     
    Last edited by a moderator: May 7, 2015
  23. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    I just found that link too and was about to post here! lol

    I'm still doing something wrong, believe it or not.

    I pasted the line, no problems there, Phosphor shows the new box.

    then I did a sudo nano scripthelp.sc, pasted and changed the path, saved, chmodded with your commands, and I get:

    /bin/sh:


    Dammit.
    Can you walk me through it in a bit more detail? Gosh, you're awesome!
     
  24. hf2046

    hf2046 Notebook Guru

    Reputations:
    18
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    15
    Try running your helper script on its own and see if it prints out a kernel source file. It should work on its own.

    You also don't need to have superuser privileges to create the helper script and make it executable.

    If all else fails, try deleting your helper script and re-creating it with your normal user account.
     
  25. inspirations365

    inspirations365 Notebook Consultant

    Reputations:
    42
    Messages:
    120
    Likes Received:
    0
    Trophy Points:
    30
    YESSSSSS THAT WAS IT.

    Thank you thank you thank you thank you thank you!

    Incredible. Absolutely stunning. Awesome.