Now that you’ve installed Arch Linux, let’s create a simple C program to startup the desktop.
First off, you need to install twm and xterm:
sudo pacman -S xorg-twm
sudo pacman -S xterm
Xterm is the original terminal emulator for the X Window System (which is a windowing system for graphical displays for Linux and other UNIX systems.) Twm is one of the oldest window manager, which is a component of the X Window System that draws borders around application windows, puts up a title bar, and moves/resizes the windows.
Your X installation includes a script called startx
, which launches the
core components of the X Window System, and then starts up your choices of
window manager and other applications, which you can specify in your
~/.xinitrc file. If
startx
does not find ~/.xinitrc
, by default it will start twm
window
manager and three instances of xterm
terminal emulators. Try it! This is
the UNIX desktop circa 1989. (You can quit by typing “exit” in the left
terminal window.)
Create a program, named launchx
, that forks then executes a shell script
specified by a command line argument. If no command line argument is
provided, the default script to run is startx
.
For example, to run startxfce4
, you should be able to run:
./launchx startxfce4
The program should wait for the child process to return, then log your
activity to a file in your home directory, named .launchx.log
, with
the oldest log messages at the top. Each session should append to the
log file the current time and message. Here is how your log file should
look:
[2016-01-17 15:07:12] Starting startxfce4 session...
[2016-01-17 16:22:34] Your startxfce4 session lasted 1 hour 15 minutes and 22 seconds.
[2016-01-18 03:39:08] Starting startx session...
[2016-01-18 05:44:50] Your startx session lasted 2 hours 5 minutes and 42 seconds.
Note that:
.launchx.log
is a dot
file.
The program should handle any errors that may occur.
You are also required to submit a Makefile which generates the launchx
program simply by typing make
.
Hint: You can check out the different time and date functions available, and how to access the HOME environment variable in section 6.10 and 7.9 of APUE, respectively.
You are to submit a single tar.gz file named as follows:
UNI-hw1.tar.gz
Obviously, “UNI” should be replaced with your actual uni. The tarball
contains a single top level directory hw1
, which contains the following
files:
hw1/Makefile
hw1/launchx.c
hw1/screenshot.png (or screenshot.jpg or other common image format)
The last one is the screenshot of your Arch Linux VM running your choice of desktop environment (which may or may not be Xfce as I suggested).
Last updated: 2016–01–20