XFCE

From OLPC
Revision as of 06:41, 26 February 2008 by Dov (talk | contribs) (→‎Rotation)
Jump to navigation Jump to search

Xfce is a lightweight but powerful desktop environment that will work well on the XO. The following is a tutorial for using Xfce on the XO based on the article from the Free Like GNU article and several forum posts.

Preamble

Please read the following steps before proceeding to make sure you understand what is involved! We take no responsibility for you making your XO unbootable. Although the process is reasonably safe for your XO, you should know how to and have the ability to wipe the XO and start fresh using a USB stick incase you get into trouble!

Please also note that Xfce and other third-party modifications (all non .xo bundled applications) to your XO may be rendered inoperative when you upgrade the base OS to a new build. (See http://dev.laptop.org/ticket/6317)

Instructions

Get Root

  • Establish a connection to the internet. You will need the ability to connect to the internet to retrieve and update files from the OPLC's repositories. "yum" is the command that will retrieve the files you request and it will automatically install them. You will need to have "root" access to use yum.
  • Get "root": Use the terminal activity and type su at the prompt and hit the return key. Your command prompt will now end with "#" this means you have "root" and can change any file on the computer.
$ su
#

Install Packages

  • Install xfce, this will give you a very basic desktop environment and the ability to customize it. This will download about 40MBs to ram then install the files automatically.
# yum install xfdesktop xfce-utils xfce-mcs-plugins xfce4-session
  • optional packages: orage (calendar), xfce-mixer (volume control), system-config-date (set datetime/timezone), genmon (generic monitor - can be used to output battery status, for example), systemload (shows CPU and memory usage)
# yum install orage xfce4-mixer system-config-date xfce4-genmon-plugin xfce4-systemload-plugin
  • installing firefox requires that you remove its exclusion from the XO's repository list
    • open the repository file with the following command:
# nano /etc/yum.repos.d/olpc-koji-ship2.repo 
    • remove the firefox entry from the last line, then save using CTRL+X and confirm with "y":
exclude=firefox,seamonkey,mozplugger,kdebase,kernel
    • install Firefox by running this command
# yum install firefox
  • tuxpaint, gimp, and gcompris and other popular applications can be found in the standard repositories - these can also be installed using yum:
# yum install tuxpaint gimp gcompris
    • start tuxpaint with 1024x768 and fullscreen
$ tuxpaint --1024x768 --fullscreen

Manage WiFi Networks

You can use wifi-radar to manage your wireless connection within xfce

# yum install wifi-radar

You can run wifi-radar through the xfce menu under "Networking". After running it once, a file will be created at /etc/wifi-radar/wifi-radar.conf. Open this file in a text editor, and change the line which reads:

interface = eth1

to read:

interface = eth0

Now, running wifi-radar should allow you to see the available wireless networks and connect to one. You may need to disable the default wireless network manager, by running:

# /etc/init.d/NetworkManager stop

You can permanently disable network manager by

# /sbin/chkconfig NetworkManager off

If you want to run wifi-radar as a daemon which will automatically connect to a preferred network:

$ wifi-radar -d

Displaying Battery Status

  • create a script file (using nano -w /home/olpc/battery.sh) with the following contents:
echo `hal-device | grep charge_level.percentage | awk '{print $3}'`%
  • make the file executable: chmod +x /home/olpc/battery.sh
  • use genmon (see above) to display the battery status in a toolbar
    • right-click on a blank spot on an Xfce toolbar, chose Add Item, select Generic Monitor and clicked Add
    • right-click the new Generic Monitor item, select Properties, and apply the following settings:
      • Command: /home/olpc/battery.sh
      • Label: B
      • Period: 300

Backlight Control

The backlight can be controlled with a simple script:

#!/bin/sh
F="/sys/class/backlight/dcon-bl/brightness"
if [ "$1" -a "$1" -lt 16 -a "$1" -ge 0 ] ; then 
   su -c "echo $1 > $F "
else
   echo -e "useage:\n  $0 number"
   echo "where number is between 0 and 15."
fi

Configure the Backlight Keys

  • Install xbindkeys. Add xbindkeys to the .xsession startup script.
  • Set permissions by adding this line to /etc/rc.local :
chmod 666 /sys/class/backlight/dcon-bl/brightness

That gives non-root users permission to change the brightness.

  • make a script to brighten things:
#!/bin/sh
## /home/olpc/bin/bright
F="/sys/class/backlight/dcon-bl/brightness"
C=`cat "$F"`
if [ "$C" -le 14 ] ; then 
  echo $(($C + 1)) > "$F"
fi

make the script executble

$ chmod +x /home/olpc/bin/bright
  • make a script to dim the backlight by one:
#!/bin/sh
## /home/olpc/bin/dim
F="/sys/class/backlight/dcon-bl/brightness"
C=`cat "$F"`
if [ "$C" -ge 1 ] ; then
  echo $(($C - 1)) > "$F"
fi

and make the script executble:

$ chmod +x /home/olpc/bin/dim
  • Add these lines to /home/olpc/.xbindkeysrc
"/home/olpc/bin/dim"
  F9
"/home/olpc/bin/bright"
  F10

Volume Control

  • as root, install xbindkeys: # yum install xbindkeys
  • as user (not root) create the default config file: xbindkeys -d > /home/olpc/.xbindkeysrc
  • open the config file with a text editor (e.g. nano -w /home/olpc/.xbindkeysrc) and add the following code at the bottom:
# decrease volume (F11)
"amixer -c 0 set Master,0 2dB-"
c:95
# increase volume (F12)
"amixer -c 0 set Master,0 2dB+"
c:96

Rotation

  • xrandr functions as expected, so you can rotate the display to the right by
$ xrandr -o right

To bind rotation to the OLPC rotation key, create the following script:

#!/usr/bin/python
# Rotates the screen 90 degrees on the olpc

import os
import re

# Get current screen orientation
xr = os.popen("xrandr -q").read()
m = re.search(r'\+\d\s+(.*?)\s*\(',xr)
if not m:
    raise "No match!"

# Generate new orientation
rot = m.group(1)
if rot=="":
    new_rot=1
elif rot=="left":
    new_rot=2
elif rot=="inverted":
    new_rot=3
else:
    new_rot=0

os.system("xrandr -o " + str(new_rot))

and make it executable:

chmod +x /home/olpc/bin/rotscreen

Connect it to the OLPC rotate button by adding the following two lines to /home/olpc/.xbindkeysrc:

"/home/olpc/bin/rotscreen"
XF86Display

Note: Rotation does not automatically resize the windows. If you are using fullscreen mode this may be fixed by pressing Alt-F11 twice.

Mounting Removable Filesystems

  1. Insert SD card or usb drive.
  2. Run thunar, the Xfce File Manager.
  3. The removable media should appear in the left-hand column. Click on it to mount it. A df will show that it has been mounted in the appropriate place (/mount/VOLUME_NAME)
  4. To unmount, right click on the media name in the same place and choose unmount.

Make Xfce the default environment

  • in /home/olpc/ create a copy of .xsession-example called .xsession:
#cp /home/olpc/.xsession-example /home/olpc/.xsession
  • edit the .xsession file to launch Xfce on startup:
# nano /home/olpc/.xsession
    • find the commented line that reads #exec xterm - below that line, add the following code:
exec startxfce4
  • use CTRL+X to save and exit
  • use CTRL+ALT+BACKSPACE to restart X, starting Xfce

Trouble?

  • If you reboot and get stuck at the XO logo (with circle around it), hold down power to shutdown then power up again.
    • You can prevent this behavior by disabling the startup logo animation:
      • Open the startup animation logo file /etc/init.d/0-boot-anim-start
      • Above the line saying "# i'm the child", change if os.fork() == 0: to if os.fork() == 'debug': to prevent the animation code from being executed
    • You can still have the startup logo animation and launch xfce:
      • Login as root
      • Disable z-boot-anim-stop
chkconfig --del z-boot-anim-stop
      • Create a shell script /etc/init.d/unfreeze.sh with the following content
#!/bin/sh
mount -t sysfs /sys /sys
# unfreeze the display, which gets frozen at the end of the boot-anim
echo 0 >  /sys/devices/platform/dcon/freeze
umount /sys
      • Link /etc/rc.d/rc5.d/S99unfreeze.sh with /etc/init.d/unfreeze.sh
cd /etc/rc.d/rc5.d
ln -s ../init.d/unfreeze.sh /etc/rc.d/rc5.d/S99unfreeze.sh
      • Edit /etc/init.d/z-boot-anim-stop to change the string "5 99 99" to "5 98 98"
      • Add z-boot-anim-stop with the updated sequence number
chkconfig --add z-boot-anim-stop
  • To make the original XO Sugar desktop the default boot again, rename the .xsession file to anything other than .xsession (.xsession.xfce for instance).

References