osdsh-0.7.0/0040755000175400001440000000000007640201777012253 5ustar moultakusersosdsh-0.7.0/HOWTO/0040755000175400001440000000000007512401424013140 5ustar moultakusersosdsh-0.7.0/HOWTO/keymapconfig0100755000175400001440000000730707507674416015567 0ustar moultakusers#!/usr/bin/wish wm title . "Keymap Configurator" set status "Ready" entry .status -textvariable status button .b1 -text "New Key" -command "new_key" button .b2 -text "Edit Key" -command "edit_key" button .b3 -text "Delete Key" -command "delete_key" button .b4 -text "Load Keymap" -command "load_keymap" button .b5 -text "Save Keymap" -command "save_keymap" button .b6 -text "Quit" -command "destroy ." button .b7 -text "Try this keys" -command "try_keys" label .keyslabel -text "Current keys: " listbox .keys -yscrollcommand ".keysscroll set" scrollbar .keysscroll -command ".keys yview" grid .keyslabel -column 0 -columnspan 3 -row 0 -sticky nsew grid .keys -column 0 -rowspan 5 -sticky nsew -row 1 grid .keysscroll -column 1 -rowspan 5 -row 1 -sticky nsew grid .b7 -column 0 -columnspan 2 -row 6 -sticky nsew grid .b1 -column 2 -row 1 -sticky nsew grid .b2 -column 2 -row 2 -sticky nsew grid .b3 -column 2 -row 3 -sticky nsew grid .b4 -column 2 -row 4 -sticky nsew grid .b5 -column 2 -row 5 -sticky nsew grid .b6 -column 2 -row 6 -sticky nsew grid .status -column 0 -row 7 -columnspan 3 -sticky nsew focus .b1 proc new_key {} { global status keycode keysym where set status "Press a Key" set where "end" set keysym "" set keycode "" .status configure -foreground red # toplevel .getkey # label .getkey.label -text "Press a key here" # pack .getkey.label -fill both -expand 1 bind . {set keycode %k;bind . {};;get_keysym} } proc add_key {} { global status keycode keysym where set status "Ready" .keys insert $where "keycode $keycode = $keysym" } proc delete_key {} { .keys delete active } proc edit_key {} { global status keycode keysym where set where [.keys index active] set lista [split [.keys get active]] set keycode [lindex $lista 1] set keysym [lindex $lista 3] toplevel .edit wm title .edit "Edit Key" label .edit.label -text "Enter the keysym to assign to this keycode" label .edit.keycode -text "Keycode $keycode = " entry .edit.entry -textvariable keysym -width 15 button .edit.button -text "OK" -command "delete_key;add_key;destroy .edit" button .edit.button2 -text "Cancel" -command "destroy .edit" bind .edit.entry "delete_key; add_key; destroy .edit" bind .edit.entry "destroy .edit" grid .edit.label -sticky nsew -row 0 -columnspan 4 grid .edit.keycode .edit.entry .edit.button2 .edit.button -row 1 -sticky nsew } proc save_keymap {} { global status set file [tk_getSaveFile] if {![string equal $file ""]} { set id [open $file w] for {set i 0} {[expr $i < [.keys index end]]} {incr i} { puts $id [string map {"\{" "" "\}" ""} [.keys get $i]] } close $id } set status "Saved keymap in $file" } proc get_keysym {} { global status keycode keysym toplevel .keysym wm title .keysym "Add key" label .keysym.label -text "Enter the keysym to assign\nRecommended: IA1-IA15 or IB1-IB15" entry .keysym.entry -textvariable keysym button .keysym.button -text "OK" -command "add_key; destroy .keysym" grid .keysym.label -row 0 -columnspan 5 -sticky nsew grid .keysym.entry -row 1 -columnspan 4 -sticky nsew grid .keysym.button -row 1 -columnspan 1 -column 5 -sticky nsew bind .keysym.entry "add_key ; destroy .keysym" focus .keysym.entry .status configure -foreground black set status "Ready" } proc try_keys {} { global status set id [open tmpfile w+] for {set i 0} {$i < [.keys index end]} {incr i} { puts $id [string map {"\{" "" "\}" ""} [.keys get $i]] } close $id exec xmodmap tmpfile } proc load_keymap {} { global status where .keys delete 0 end set file [tk_getOpenFile] if {$file != ""} { set id [open $file r] while {[gets $id readbuffer] > 0} { .keys insert end $readbuffer } close $id set status "Read $file" } } osdsh-0.7.0/HOWTO/Multimedia-X-Keyboard-HOWTO.html0100644000175400001440000003453507507674416021011 0ustar moultakusers

This is the firs version of the Multimedia-X-Keyboard-HOWTO

This HOWTO was written by Lord Darth Moultak <moultak@gothicfuneral.zzn.com>

The latest version of this HOWTO can be found at http://www.sourceforge.net/projects/osdsh


How to configure the internet keys on your multimedia keyboard, without using extra daemons, just X and the window manager you already run.


Introduction:

Some time ago, manufacturers of computers started shipping their hardware with keyboards that had "extra" keys on them, these keys were meant to control internet and multimedia features of the system, like playing/stoping/pausing cds and MP3's, connecting to the internet, starting mail and chat programs, and sleeping or suspending the computer, and were marked as such. This is nice, these keyboards look nice and they are comfortable to work with, those keys always come in handy, but they are a pain to configure in X. This is how I did it.


The theory:

When a key is pressed, the keyboard generates a code that the kernel detects, this code is known as "keycode". When X detects a keycode, it looks in a table of symbols to see if that keycode means something. The symbols are the way the software understands the keys, like TAB, UP, DOWN, CTRL, etc...


If the keycode does mean something, (that is, a symbol is asigned to it) the symbol goes to the application that has the keyboard control, like a text editor or a game.


X comes with a series of "keymaps", (files that contain the keycode-keysym pairs ) that work for a lot of keyboards, and even with some "Internet keys", but at least for me, the internet keys were dead. So I needed a new keymap.


Since the normal keys already worked fine, I just needed to add the keycode-keysym pairs that would make my keys work. To do this there is a utility (also part of X) called xmodmap.


xmodmap reads a file or std input for "commands". The commands are in the form of


keycode $keycode = $keysym


where $keycode is the actual keycode (the first "keycode" needs to be there).


This tells xmodmap to assign the specified keysym to that keycode. Since when you log out you lose the asignments, you need to load them when you start X. (X automatically loads a keymap from its configuration file) This is done adding a line like:


xmodmap yourkeymap


to your .xinitrc or .Xsession file


Now they get recognized, but they dont do anything!!! you say.


That is true, any software can now recognize the keys, but they are not doing anything useful, like starting programs, changing the volume or connecting to the internet. We will leave this to the window manager.


Most window managers can be configured to do something when a key or a combination of keys is pressed, like Alt-Tab to switch or cicle the windows, and we are going to use this feature to start the programs that will actually do something useful.


In WindowMaker, the configuration utility has a section for this. For blackbox there is a program called bbkeys that handles the "keyboard shortcuts".


I can give no advice in this part, since each window manager works different, but in the documentation of yours, you can get the info you need. Look for "keyboard shortcuts" or something like that.


The practice:

Well, lets get our hands on this...


First, pick up a key (the leftmost, the rightmost, the bigger one) of your internet keys.


In an xterm write


$ xev


you will get a window with a square on it. Now press the key you chose.


It will read something like:


KeyPress event, serial 19, synthetic NO, window 0x2200001,

root 0x27, subw 0x0, time 2565600158, (136,110), root:(350,340),

state 0x10, keycode 149 (keysym 0x1000410e, IA14), same_screen YES,

XLookupString gives 0 characters: ""



KeyRelease event, serial 24, synthetic NO, window 0x2200001,

root 0x27, subw 0x0, time 2565600304, (136,110), root:(350,340),

state 0x10, keycode 149 (keysym 0x1000410e, IA14), same_screen YES,

XLookupString gives 0 characters: ""


now press Ctrl-c in the xterm and look at the third line of each block, there is a keycode in decimal (in this case, 149) and a keysym (in this case IA14). Ok, if you had not assigned any keysym to your inet keys, instead of IA14 you will get something like NoKeysym.


The X guys have set aside some special keysyms for the inet keys, they go from IA1 to IA15 and IB1 to IB15. This gives us a total of 30 keysyms. This has to be enough for any keyboard.


write a file "yourkeymap" that reads


keysym 149 = IA14


(change the values acording with what you got, if you got a NoKeysym, choose a keysym from the ones mentioned above, IA1 looks nice for a start)


now from the xterm do:


$ xmodmap yourkeymap


and repeat the thing with xev. Start it and press the key you pressed before. You will get a similar output, but instead of the NoKeysym you will get the keysym you wrote in your file.


Add a line for each key you want to configure. Don't repeat keysyms (unless you want several keys to do the exact same thing). Reload your keymap with:


$ xmodmap yourkeymap


Now copy the yourkeymap file to ~/.yourkeymap.


Edit your ~/.xinitrc or ~/.Xsession file to add a line that says:


xmodmap ~/.yourkeymap


This is done to load the keys when you start X.


Instead of doing all this, you may want to check my program "keymapconfig" that asks you to press a key and then asks you for the keysym to asign to it. You can save this pairs to a file and load them later with xmodmap... It requieres Tcl/Tk. Try to use only the keysyms specified above (IA1 to IA15 and IB1 to IB15) to avoid conflicts and problems. Anyway 30 keys are more than enough for internet and multimedia stuff.

(You have already downloaded this program, with this howto, look in the directory where you untarred the tarball)


You still have to add that line in your .xinitrc or .Xsession to load your keymap when you start X.


Now you have to configure the applications that do the work. This is configuration of your window manager, and each window manager will have different instructions, but most of them will work.


Basically, when asked for the key to watch (or “keyboard shortcut”), just write the keysym you asigned to the key you want to do something (or press that key, the “Key” is in fact the keysym, not actually the key) and then write the command you want to run when you press that key.


You can also use these keys in combination with modifiers like Ctrl, Shift and Alt. For example, I use the "Play" key to start xmms, but if I want to play a CD, I use Ctrl-Play to start gcd; for me Play is IB3 so I configured Ctrl-IB3 to start gcd. I also use the "Suspend" key to suspend the computer by running "apm -s", but if I want to see the battery status, I use Ctrl-Sleep to run "osdctl -A 3", that displays the battery status using osdsh (Read below). Again, for me "Suspend" is IA5, so to run "apm -s" I asigned the key IA5 and to run "osdctl -A 3" I asigned Ctrl-IA5.


For volume control, I recommend using umix, for terminals aterm is nice and for the "Connect" key, put the command you use to connect. Its that simple.


As an adition, you may want to check osdsh (by me of course), its a daemon that monitors the sound card volume, battery and connection status, displays a clock and displays it all using the XOSD library, so you get a nice TV-like On-Screen-Display for your sound, batt, connection and a sexy clock floating unmanaged on your display.


http://www.sourceforge.net/projects/osdsh

osdsh-0.7.0/HOWTO/README0100644000175400001440000000170407507674416014040 0ustar moultakusersKeymapconfig README What is this? keymapconfig is a Tcl/Tk script that generates keymaps to be loaded into the X window sistem thru the utility called xmodmap. keymapconfig reads the keycode of a key and asks for a keysym t be assigned to it. It can save the keycode-keysym pairs to a file that can be then feed to xmodmap, and can run xmodmap itself to try the keys It also can load these files to edit them. Read the manual pages of xmodmap to understand this. The reason I wrote this is that I needed a tool to grab the keycodes of the internet keys on my multimedia keyboard, this can be done with the utility "xev" that is part of X, but I also needed to edit the keysyms and assign them to keycodes, so after doing it manually a few times, I wrote this program so other people can get their multimedia keys working. I also did it as a tool for my Multimedia-X-Keyboard-HOWTO. Installation Just copy it somewhere in your path. It needs Tcl/Tk. osdsh-0.7.0/Makefile0100644000175400001440000000103607637713245013714 0ustar moultakusersVERSION=0.6.0 PREFIX=/usr/local EXEC_PREFIX=$(PREFIX) BINDIR=$(EXEC_PREFIX)/bin LIBDIR=$(EXEC_PREFIX)/lib DOCDIR=$(PREFIX)/doc/osdsh INCLUDEDIR=$(PREFIX)/include INSTALL=/usr/bin/install -c all: osdsh osdctl osdsh: cd src/$@; make osdctl: cd src/$@; make install: all $(INSTALL) src/osdsh/osdsh $(BINDIR) $(INSTALL) src/osdctl/osdctl $(BINDIR) mkdir -p $(LIBDIR)/osdsh $(INSTALL) src/osdsh/libosdsh*.so $(LIBDIR)/osdsh mkdir -p $(DOCDIR) $(INSTALL) README $(DOCDIR) clean: cd src/osdsh; make clean cd src/osdctl; make clean osdsh-0.7.0/README0100644000175400001440000002745607565537230013150 0ustar moultakusers COPYRIGHT Copyright 2002 Lord Darth Moultak All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA _________________________________________________________________ This program needs: *XOSD 2.0.1 *libapm..... (check your distro for this...) *pthreads... (this one in your distro too) What is this: osdsh is a program based on osdd-0.0.2 by Michael Petullo ,osdclock-0.5 by Jon Beckham and Martijn van de Streek , a nice utility named ppptime-0.9 written by Justin Azoff, and uses the xosd-2.0.1 library by Andre Renaud . Thank you guys!!. osdsh is a daemon that reads from your mixer device and shows the volume of the sound card when it changes, can show a clock, independent of the mixer watch, tell you if you are connected, and your battery status. In adition, you can type "commands" to a fifo and they will get "executed", the plans are that it will support battery status, and anything you want. You can also change the color, font and position of the different displays when running. How do I use it? Just run it from the command line, and change the volume of your sound card, you should see a bar showing the current volume for that device You can display strings, sliders and bars on the screen by using the complement program "osdctl", or by echoing commands to the fifo file (/tmp/osdsh.x, x= your uid). *** NOTICE *** Starting with 0.5.0, you need to activate each of the displays before it starts working. To activate the mixer do a "osdctl -m 1". This is some stuff you can do with osdsh, I show the commands used by osdctl so you can add them to your scripts: **In this examples we will call "uid" to your numeric uid.** To display a string into the screen, you can do a $echo "strn(firstline,secoundline)" > /tmp/osdsh.uid or $osdctl -s "firstline,secounline" It is a good thing to alwawy specify both arguments, so you get the results you want, it doesn't matter that one line is empty. If you don't do this, you will end up with a screwed display... try it. To display a bar named BAR full up to 50%: $echo "bars(BAR,50)" > /tmp/osdsh.uid or $osdctl -b "BAR,50" To display a slider named SLIDER at 25%: $echo "slid(SLIDER,25)" > /tmp/osdsh.uid or $osdctl -l "SLIDER,25" To activate the osd clock: $echo "clck(1)" > /tmp/osdsh.uid or $osdctl -c 1 To deactivate it use 0 instead of 1 To activate the mixer watch: $echo "mixr(1)" > /tmp/osdsh.uid or $osdctl -m 1 To deactivate it, use 0, mixer watch is activated by default. To activate the ppp watch: $echo "pppw(1)" > /tmp/osdsh.uid or $osdctl -p 1 (0 to deactivate). This will display "Connecting..." until connected (it wont check if you are actually connecting, just will say it, its up to you to start your connection script). *** This has changes... a bit. Now you can configure the phrase that osdsh says when its still connecting. Change it using the "connecting(firstline,secoundline)" command. Also change the "Connected" phrase with "connected(firstline,secoundline)" and the disconnected phrase with "disconnected(firslineonly)". On the secound line it will say "Disconnected after %d hr %d min %d secs" telling the time you were connected. *** End of this note. To change the ppp interface (defaults to ppp0) $echo "pdev(pppx)" > /tmp/osdsh.uid to watch the connection thru pppx. or $osdctl -d pppx Do this before you tell osdsh to check the connection. To show the battery status $echo "apmw(1)" > /tmp/osdsh.uid or $osdctl -a 1 (0 to hide) or to show it for five seconds $echo "apms(5)" > /tmp/osdsh.uid or $osdctl -A 5 How do I change the looks of the OSD? You can change the look of the osd when osdsh is running, to do this you have a set of commands that are not currently supported as command line options for osdctl, but can be used thru osdctl anyway, this commands will be discussed later. An important note, each of the "watching processes" has its own display, maybe you like your clock to float on the top of the screen with a nice green color and a matrix-esque font, but you want the mixer volume to be displayed at the bottom in light blue with a bold font, the connection status has to be yellow and appear just below the clock, and in a big annoying font so you notice it..... well you can have it. Each of the "displays" has its own configuration, but when you start osdsh, the options given in the command line are set for all of the displays, except the mixer, that always starts at the bottom (you can change it later). To change the font to helvetica: $echo "dset(f,helvetica)" > /tmp/osdsh.uid or $osdctl -e "dset(f,helvetica)" To change the color to white: $echo "dset(C,white)" > /tmp/osdsh.uid or $osdctl -e "dset(C,white)" To display a shadow with an offset of 2: $echo "dset(o,2)" > /tmp/osdsh.uid or $osdctl "dset(o,2)" To turn the shadow off $echo "dset(o,0)" > /tmp/osdsh.uid or $osdctl -e "dset(o,0)" To display the strings, bars and sliders on the bottom of the screen: $echo "dset(b)" > /tmp/osdsh.uid or $osdctl -e "dset(b)" To put it back on the top of the screen: $echo "dset(t)" > /tmp/osdsh.uid or $osdctl -e "dset(t)" To terminate the osdsh process: $echo "exit()" > /tmp/osdsh.uid or $osdctl -x What will come: Maybe we could make a nice HUD like status bar, like the ones in the first person shooting games like doom or quake, where you can see the batt, time, connection status and speed, volume, and other stuff, floating on your screen, and going away when not wanted, but for this its necessary that xosdlib supports some other features, like x and y offset, or a geometry like option, or maybe the ability to have different fonts and colors on the same display... A look on it wouldn't hurt anyway, but osdsh and osdctl as they are now are A LOT nicer than anything I have seen( and to me, useful)but it takes more than a nice quake-like hud on my desktop to get off my butt and start hacking the xosdlib...(ok no, but I have to do some research, and it may take some time) *** Already looked into xosd, and hacked it. We now support the x coordinate. Change it with "yourdisplaysetcommand(x,value)". Of course, we also can count from right-to-left or left-to-right, to your choice *** Looked into xosd again... and they finally got the X-offset clue, so we now support XOSD again, not our own library. the requiered version of XOSD is 2.0.1. Yeah, right but, how do I compile it? First, edit the Makefile and the config.h files, or at least read them. Then: $make Copy the binaries to where you like them, osdctl is not requiered, but recommended, since it detects your uid and puts the commands right where they belong, and gets some command line options to do its bussiness. Or you can do a: $make install OSDSH commands. osdctl is the complement program of osdsh, osdctl is an interface to the control shell of osdsh, and support several command line options to do some stuff, like "-s" to display a string, with osdctl you dont have to know your uid, since the program checks for it. osdctl can give osdsh commands directly, with the flag "-e" you can type a command that is not yet supported by an option. There are several commands that are not supported yet by osdctl in the form of command line options, currently the ones that change the look of the display. This commands are: -dset: stands for "display set", it will change the look of the main display, that is, the one that is used to display strings, bars, and sliders . -smix: stands for "set mixer", the same that dset, but for the mixer display. -sclk: stands for "set clock", just as above, for the clock display. -sppp: stands for "set ppp", for the ppp display. -sapm: "set apm", the battery status display Each one of this commands support several options to change the look of the displays. This options are: -f fontstring: changes the font of the selected display to "fontstring" -C color: changes the color of the display to "color" -t : stands for top, show the selected display on the top of the screen. -b : stands for bottom, display in the bottom of the screen. -l : stands for left, display to the left of the screen. -c : to center the display in the screen -r : stands for right, display to the right of the screen. -d delay: changes the time the info will be displayed to "delay" secs. -o soffset: changes the distance in pixels that the shadow of the display is throw away, 0 for no shadow, (default). -y offset: changes the distance from the top or the bottom of the screen at wich the display is shown. -x offset: changes the distance from the left or right of the screen at wich the display is shown. It is measured from the left edge of the display to the left or right edge of the screen. Well, the way to give the commands to osdsh thru osdctl is as follows: To change the color of the mixer to white: $osdctl -e "smix(C,white)" Just as above, the fifo file can be used directly. Note that osdctl can get several commands, but that is not really tested. You can do a $osdctl -c 1 -m 1 -e "dset(C,yellow)" -s "hello, world" To activate the clock and mixer, and display "hello, world" in yellow Do the same for other commands and options to get the look you want. There is another command that is used to change the format of the clock. This is used like this: $osdctl -e "clkf(%H:%M:%S)" The format is the regular strftime string. To finish, the commands supported by osdsh are: strn(firstline,secound) : display a string bars(name,number) : display a bar with a label slid(name,number) : display a slider with a label time(n) : display the clock for n seconds apms(n) : display the apm monitor for n seconds sleep(n) : sleep for n seconds clck(1|0) : (de)activate the clock mixr(1|0) : (de)activate the mixer monitor (sound card) apmw(1|0) : (de)activate the apm monitor pppw(1|0) : (de)activate the connection monitor exit() : causes osdsh to exit. dset(option,value) : configure the main display smix(option,value) : configure the mixer display sclk(option,value) : configure the clock display sppp(option,value) : configure the ppp display sapm(option,value) : configure the apm display pdev(pppdevice) : change the ppp interface (ppp0 by default) clkf(strftimestring) : change the format of the clock in the strftime format. connecting(firs,secound): Change the "Connecting..." prase while connecting. connected(fisrt,secound): Change the "Connected" phrase when connected. disconnected(firstline) : Change the first line phrase when disconnected. showconntime() : Shows the time you have been connected. And for your theme-ing delight, you can make osdctl run scripts to osdsh. The scripts can have comments (anything not recognized by osdsh is just ignored) and they consist of osdsh commands and arguments, one command per line. There is a test script in the data dir, (named testscript of course) to show what I mean. osdctl executes scripts with the "-S" flag, see the osdctl help. *** Note: now included with osdSH, I included a Tcl/Tk script to automate the process of configuring themes for osdSH. Check examples in the "themes" directory. "tkosdshconfig" will read themes and save them to files. You can load them to osdSH using: $ osdctl -S yourthemefile The End osdsh-0.7.0/README.tkosdshconfig0100644000175400001440000000072407511605662015775 0ustar moultakusersWell, this script loads a file containing commands of osdsh that change the look of it. You can then change the values and save this changes. You can preview your changes also. This is like a Theme-maker program, this way you can change the look of osdsh just running a script and you can have different scripts to match your preferences for each hour of the day or day of the week.... woohoo!!! GPLed, so you can do almost anything to it. (don't eat it, it's toxic) osdsh-0.7.0/src/0040755000175400001440000000000007637724166013052 5ustar moultakusersosdsh-0.7.0/src/config.h0100644000175400001440000000073207637724162014463 0ustar moultakusers#define VERSION "0.7.0" #define FONT "-*-lucidatypewriter-bold-*-*-*-*-240-*-*-*-*-*-*" #define TIMEOUT 5 #define COLOR "green" #define OSD_ALIGNMENT XOSD_left #define OSD_POSITION XOSD_top #define MIXER "/dev/mixer" #define SHADOW_OFFSET 0 #define DEFAULT_OFFSET 0 #define CLOCK_FORMAT "%a %b %e %G - %H : %M : %S" #define OSD_FIFO_PATH "/tmp/osdsh" #define PPP_DEVICE "ppp0" #define PPP_PID_PATH "/var/run" #define PLUGINSDIR "/usr/local/lib/osdsh" #define MAX_PLUGINS 20 osdsh-0.7.0/src/osdctl/0040755000175400001440000000000007640154545014332 5ustar moultakusersosdsh-0.7.0/src/osdctl/Makefile0100644000175400001440000000035407637724663016003 0ustar moultakusersCC = gcc PREFIX = /usr BINDIR = $(PREFIX)/bin DOCDIR = $(PREFIX)/doc/osdsh LIBDIR = -L/usr/X11R6/lib -L/usr/lib LIBS = $(LIBDIR) CFLAGS = -O3 all: osdctl osdctl: gcc $(LIBDIR) $(LIBS) $(CFLAGS) -o $@ $@.c clean: rm osdctl osdsh-0.7.0/src/osdctl/osdctl.c0100644000175400001440000001014407635053125015757 0ustar moultakusers#include "osdctl.h" #include "../config.h" /* ============================ usage () =================================== */ void usage(const int exitcode, const char *error, const char *more) { fprintf(stderr, "osdctl %s\n", VERSION); fprintf(stderr, "osdctl ...\n\n"); fprintf(stderr, " -h display help\n"); fprintf(stderr, " -s \"string\" display a string\n"); fprintf(stderr, " -b (name,val) display a bar up to val, named \"name\"\n"); fprintf(stderr, " -l (name,val) display a slider at val, named \"name\"\n"); fprintf(stderr, " -t int display the clock for int seconds\n"); fprintf(stderr, " -c <0|1> (de)activate the osd clock\n"); fprintf(stderr, " -m <0|1> (de)activate the mixer display\n"); fprintf(stderr, " -p <0|1> (de)activate the ppp watch feature\n"); fprintf(stderr, " -a <0|1|2> (de)activate the apm watch feature\n"); fprintf(stderr, " 1=don't show percent bar; 2=do show it\n"); fprintf(stderr, " -d interface set the ppp interface, default: ppp0\n"); fprintf(stderr, " -A int show battery status for int seconds\n"); fprintf(stderr, " -e \"comm args\" tell osdsh to do \"comm\" with \"args\"\n"); fprintf(stderr, " -S \"scriptfile\" execute commands form scriptfile\n"); fprintf(stderr, " -x tell osdsh to quit\n\n"); if (error) fprintf(stderr, "%s: %s\n\n", error, more); exit(exitcode); } /* ============================= function prototypes ======================= */ void send_command(char command[BUFSIZ]); void script_file(char file[PATH_MAX]); int main(int argc, char *argv[]); /*================================= send_command() ========================= */ void send_command(char command[BUFSIZ]) { FILE *fp; char fifo_file[PATH_MAX]; if (strcmp(command, "")==0) return; sprintf(fifo_file, "%s.%d", OSD_FIFO_PATH, getuid()); if((fp = fopen(fifo_file, "w")) == NULL) { perror("Couldn't open fifo"); exit(1); } fputs(command, fp); fclose(fp); } /*============================= script_file() =========================*/ void script_file(char file[PATH_MAX]) { char readbuffer[BUFSIZ]; FILE *fp; if((fp = fopen(file, "r")) == NULL) { perror("Couldn't find script file"); exit(1); } while (fgets(readbuffer, BUFSIZ, fp)) { send_command(readbuffer); } fclose(fp); } /* ============================ main () ============================== */ int main(int argc, char *argv[]) { char c; char command[BUFSIZ]; int opt_index = 0; struct option opts[] = { {"help", 0, 0, 'h'}, {"string", 1, 0, 's'}, {"bars", 1, 0, 'b'}, {"slider", 1, 0, 'l'}, {"flashtime", 1, 0, 't'}, {"clock", 1, 0, 'c'}, {"mixer", 1, 0, 'm'}, {"execute", 1, 0, 'e'}, {"exit", 0, 0, 'x'}, {"script", 1, 0, 'S'}, {"apm-watch", 1, 0, 'a'}, {"apm-show", 1, 0, 'A'}, {"ppp-watch", 1, 0, 'p'}, {"ppp-dev", 1, 0, 'd'}, }; if (argc == 1) usage(0, NULL, NULL); while ((c = getopt_long(argc, argv, "hxs:b:l:t:c:m:e:S:p:d:a:A:", opts, &opt_index)) >= 0) { switch (c) { case 'h': usage(0, NULL, NULL); exit(0); case 's': sprintf(command, "strn(%s)", optarg); break; case 'b': sprintf(command, "bars(%s)", optarg); break; case 'l': sprintf(command, "slid(%s)", optarg); break; case 't': sprintf(command, "time(%s)", optarg); break; case 'c': sprintf(command, "clck(%s)", optarg); break; case 'm': sprintf(command, "mixr(%s)", optarg); break; case 'e': sprintf(command, "%s", optarg); break; case 'x': sprintf(command, "exit()"); break; case 'S': sprintf(command, ""); script_file(optarg); break; case 'p': sprintf(command, "pppw(%s)", optarg); break; case 'd': sprintf(command, "pdev(%s)", optarg); break; case 'a': sprintf(command, "apmw(%s)", optarg); break; case 'A': sprintf(command, "apms(%s)", optarg); break; default: usage(1, NULL, NULL); exit(1); } send_command(command); } return(0); } osdsh-0.7.0/src/osdctl/osdctl.h0100644000175400001440000000010107510262377015757 0ustar moultakusers#include #include #include osdsh-0.7.0/src/osdsh/0040755000175400001440000000000007640200123014142 5ustar moultakusersosdsh-0.7.0/src/osdsh/apmwatch.c0100644000175400001440000000705707637706101016135 0ustar moultakusers#include "osdsh.h" #include "../config.h" #include #define IAM 2 #define MYNAME "APM / Battery" settings_t apmset; void *apm_watch(void *arg); /* ========================================================================== ====================== REQUIERED STUFF FOR PLUGINS ======================= ========================================================================== ***** ID of the plugin, contact me before you asign this to your plugin!! ***** */ int whoami(void) { return IAM; } /* Return a pointer to the name of the plugin */ char *mynameis() { char *a = MYNAME; return a; } /* This function sets the default (initual) values for our osd */ void initialize_myosd() { set_defaults(&apmset); } /* This function takes a command and arguments, if the command is ours, execute it and return 1, if not, return 0*/ int isitmine( char command[BUFSIZ], char arg_first[BUFSIZ], char arg_secound[BUFSIZ]) { int i=1; if(strcmp(command, "stop")==0) { apmset.displaying = 0; } else if(strcmp(command, "start")==0) { if(!apmset.displaying) { apmset.displaying = 1; pthread_create(&apmset.mythread, NULL, apm_watch, NULL); } } else if (strcmp(command, "apmw")==0) { if (atoi(arg_first)) { isitmine("start", NULL, NULL); } else { apmset.displaying = 0; } } else if (strcmp(command, "apms")==0) { isitmine("start", NULL, NULL); sleep(atoi(arg_first)); apmset.displaying = 0; } else if (strcmp(command, "sapm")==0) { control_options(&apmset, arg_first, arg_secound); } else { i = 0; } return i; } /*=============================apm_watch()=========================== */ /* some ideas (shamelessly copied ) from apmd's "apm" utility*/ void *apm_watch(void *arg) { int secs; apm_info i; char battery[255]; char remainingtime[255]; char report1[255]; apmset.myosd = xosd_create(2); initialize_osd(&apmset); while(apmset.displaying) { if (apm_read(&i)) { /*fprintf(stderr, "Cannot read APM information\n");*/ apmset.displaying = 0; xosd_display(apmset.myosd, apmset.position==XOSD_bottom?1:0, XOSD_string, "Cannot read APM information"); break; } secs = i.using_minutes ? i.battery_time * 60 : i.battery_time; if (i.battery_flags != 0xff /* Have a 1.1 BIOS and a system battery. ?????? */ && i.battery_flags & 0x80) { sprintf(battery, "no system battery"); } else { switch (i.battery_status) { case 0: sprintf(battery, "high"); xosd_set_colour(apmset.myosd, apmset.color); break; case 1: sprintf(battery, "low"); xosd_set_colour(apmset.myosd, "yellow"); break; case 2: sprintf(battery, "critical!!"); xosd_set_colour(apmset.myosd, "red"); break; case 3: sprintf(battery, "charging..."); break; } } if (strcmp(battery, "no system battery")==0) { xosd_display(apmset.myosd, apmset.position==XOSD_bottom?1:0, XOSD_string, "AC on line"); xosd_display(apmset.myosd, apmset.position==XOSD_bottom?0:1, XOSD_string, battery); } else { sprintf(remainingtime, "%dhr, %dmin, %dsec", secs/3600, (secs%3600)/60, ((secs%3600)%60)%60); sprintf(report1, "AC: %s Remaining battery: %d%%(%s) %s", i.ac_line_status?"on line":"off line",i.battery_percentage, remainingtime, battery); xosd_display(apmset.myosd, 0, XOSD_string, report1); if (apmset.displaying > 1) xosd_display(apmset.myosd, 1, XOSD_percentage, i.battery_percentage ); else xosd_display(apmset.myosd, 1, XOSD_string, ""); } } pthread_exit(0); } osdsh-0.7.0/src/osdsh/clockdisplay.c0100644000175400001440000000460307637452500017005 0ustar moultakusers#include "../config.h" #include "osdsh.h" #define IAM 1 #define MYNAME "Clock" char clockformat[255] = CLOCK_FORMAT; void *osdsh_clock(void *arg); settings_t clocksetts; /*================================clock_display() ========================== */ /* got the ideas from osd_clock */ /* ========================================================================== ====================== REQUIERED STUFF FOR PLUGINS ======================= ========================================================================== ***** ID of the plugin, contact me before you asign this to your plugin!! ***** */ int whoami(void) { return IAM; } /* Return a pointer to the name of the plugin */ char *mynameis() { char *a = MYNAME; return a; } /* This function sets the default (initual) values for our osd */ void initialize_myosd() { set_defaults(&clocksetts); } /* This function takes a command and arguments, if the command is ours, execute it and return 1, if not, return 0*/ int isitmine( char command[BUFSIZ], char arg_first[BUFSIZ], char arg_secound[BUFSIZ]) { int i=1; if(strcmp(command, "stop")==0) { clocksetts.displaying = 0; } else if(strcmp(command, "start")==0) { if(!clocksetts.displaying) { clocksetts.displaying = 1; pthread_create(&clocksetts.mythread, NULL, osdsh_clock, NULL); } } else if (strcmp(command, "clkf")==0) { strcpy(clockformat ,arg_first); } else if (strcmp(command, "clck")==0) { if (atoi(arg_first)) { isitmine("start", NULL, NULL); } else { clocksetts.displaying = 0; } } else if (strcmp(command, "time")==0) { if (atoi(arg_first)) isitmine("start", NULL, NULL); sleep(atoi(arg_first)); clocksetts.displaying = 0; } else if (strcmp(command, "sclk")==0) { control_options(&clocksetts, arg_first, arg_secound); } else { i = 0; } return i; } /*The functtion to call when we start our plugin... this sould be called by a pthread(...) call so it won't block the whole program*/ void *osdsh_clock(void *arg) { time_t currenttime; char timestring[255]; clocksetts.myosd = xosd_create(1); initialize_osd(&clocksetts); clocksetts.displaying = 1; while (clocksetts.displaying) { currenttime = time(0); strftime(timestring, 255, clockformat, localtime(¤ttime)); xosd_display(clocksetts.myosd, 0, XOSD_string, timestring); } xosd_destroy(clocksetts.myosd); pthread_exit(0); } osdsh-0.7.0/src/osdsh/connectionwatch.c0100644000175400001440000001025407637632576017526 0ustar moultakusers#include "osdsh.h" #include "../config.h" #define IAM 3 #define MYNAME "Net" settings_t pppset; void *connection_watch(void *arg); char pppdevice[PATH_MAX+1]; char connecting1[BUFSIZ+1]; char connecting2[BUFSIZ+1]; char connected1[BUFSIZ+1]; char connected2[BUFSIZ+1]; char disconnected[BUFSIZ+1]; char timeconnected[255]; /* ========================================================================== ====================== REQUIERED STUFF FOR PLUGINS ======================= ========================================================================== ***** ID of the plugin, contact me before you asign this to your plugin!! ***** */ int whoami(void) { return IAM; } /* Return a pointer to the name of the plugin */ char *mynameis() { char *a = MYNAME; return a; } /* This function sets the default (initual) values for our osd */ void initialize_myosd() { set_defaults(&pppset); } /* This function takes a command and arguments, if the command is ours, execute it and return 1, if not, return 0*/ int isitmine( char command[BUFSIZ], char arg_first[BUFSIZ], char arg_secound[BUFSIZ]) { int i=1; if(strcmp(command, "stop")==0) { pppset.displaying = 0; } else if(strcmp(command, "start")==0) { if(!pppset.displaying) { pppset.displaying = 1; pthread_create(&pppset.mythread, NULL, connection_watch, NULL); } } else if (strcmp(command, "pppw")==0) { if (atoi(arg_first)) { isitmine("start", NULL, NULL); } else { pppset.displaying = 0; } } else if (strcmp(command, "sppp")==0) { control_options(&pppset, arg_first, arg_secound); } else if (strcmp(command, "pdev")==0) { sprintf(pppdevice, "%s", arg_first); } else if (strcmp(command, "connecting")==0) { sprintf(connecting1, "%s", arg_first); sprintf(connecting2, "%s", arg_secound); } else if (strcmp(command, "connected")==0) { sprintf(connected1, "%s", arg_first); sprintf(connected2, "%s", arg_secound); } else if (strcmp(command, "disconnected")==0) { sprintf(disconnected, "%s", arg_first); } else if (strcmp(command, "showconntime")==0) { xosd_display(pppset.myosd, 0, XOSD_string, "Connected for"); xosd_display(pppset.myosd, 1, XOSD_string, timeconnected); } else { i = 0; } return i; } /*=============================connection_watch()=========================== */ /* some ideas from ppptime */ void *connection_watch(void *arg) { FILE *fp; int ppp0run; long start; long end; int total; struct stat st; char ppp0pidfile[PATH_MAX]; pppset.myosd = xosd_create(2); initialize_osd(&pppset); if(strcmp(pppdevice, "")==0) sprintf(pppdevice, "%s", PPP_DEVICE); sprintf(ppp0pidfile, "%s/%s.pid", PPP_PID_PATH, pppdevice); if (strcmp(connecting1, "")==0) sprintf(connecting1, "Connecting"); if (strcmp(connecting2, "")==0) sprintf(connecting2, "please wait..."); if (strcmp(connected1, "")==0) sprintf(connected1, "Connected"); if (strcmp(connected2, "")==0) sprintf(connected2, "GO!"); if (strcmp(disconnected, "")==0) sprintf(disconnected, "Connection terminated"); while (pppset.displaying) { xosd_display(pppset.myosd, 0, XOSD_string, connecting1); xosd_display(pppset.myosd, 1, XOSD_string, connecting2); sprintf(ppp0pidfile, "%s/%s.pid", PPP_PID_PATH, pppdevice); if((fp=fopen(ppp0pidfile, "r"))==NULL) { ppp0run = 0; } else { ppp0run = 1; fclose(fp); } if(ppp0run) { xosd_display(pppset.myosd,0, XOSD_string, connected1); xosd_display(pppset.myosd,1, XOSD_string, connected2); stat(ppp0pidfile, &st); start = st.st_mtime; while((fp=fopen(ppp0pidfile, "r"))!=NULL) { fclose(fp); end = time(0); total = end - start; sprintf(timeconnected, "Connected for %d hr %d min %d sec", ((total/60)/60)%100, (total/60)%60, total%60); usleep(3); } end = time(0); total = end - start; sprintf(timeconnected, "Disconnected after %d hr %d min %d sec", ((total/60)/60)%100, (total/60)%60, total%60); xosd_display(pppset.myosd,0, XOSD_string, disconnected); xosd_display(pppset.myosd,1, XOSD_string, timeconnected); pppset.displaying = 0; } } sleep(1); xosd_destroy(pppset.myosd); pthread_exit(0); } osdsh-0.7.0/src/osdsh/controlsh.c0100644000175400001440000001276507640154223016342 0ustar moultakusers#include "osdsh.h" #include "../config.h" int n=0; plugininfo_t plugins[MAX_PLUGINS]; settings_t settings; /* ================================== load a plugin ============================= */ int load_plugin( char pluginfile[255]) { int (*info)(); void *module; int a; char file[PATH_MAX+256]; char *msg = NULL; /* getcwd(file, PATH_MAX); strcat(file, "/"); */ strcat(file, pluginfile); module = dlopen(pluginfile, RTLD_NOW); if(!module) { msg = dlerror(); if(msg != NULL) { fprintf(stderr, "%s\n", msg); a = -1; } } else { info = dlsym(module, "whoami"); a = info(); info = dlsym(module, "initialize_myosd"); info(); plugins[a].isitmine = dlsym(module, "isitmine"); info = dlsym(module, "mynameis"); plugins[a].module = module; plugins[a].whoami = a; plugins[a].file = file; plugins[a].myname = (char *) info(); plugins[a].active = 1; } return a; } /* =========================== close a plugin ===============================*/ /* int close_plugin( int a) { char report[255]; if(dlclose(plugins[a].module)) { sprintf(report, "Error while unloading %s", plugins[a].myname); plugins[a].displaying = 1; return -1; } else { sprintf(report, "Successfully unloaded %s", plugins[a].myname); plugins[a].displaying = 0; return 0; } xosd_display(settings.myosd, 0, XOSD_string, report); xosd_display(settings.myosd, 1, XOSD_string, ""); } */ /*============================ display_stuff()=============================== */ void display_stuff(char command[BUFSIZ], char arguments[BUFSIZ]) { char c; char arg_first[BUFSIZ]; char arg_secound[BUFSIZ]; int a,i; sprintf(arg_first, ""); sprintf(arg_secound, ""); /* separate the arguments in sub_arguments .... or not?*/ i=0; a=0; while ((c=arguments[i])!=','&&c!='\n'&&c!='\0') { if (c=='\\') { i++; arg_first[a] = arguments[i]; } else { arg_first[a] = c; } a++; i++; } arg_first[a] = '\0'; i++; a = 0; while((c=arguments[i])!='\n'&&c!='\0'&&c!=')') { if (c=='\\') { i++; arg_secound[a] = arguments[i]; } else { arg_secound[a] = c; } a++; i++; } arg_secound[a] = '\0'; /* done with the arguments */ if (strcmp(command, "load")==0) { /* for(i=0;i=0) { if(a>n&&a, with some ideas, and slightly (one or two chars) modified by me*/ /* ============================ initialize_vols () ========================= */ void initialize_vols( int devmask) { int i; int volume; for (i=0;i> 8) & 0xff)) { xosd_display(mixerset.myosd, mixerset.position, XOSD_bottom, "Muted"); xosd_display(mixerset.myosd, !mixerset.position, XOSD_bottom, ""); } /* not muted, so lets check if the vol changed, if so, display them, if not, just ignore it*/ else if (vol[channel] != old_vol[channel]) { xosd_display(mixerset.myosd, 0, XOSD_string, channel_name); xosd_display(mixerset.myosd, 1, XOSD_percentage, (((vol[channel]>>8)&0xff)+vol[channel]&0xff)/2); } } /*================================= mixer_watch() ============================*/ void *mixer_watch(void *arg) { int devmask; int i; /* we open the osd for the mixer*/ /* Mixer usually goes on the bottom of the screen... so*/ mixerset.position = XOSD_bottom; mixerset.myosd = xosd_create(2); initialize_osd(&mixerset); /*open the mixer device for reading*/ if ((dev = open(mixerdevice, O_RDWR)) < 0) { perror("Error opening"); perror(mixerdevice); pthread_exit(0); } if (ioctl(dev, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) { perror("Error reading"); perror(mixerdevice); pthread_exit(0); } /*initialize the volume.....*/ initialize_vols(devmask); while(mixerset.displaying) { for (i=0;i position of the osd, 0 for bottom,\n"); fprintf(stderr, " 1 for top. Default 1 (top).\n"); fprintf(stderr, " -a <0|1|2> align of the osd. left,center or right.\n"); fprintf(stderr, " -n number set the nice number so osdsh won't eat your cpu\n"); fprintf(stderr, "\n"); if (error) fprintf(stderr, "%s: %s\n\n", error, more); exit(exitcode); } /* ============================ parse_args () ============================== */ void parse_args(int argc, char *argv[], settings_t * settings) { char c; int opt_index = 0; struct option opts[] = { {"help", 0, 0, 'h'}, {"position", 1, 0, 'p'}, {"soffset", 1, 0, 'o'}, {"mixer", 1, 0, 'm'}, {"font", 1, 0, 'f'}, {"color", 1, 0, 'c'}, {"delay", 1, 0, 'd'}, {"align", 1, 0, 'a'}, {"nice", 1, 0, 'n'} }; while ((c = getopt_long(argc, argv, "hm:f:c:p:d:o:n:", opts, &opt_index)) >= 0) { switch (c) { case 'h': usage(0, NULL, NULL); exit(0); case 'f': strncpy(settings->font, optarg, BUFSIZ); settings->font[BUFSIZ] = '\0'; break; case 'c': strncpy(settings->color, optarg, BUFSIZ); settings->color[BUFSIZ] = '\0'; break; case 'p': settings->position = atoi(optarg); break; case 'a': settings->align = atoi(optarg); break; case 'd': settings->delay = atoi(optarg); break; /* case 'm': strncpy(messages.mixerdevice, optarg, BUFSIZ); messages.mixerdevice[PATH_MAX+1] = '\0'; break; */ case 'o': settings->soffset = atoi(optarg); break; case 'n': nice(atoi(optarg)); break; default: usage(1, NULL, NULL); exit(1); } } } void load_basic_plugins(void) { int a; char file[PATH_MAX+255]; sprintf(file, "%s/libosdshmixer.so", PLUGINSDIR); a = load_plugin(file); if (a<0) { xosd_display(settings.myosd, 0, XOSD_string, "No Mixer Support"); xosd_display(settings.myosd, 1, XOSD_string, ""); } sprintf(file, "%s/libosdshclock.so", PLUGINSDIR); a = load_plugin(file); if (a<0) { xosd_display(settings.myosd, 0, XOSD_string, "No Clock Support"); xosd_display(settings.myosd, 1, XOSD_string, ""); } sprintf(file, "%s/libosdshnet.so", PLUGINSDIR); a = load_plugin(file); if (a<0) { xosd_display(settings.myosd, 0, XOSD_string, "No Net Support"); xosd_display(settings.myosd, 1, XOSD_string, ""); } sprintf(file, "%s/libosdshapm.so", PLUGINSDIR); a = load_plugin(file); if (a<0) { xosd_display(settings.myosd, 0, XOSD_string, "No APM/Battery support"); xosd_display(settings.myosd, 1, XOSD_string, ""); } } /* ============================ main () ==================================== */ int main(int argc, char *argv[], char *env[]) { pid_t childpid; char pid_file[PATH_MAX+1]; FILE *fp; set_defaults(&settings); initialize_osd(&settings); parse_args(argc, argv, &settings); /* #ifndef NOAPM apmset = settings; #endif pppset = mixerset = settings; */ if((childpid=fork())<0) { perror("fork"); exit(1); } if (childpid==0) { control_sh(NULL); } else { sprintf(pid_file, "%s.%d.pid", OSD_FIFO_PATH, getuid()) ; fp=fopen(pid_file, "w"); fprintf(fp, "%d", childpid); fclose(fp); exit(0); } return(0); } osdsh-0.7.0/src/osdsh/osdsh.h0100644000175400001440000000152307637704514015454 0ustar moultakusers#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*============================== settings_t ==================================*/ typedef struct settings_t { xosd *myosd; char font[BUFSIZ + 1]; char color[BUFSIZ + 1]; int soffset; int xoffset; int yoffset; xosd_align align; xosd_pos position; int displaying; int delay; pthread_t mythread; } settings_t; typedef struct plugininfo_t { int whoami; int active; void *module; char *file; char *myname; int (*isitmine)(); } plugininfo_t; osdsh-0.7.0/src/osdsh/utils.c0100644000175400001440000000647107637404245015474 0ustar moultakusers#include "osdsh.h" #include "../config.h" /*This function is used to control the options of the individual osd's*/ void control_options(settings_t *setts, char option[2], char argument[BUFSIZ]) { /*this function reads the option to change on each display, changes it and saves the changes on the corresponding settings structure*/ switch (option[0]) { case 'f': strncpy(setts->font, argument, BUFSIZ); if (setts->displaying&&xosd_set_font(setts->myosd, argument)) fprintf(stderr, "Couldn't change font\n"); break; case 'C': strncpy(setts->color, argument, BUFSIZ); if (setts->displaying&&xosd_set_colour(setts->myosd, argument)) fprintf(stderr, "Couldn't change color\n"); break; case 'd': setts->delay = atoi(argument); if (setts->displaying&&xosd_set_timeout(setts->myosd, atoi(argument))) fprintf(stderr, "Couldn't change timeout\n"); break; case 'b': setts->position = XOSD_bottom; if (setts->displaying&&xosd_set_pos(setts->myosd, XOSD_bottom)) fprintf(stderr, "Couldn't change position\n"); break; case 't': setts->position = XOSD_top; if (setts->displaying&&xosd_set_pos(setts->myosd, XOSD_top)) fprintf(stderr, "Couldn't change position\n"); break; case 'l': setts->align = XOSD_left; if (setts->displaying&&xosd_set_align(setts->myosd, XOSD_left)) fprintf(stderr, "Couldn't change align\n"); break; case 'r': setts->align = XOSD_right; if (setts->displaying&&xosd_set_align(setts->myosd, XOSD_right)) fprintf(stderr, "Couldn't change align\n"); break; case 'c': setts->align = XOSD_center; if (setts->displaying&&xosd_set_align(setts->myosd, XOSD_center)) fprintf(stderr, "Couldn't change align\n"); case 'o': setts->soffset = atoi(argument); if (setts->displaying&&xosd_set_shadow_offset(setts->myosd, setts->soffset)) fprintf(stderr, "Couldn't change Shadow Offset\n"); break; case 'y': setts->yoffset = atoi(argument); if (setts->displaying&&xosd_set_vertical_offset(setts->myosd, setts->yoffset)) fprintf(stderr, "Couldn't change vertical offset\n"); break; case 'x': setts->xoffset = atoi(argument); if (setts->displaying&&xosd_set_horizontal_offset(setts->myosd, setts->xoffset)) fprintf(stderr, "Couldn't change horizontal offset\n"); default: break; } } /*============================= initialize_osd() =========================== */ void initialize_osd( settings_t *setts) { xosd_set_font(setts->myosd, setts->font); xosd_set_colour(setts->myosd, setts->color); xosd_set_pos(setts->myosd, setts->position); xosd_set_align(setts->myosd, setts->align); xosd_set_horizontal_offset(setts->myosd, setts->xoffset); xosd_set_vertical_offset(setts->myosd, setts->yoffset); xosd_set_shadow_offset(setts->myosd, setts->soffset); xosd_set_timeout(setts->myosd, setts->delay); } /* ============================ set_defaults () ============================ */ void set_defaults(settings_t *setts) { strncpy(setts->font, FONT, BUFSIZ); setts->font[BUFSIZ] = '\0'; strncpy(setts->color, COLOR, BUFSIZ); setts->color[BUFSIZ] = '\0'; setts->soffset = SHADOW_OFFSET; setts->yoffset = DEFAULT_OFFSET; setts->xoffset = DEFAULT_OFFSET; setts->align= OSD_ALIGNMENT; setts->position = OSD_POSITION; setts->delay = TIMEOUT; setts->displaying = 0; } osdsh-0.7.0/themes/0040755000175400001440000000000007565540067013544 5ustar moultakusersosdsh-0.7.0/themes/biggerfonts0100644000175400001440000000141307565537275016003 0ustar moultakusers#This osdsh theme was created for osdsh-0.6.0 #with Tkosdshconfig, by Lord Darth Moultak dset(d,5) dset(f,-*-helvetica-*-*-*-*-*-180-*-*-*-*-*-*) dset(C,DodgerBlue) dset(o,0) dset(x,0) dset(y,0) dset(l) dset(t) smix(d,5) smix(f,-*-helvetica-*-*-*-*-*-180-*-*-*-*-*-*) smix(C,DodgerBlue) smix(o,0) smix(x,0) smix(y,0) smix(l) smix(b) sppp(d,5) sppp(f,-*-helvetica-*-*-*-*-*-180-*-*-*-*-*-*) sppp(C,DodgerBlue) sppp(o,0) sppp(x,0) sppp(y,100) sppp(l) sppp(t) sapm(d,5) sapm(f,-*-helvetica-*-*-*-*-*-180-*-*-*-*-*-*) sapm(C,yellow) sapm(o,0) sapm(x,0) sapm(y,50) sapm(l) sapm(t) sclk(d,5) sclk(f,-*-helvetica-*-*-*-*-*-180-*-*-*-*-*-*) sclk(C,red) sclk(o,0) sclk(x,270) sclk(y,0) sclk(r) sclk(t) pdev(ppp0) clkf(bigger fonts time is %H : %M : %S) clck(1) mixr(1) apmw(1) pppw(1) osdsh-0.7.0/themes/README0100644000175400001440000000070507511672037014415 0ustar moultakusersThis directory contains sample script files for osdsh and osdctl. These scripts or themes can be run thru osdctl or piped to the fifo of osdsh. testscript: a simple theme, using the "fixed" font. Enables everything. biggerfonts: just as testscript, but using the "helvetica" font in a bigger size. welcome: Adjust this script to a font that exists on your system. This is a presentation/demo of osdsh. To try these scripts do: $ osdctl -S script osdsh-0.7.0/themes/testscript0100644000175400001440000000133407565537404015672 0ustar moultakusers#This osdsh theme was created #with Tkosdshconfig, by Lord Darth Moultak dset(d,5) dset(f,fixed) dset(C,DodgerBlue) dset(o,0) dset(x,0) dset(y,0) dset(l) dset(t) smix(d,5) smix(f,fixed) smix(C,DodgerBlue) smix(o,0) smix(x,0) smix(y,0) smix(l) smix(b) sppp(d,5) sppp(f,fixed) sppp(C,DodgerBlue) sppp(o,0) sppp(x,0) sppp(y,80) sppp(l) sppp(t) sapm(d,5) sapm(f,fixed) sapm(C,yellow) sapm(o,0) sapm(x,0) sapm(y,50) sapm(l) sapm(t) sclk(d,5) sclk(f,fixed) sclk(C,red) sclk(o,0) sclk(x,200) sclk(y,0) sclk(r) sclk(t) pdev(ppp0) clkf(testscript time is %H : %M : %S) clck(1) mixr(1) apmw(1) pppw(1) connecting(connecting..... first line,connecting.... secound line) connected(we are connected,get to work now.) disconnected(disconnected,) osdsh-0.7.0/themes/welcome0100644000175400001440000000055207565540067015121 0ustar moultakusersdset(x,300) dset(l) dset(y,300) dset(t) dset(f,-*-helvetica-*-*-*-*-*-360-*-*-*-*-*-*) dset(C,DodgerBlue) dset(d,5) strn(Welcome to osdSH,HELLO!!!) sleep(4) strn(Isn't it sexy?,It is\\\, I know) sleep(4) dset(x,0) bars(Sexyness bar:,100) sleep(5) dset(x,300) strn(All your base are,belong to osdsh) sleep(4) strn(Thank you \\\(very much\\\), Lord Darth Moultak) osdsh-0.7.0/tkosdshconfig0100755000175400001440000001627007565537326015061 0ustar moultakusers#!/usr/bin/wish wm title . "osdSH configuration tool" menu .menu menu .menu.osd .menu.osd add checkbutton -variable settings -onvalue Mixer -label "Mixer" -command {configure_osd smix} .menu.osd add checkbutton -variable settings -onvalue Connection -label "Connection" -command {configure_osd sppp } .menu.osd add checkbutton -variable settings -onvalue Clock -label "Clock" -command {configure_osd sclk} .menu.osd add checkbutton -variable settings -onvalue Battery -label "Battery" -command {configure_osd sapm} .menu.osd add checkbutton -variable settings -onvalue Main -label "Main" -command {configure_osd dset} menu .menu.file .menu.file add command -label "Load theme..." -command load_theme .menu.file add command -label "Save Theme as..." -command save_theme .menu.file add command -label "Try this theme" -command {save_theme $fifofile} .menu.file add command -label "Quit" -command "destroy ." .menu add cascade -label "File" -menu .menu.file .menu add cascade -label "Configure" -menu .menu.osd . configure -menu .menu set settings Main foreach a {dset sppp sclk sapm smix} { frame .$a label .$a.title -textvariable settings grid .$a.title -row 0 -column 0 -columnspan 2 -sticky nsew array set $a { delay "5" color "green" font "fixed" xoffset "0" yoffset "0" xside "Left" yside "Top" shad "0" extra "" extra2 "" extra3 "" extra4 "" extra5 "" extra6 "" active 0 } checkbutton .$a.active -variable $a\(active) -text "Active" grid .$a.active -row 0 -column 2 -columnspan 2 -sticky nsew label .$a.delay -text "Delay:" label .$a.color -text "Color:" label .$a.font -text "Font:" label .$a.xpos -text "X side:" label .$a.xoff -text "X distance:" label .$a.ypos -text "Y edge:" label .$a.yoff -text "Y distance:" label .$a.shad -text "Shadow offset:" grid .$a.delay -row 1 -column 0 -sticky nsew grid .$a.color -row 2 -column 0 -sticky nsew grid .$a.font -row 3 -column 0 -sticky nsew grid .$a.shad -row 4 -column 0 -sticky nsew grid .$a.xpos -row 1 -column 2 -sticky nsew grid .$a.xoff -row 2 -column 2 -sticky nsew grid .$a.ypos -row 3 -column 2 -sticky nsew grid .$a.yoff -row 4 -column 2 -sticky nsew entry .$a.delayent -textvariable $a\(delay) entry .$a.colorent -textvariable $a\(color) entry .$a.fontent -textvariable $a\(font) entry .$a.shadent -textvariable $a\(shad) entry .$a.xoffent -textvariable $a\(xoffset) entry .$a.yoffent -textvariable $a\(yoffset) tk_optionMenu .$a.xside $a\(xside) Left Center Right tk_optionMenu .$a.yside $a\(yside) Top Bottom grid .$a.delayent -row 1 -column 1 -sticky nsew grid .$a.colorent -row 2 -column 1 -sticky nsew grid .$a.fontent -row 3 -column 1 -sticky nsew grid .$a.shadent -row 4 -column 1 -sticky nsew grid .$a.xside -row 1 -column 3 -sticky nsew grid .$a.xoffent -row 2 -column 3 -sticky nsew grid .$a.yside -row 3 -column 3 -sticky nsew grid .$a.yoffent -row 4 -column 3 -sticky nsew } set sclk(extra) "%H:%M:%S" label .sclk.formatlab -text "Clock format:" entry .sclk.format -textvariable sclk(extra) grid .sclk.formatlab -row 5 -column 0 -columnspan 2 -sticky nsew grid .sclk.format -row 5 -column 2 -columnspan 2 -sticky nsew set sppp(extra) ppp0 label .sppp.devicelab -text "PPP Interface:" entry .sppp.deviceent -textvariable sppp(extra) label .sppp.connectinglab -text "Connecting string" entry .sppp.connecting1 -textvariable sppp(extra2) entry .sppp.connecting2 -textvariable sppp(extra3) label .sppp.connectedlab -text "Connected string" entry .sppp.connected1 -textvariable sppp(extra4) entry .sppp.connected2 -textvariable sppp(extra5) label .sppp.disconnectedlab -text "Disconnect string" entry .sppp.disconnected -textvariable sppp(extra6) grid .sppp.devicelab -row 0 -column 4 -sticky nsew grid .sppp.connectinglab -row 1 -column 4 -sticky nsew grid .sppp.connectedlab -row 3 -column 4 -sticky nsew grid .sppp.disconnectedlab -row 5 -column 4 -sticky nsew grid .sppp.deviceent -row 0 -column 5 -sticky nsew grid .sppp.connecting1 -row 1 -column 5 -sticky nsew grid .sppp.connecting2 -row 2 -column 5 -sticky nsew grid .sppp.connected1 -row 3 -column 5 -sticky nsew grid .sppp.connected2 -row 4 -column 5 -sticky nsew grid .sppp.disconnected -row 5 -column 5 -sticky nsew proc configure_osd {osd} { global fifofile set fifo [open $fifofile w+] puts $fifo $osd\(d,-1\) close $fifo grid forget .smix .sppp .sapm .sclk .dset grid .$osd -column 0 -row 1 -columnspan 2 } proc load_theme {} { global smix sppp sapm sclk dset set file [tk_getOpenFile] if {$file == ""} {} else { set id [open $file r] while {[gets $id readbuf] >= 0} { set separate [split $readbuf \(|,|\)] set command [lindex $separate 0] set option [lindex $separate 1] set argument [lindex $separate 2] switch $option { C {set option color} f {set option font} d {set option delay} x {set option xoffset} y {set option yoffset} t {set option yside;set argument Top} b {set option yside;set argument Bottom} l {set option xside;set argument Left} c {set option xside;set argument Center} r {set option xside;set argument Right} o {set option shad} } switch $command { mixr {set command smix set argument $option set option active} clck {set command sclk set argument $option set option active} apmw {set command sapm set argument $option set option active} pppw {set command sppp set argument $option set option active} clkf {set command sclk set argument $option set option extra} pdev {set command sppp set argument $option set option extra} connecting {set command sppp set sppp(extra2) $option set option extra3} connected {set command sppp set sppp(extra4) $option set option extra5} disconnected {set command sppp set argument $option set option extra6} } set $command\($option) $argument } close $id } } proc save_theme {args} { if {[lindex $args 0]==""} { set file [tk_getSaveFile] } else { set file [lindex $args 0] } if {$file == ""} {} else { set id [open $file w] puts $id "#This osdsh theme was created for osdsh-0.6.0" puts $id "#with Tkosdshconfig, by Lord Darth Moultak" foreach a {dset smix sppp sapm sclk} { global $a puts $id $a\(d\,[expr \$$a\(delay)]) puts $id $a\(f\,[expr \$$a\(font)]) puts $id $a\(C\,[expr \$$a\(color)]) puts $id $a\(o\,[expr \$$a\(shad)]) puts $id $a\(x\,[expr \$$a\(xoffset)]) puts $id $a\(y\,[expr \$$a\(yoffset)]) if {[expr \$$a\(xside)=="Right"]} { puts $id $a\(r) } else { if {[expr \$$a\(xside)=="Center"]} { puts $id $a\(c) } else { puts $id $a\(l) } } if {[expr \$$a\(yside)=="Bottom"]} { puts $id $a\(b) } else { puts $id $a\(t) } } puts $id "pdev($sppp(extra))" puts $id "clkf($sclk(extra))" puts $id "clck($sclk(active))" puts $id "mixr($smix(active))" puts $id "apmw($sapm(active))" puts $id "pppw($sppp(active))" puts $id "connecting($sppp(extra2),$sppp(extra3))" puts $id "connected($sppp(extra4),$sppp(extra5))" puts $id "disconnected($sppp(extra6),)" close $id } } set uid [exec id -u] set fifofile /tmp/osdsh.$uid configure_osd dset osdsh-0.7.0/README.plugins0100644000175400001440000000267507640201777014622 0ustar moultakusersOK... this new version (0.7.0) uses plugins.... YEAH! *** WARNING *** If you want to write a new plugin, contact me to asign a number to it so it wont conflict with others... *** WARNING *** This number is requiered for the plugins to work... Ok... the plugins must have the next functions: whoami: a function that returns this "plugin number" mynameis : a function that returns a char pointer to the name of the plugin initialize_myosd : a function that sets the default values for the osd of your plugin isitmine : a function that reads a command and 2 arguments, and executes it if it applies to the plugin. if so returns 1, else returns 0. This plugin should be able to execute a "stop" command with no arguments that stops the plugin(of course). To change the look of the displays, I made a function called control_options that can be found on the "utils.c" file... copy this file if you like it and use it on your plugins This function is going to be called a lot, so write it carefully, it is going to start, stop and change the look of your plugin, and is the only contact the user is going to have with your plugin... The function that does the actual work should be called by a pthread(...) call so it won't block the whole program. anything not correctly defined here, please contact me and check the source of the plugins Now go for it.... contact me if you write a new plugin, and maybe i'll include it in the standard dist.