个人工具

“UbuntuHelp:Torsmo”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第4行: 第4行:
 
First we have to install the package:
 
First we have to install the package:
 
<pre><nowiki>
 
<pre><nowiki>
apt-get install torsmo
+
  apt-get install torsmo
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Make Configuration File ===
 
=== Make Configuration File ===
 
Move to user directory, unzip the example and rename it:
 
Move to user directory, unzip the example and rename it:
 
<pre><nowiki>
 
<pre><nowiki>
cp /usr/share/doc/torsmo/examples/torsmorc.example.gz ~/
+
  cp /usr/share/doc/torsmo/examples/torsmorc.example.gz ~/
gunzip torsmorc.example.gz
+
  gunzip torsmorc.example.gz
mv torsmorc.example.gz .torsmorc
+
  mv torsmorc.example.gz .torsmorc
 
</nowiki></pre>
 
</nowiki></pre>
 
As user you are able to start torsmo by typing:
 
As user you are able to start torsmo by typing:
 
<pre><nowiki>
 
<pre><nowiki>
torsmo
+
  torsmo
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Display your ip-address ===
 
=== Display your ip-address ===
第21行: 第21行:
 
File: ~/.torsmo_ip
 
File: ~/.torsmo_ip
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
  #!/bin/sh
/sbin/ifconfig | awk '/P-t-P/ { split($2, x, /:/); print x[2]; exit; }'
+
  /sbin/ifconfig | awk '/P-t-P/ { split($2, x, /:/); print x[2]; exit; }'
 
</nowiki></pre>
 
</nowiki></pre>
 
Change it to be executable:  
 
Change it to be executable:  
 
<pre><nowiki>
 
<pre><nowiki>
chmod 775 ~/.torsmo_ip
+
  chmod 775 ~/.torsmo_ip
 
</nowiki></pre>
 
</nowiki></pre>
 
And make sure to change "P-t-P" to the identifier that /sbin/ifconfig gives,  
 
And make sure to change "P-t-P" to the identifier that /sbin/ifconfig gives,  
第32行: 第32行:
 
File: ~/.tormo_ip
 
File: ~/.tormo_ip
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
  #!/bin/sh
/sbin/ifconfig eth0 | awk '/inet addr/ { split($2, x, /:/); print x[2]; exit; }'
+
  /sbin/ifconfig eth0 | awk '/inet addr/ { split($2, x, /:/); print x[2]; exit; }'
 
</nowiki></pre>
 
</nowiki></pre>
 
Where "eth0" is the networkcard of which you want to display the ip-address.
 
Where "eth0" is the networkcard of which you want to display the ip-address.
第39行: 第39行:
 
File: ~/.torsmorc
 
File: ~/.torsmorc
 
<pre><nowiki>
 
<pre><nowiki>
ip: ${execi 180 ~/.torsmo_ip}
+
  ip: ${execi 180 ~/.torsmo_ip}
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Weather Display ===
 
=== Weather Display ===
第45行: 第45行:
 
File: ~/tweather.sh
 
File: ~/tweather.sh
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/bash
+
  #!/bin/bash
city="Rotterdam"
+
  city="Rotterdam"
link=NLXX0015_c.html?force_units=1
+
  link=NLXX0015_c.html?force_units=1
file=/tmp/weather.txt
+
  file=/tmp/weather.txt
location=http://weather.yahoo.com/forecast/$link
+
  location=http://weather.yahoo.com/forecast/$link
lynx -accept_all_cookies -dump $location > $file
+
 
begin=`cat -n $file | grep "Currently" | cut -d ' ' -f5`
+
  lynx -accept_all_cookies -dump $location > $file
end=`expr $begin + 40`
+
  begin=`cat -n $file | grep "Currently" | cut -d ' ' -f5`
head -n $end $file > tmp.t
+
  end=`expr $begin + 40`
tail -n 41 tmp.t > $file
+
 
case $1 in
+
  head -n $end $file > tmp.t
Today)  head -n 6 $file | sed '3d' ;;
+
  tail -n 41 tmp.t > $file
Tomorrow)
+
 
begin=`cat -n $file | grep 'Today Tomorrow' | cut -d ' ' -f5`
+
  case $1 in
end=`cat -n $file | grep 'Extended' | cut -d ' ' -f5`
+
      Today)  head -n 6 $file | sed '3d' ;;
num=`expr $end - $begin - 1`
+
      Tomorrow)
end2=`expr $begin + 7`
+
        begin=`cat -n $file | grep 'Today Tomorrow' | cut -d ' ' -f5`
head -n $end2 $file > tmp.t
+
        end=`cat -n $file | grep 'Extended' | cut -d ' ' -f5`
tail -n 3 tmp.t | sed 's/sky/\n sky/' | sed '4d' ;;
+
        num=`expr $end - $begin - 1`
*) exit ;;
+
        end2=`expr $begin + 7`
esac
+
 
rm tmp.t
+
        head -n $end2 $file > tmp.t
rm $file
+
        tail -n 3 tmp.t | sed 's/sky/\n sky/' | sed '4d' ;;
 +
      *) exit ;;
 +
  esac
 +
 
 +
  rm tmp.t
 +
  rm $file
 
</nowiki></pre>
 
</nowiki></pre>
 
And place this, somewhere below TEXT in your .torsmorc
 
And place this, somewhere below TEXT in your .torsmorc
 
<pre><nowiki>
 
<pre><nowiki>
${color grey}Weather:
+
 
$color${execi 1800 /home/username/tweather.sh Today}
+
  ${color grey}Weather:
$color  Tomorrow:
+
  $color${execi 1800 /home/username/tweather.sh Today}
$color${execi 1800 /home/username/tweather.sh Tomorrow}
+
  $color  Tomorrow:
 +
  $color${execi 1800 /home/username/tweather.sh Tomorrow}
 
</nowiki></pre>
 
</nowiki></pre>
 
"city" can be renamed to your city. Look at the weather condition of your city at weather.yahoo.com, take the last part of the link and put it in the script after "link".
 
"city" can be renamed to your city. Look at the weather condition of your city at weather.yahoo.com, take the last part of the link and put it in the script after "link".
 
Note: Make sure "lynx" is installed.
 
Note: Make sure "lynx" is installed.
 
<pre><nowiki>
 
<pre><nowiki>
apt-get install lynx
+
 
 +
  apt-get install lynx
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Logged-in Users ===
 
=== Logged-in Users ===
第86行: 第93行:
 
File: ~/.torsmo_users
 
File: ~/.torsmo_users
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
  #!/bin/sh
who | awk '{print $1}' | uniq -c | wc -l
+
  who | awk '{print $1}' | uniq -c | wc -l
 
</nowiki></pre>
 
</nowiki></pre>
 
Make it an executable:  
 
Make it an executable:  
 
<pre><nowiki>
 
<pre><nowiki>
chmod 775 ~/.torsmo_users
+
 
 +
  chmod 775 ~/.torsmo_users
 
</nowiki></pre>
 
</nowiki></pre>
 
Then, in your ~/.torsmorc, after TEXT, search for a nice place to display the current number of logged-in users:
 
Then, in your ~/.torsmorc, after TEXT, search for a nice place to display the current number of logged-in users:
 
File: ~/.torsmorc
 
File: ~/.torsmorc
 
<pre><nowiki>
 
<pre><nowiki>
Current users: ${execi 8 ~/.torsmo_users}
+
  Current users: ${execi 8 ~/.torsmo_users}
 
</nowiki></pre>
 
</nowiki></pre>
 
=== KNOWN PROBLEMS ===
 
=== KNOWN PROBLEMS ===
第104行: 第112行:
 
Uncheck the show_desktop in /apps/nautilus/preferences/
 
Uncheck the show_desktop in /apps/nautilus/preferences/
 
<pre><nowiki>
 
<pre><nowiki>
Menu Bar: Applications > System Tools > Configuration Editor
+
  Menu Bar: Applications > System Tools > Configuration Editor
 
</nowiki></pre>
 
</nowiki></pre>
 
Start Torsmo when I log in:
 
Start Torsmo when I log in:
 
<pre><nowiki>
 
<pre><nowiki>
Menu Bar: System > Preferences > Sessions
+
  Menu Bar: System > Preferences > Sessions
Go to the "Startup Programs"-tab > Add > Startup Command: torsmo
+
  Go to the "Startup Programs"-tab > Add > Startup Command: torsmo
 
</nowiki></pre>
 
</nowiki></pre>
 
This is my [http://www.ju87.nl/torsmo/.torsmorc .torsmorc]
 
This is my [http://www.ju87.nl/torsmo/.torsmorc .torsmorc]

2007年12月6日 (四) 10:56的版本

Install Package

First we have to install the package:

   apt-get install torsmo

Make Configuration File

Move to user directory, unzip the example and rename it:

   cp /usr/share/doc/torsmo/examples/torsmorc.example.gz ~/
   gunzip torsmorc.example.gz
   mv torsmorc.example.gz .torsmorc

As user you are able to start torsmo by typing:

   torsmo

Display your ip-address

You can get torsmo to display your ip-address. Put this into a script called ~/.torsmo_ip File: ~/.torsmo_ip

   #!/bin/sh
   /sbin/ifconfig | awk '/P-t-P/ { split($2, x, /:/); print x[2]; exit; }'

Change it to be executable:

   chmod 775 ~/.torsmo_ip

And make sure to change "P-t-P" to the identifier that /sbin/ifconfig gives, "P-t-P" is for dialup, "inet addr" for networkcards. So the file will look like this: File: ~/.tormo_ip

   #!/bin/sh
   /sbin/ifconfig eth0 | awk '/inet addr/ { split($2, x, /:/); print x[2]; exit; }'

Where "eth0" is the networkcard of which you want to display the ip-address. Then, in your ~/.torsmorc, after the TEXT, put the following: File: ~/.torsmorc

   ip: ${execi 180 ~/.torsmo_ip}

Weather Display

Local weather condition can also be displayed. Write a script named tweather.sh: File: ~/tweather.sh

   #!/bin/bash
   city="Rotterdam"
   link=NLXX0015_c.html?force_units=1
   file=/tmp/weather.txt
   location=http://weather.yahoo.com/forecast/$link

   lynx -accept_all_cookies -dump $location > $file
   begin=`cat -n $file | grep "Currently" | cut -d ' ' -f5`
   end=`expr $begin + 40`

   head -n $end $file > tmp.t
   tail -n 41 tmp.t > $file

   case $1 in
      Today)  head -n 6 $file | sed '3d' ;;
      Tomorrow)
         begin=`cat -n $file | grep 'Today Tomorrow' | cut -d ' ' -f5`
         end=`cat -n $file | grep 'Extended' | cut -d ' ' -f5`
         num=`expr $end - $begin - 1`
         end2=`expr $begin + 7`

         head -n $end2 $file > tmp.t
         tail -n 3 tmp.t | sed 's/sky/\n sky/' | sed '4d' ;;
      *) exit ;;
   esac

   rm tmp.t
   rm $file

And place this, somewhere below TEXT in your .torsmorc


   ${color grey}Weather:
   $color${execi 1800 /home/username/tweather.sh Today}
   $color   Tomorrow:
   $color${execi 1800 /home/username/tweather.sh Tomorrow}

"city" can be renamed to your city. Look at the weather condition of your city at weather.yahoo.com, take the last part of the link and put it in the script after "link". Note: Make sure "lynx" is installed.


   apt-get install lynx

Logged-in Users

Here is a script if you are running an SSH server and like to keep tabs on whos logged on at any given time. Put the following code into a script named ~/.torsmo_users: File: ~/.torsmo_users

   #!/bin/sh
   who | awk '{print $1}' | uniq -c | wc -l

Make it an executable:


   chmod 775 ~/.torsmo_users

Then, in your ~/.torsmorc, after TEXT, search for a nice place to display the current number of logged-in users: File: ~/.torsmorc

   Current users: ${execi 8 ~/.torsmo_users}

KNOWN PROBLEMS

Taken from the http://torsmo.sourceforge.net/ site of the writers of this program: "Drawing to root or some other desktop window directly doesn't work with all window managers. Especially doesn't work well with Gnome and it has been reported that it doesn't work with KDE either. Nautilus can be disabled from drawing to desktop with program gconf-editor. Uncheck show_desktop in /apps/nautilus/preferences/. There is -w switch in torsmo to set some specific window id. You might find xwininfo -tree useful to find the window to draw to. You can also use -o argument which makes torsmo to create its own window." What I did, to make it work well, is: Uncheck the show_desktop in /apps/nautilus/preferences/

   Menu Bar: Applications > System Tools > Configuration Editor

Start Torsmo when I log in:

   Menu Bar: System > Preferences > Sessions
   Go to the "Startup Programs"-tab > Add > Startup Command: torsmo

This is my .torsmorc