pyosd-0.2.14/0000755000175000017500000000000010304534314012651 5ustar resolveresolvepyosd-0.2.14/modules/0000755000175000017500000000000010304534314014321 5ustar resolveresolvepyosd-0.2.14/modules/battery.py0000644000175000017500000001134310303160461016344 0ustar resolveresolve#!/usr/bin/env python # # Copyright (C) Damien Elmes , 2001. # This file is licensed under the GPL. Please see COPYING for more details. # """ Display battery usage information and monitor for low available battery. The default warn and shutdown percentages are very conservative, due to a badly designed Compaq laptop I own which 'loses' 10% of the total capacity if allowed to fully discharge. Ideally the info file's warning and low capacity information should be used instead. """ # percentage when a warning should appear THRESHOLD_WARN = 11 # percentage when the computer should be automatically shut down THRESHOLD_SHUTDOWN = 9 # total battery capacity (if acpi doesn't know this value) TOTAL_CAPACITY = 3736.0 ACPI_PROC_DIR = "/proc/acpi/battery/" STATE_FILE = "state" INFO_FILE = "info" import commands import os import re import string import pyosd, pyosd.daemon as pyd class BatteryStatus: """Provides battery status information. Provides status information such as the charging state and remaining capacity. Usage: bs = BatteryStatus() bs.check() print bs.availablePercentage""" def __init__(self, battery="BAT0"): """The battery argument can be used to specify a particular battery to use, otherwise the first one will be used.""" self.batteryPath = os.path.join(ACPI_PROC_DIR, battery) stateFilePath = os.path.join(self.batteryPath, STATE_FILE) try: self.stateFile = open(stateFilePath) except: raise "Couldn't open battery state file: %s" % \ stateFilePath self.findTotalCapacity() def findTotalCapacity(self): "Try and derive the total capacity if it's available" infoFilePath = os.path.join(self.batteryPath, INFO_FILE) try: infoFile = open(infoFilePath) data = self.readFile(infoFile) if data['last full capacity']: full = int(string.split( data['last full capacity'])[0]) if full: self.totalCapacity = full return except IOError: self.totalCapacity = TOTAL_CAPACITY def check(self): """Check battery status""" self.data = self.readFile(self.stateFile) self.remainingCapacity = int(string.split(self.data['remaining capacity'])[0]) self.percentAvailable = (self.remainingCapacity / float(self.totalCapacity)) * 100 def readFile(self, fileObj): """Read an ACPI info or state file into a hash""" fileObj.seek(0) lines = fileObj.readlines() data = {} for line in lines: (id, val) = string.split(line, ":", maxsplit=1) data[id] = string.strip(val) return data class plugin: def __init__(self): self.plugin_name = "battery" self.plugin_desc = "Display ACPI battery status" self.plugin_keys = ["bat"] self.batstat = BatteryStatus() self.increment = 100 self.check_battery() def check_battery(self): """Check battery status and warn when it reaches a certain level""" self.batstat.check() if self.batstat.data['charging state'] == 'discharging': # if the battery is discharging, check we're not running out of # power if self.batstat.percentAvailable < THRESHOLD_SHUTDOWN: pyd.top.set_timeout(-1) pyd.top.display(("Critical! Battery at less than %d%%" + " - shutting down") % threshhold_shutdown) os.system("sync") os.system("sudo halt") return if self.batstat.percentAvailable < THRESHOLD_WARN: pyd.top.set_timeout(-1) pyd.top.display("Alert! Battery at %d%%" % self.batstat.percentAvailable) if self.batstat.percentAvailable < self.increment: self.bat() self.increment = self.batstat.percentAvailable - 5 else: pyd.top.set_timeout(3) self.increment = 100 pyd.reactor.callLater(30, self.check_battery) def bat(self, *args): """Display battery info""" self.batstat.check() if self.batstat.data['charging state'] in ('unknown', 'charged'): state = "On A/C power." else: state = self.batstat.data['charging state'] state = state + " (at %d%%)" % self.batstat.percentAvailable pyd.top.set_colour("#bbbbFF") pyd.top.set_timeout(3) pyd.top.display(state) pyd.top.display(self.batstat.percentAvailable, type=pyosd.TYPE_PERCENT, line=1) pyosd-0.2.14/modules/display.py0000644000175000017500000000116710002470305016337 0ustar resolveresolve#!/usr/bin/env python # # $Id$ # # Time-stamp: <2003-12-16 13:45:51 resolve> # # Copyright (C) Damien Elmes , 2001. # This file is licensed under the GPL. Please see COPYING for more details. # """ Plugin for displaying arbitrary messages. """ import pyosd, pyosd.daemon as pyd import string class plugin: def __init__(self): self.plugin_name = "display" self.plugin_desc = "display an arbitrary message" self.plugin_keys = ["display"] def display(self, *args): pyd.top.set_colour("#bbbbFF") pyd.top.set_timeout(3) pyd.top.display(string.join(args)) pyosd-0.2.14/modules/volume.py0000644000175000017500000000251107715351325016214 0ustar resolveresolve#!/usr/bin/env python # # $Id: volume.py,v 1.3 2003/06/11 11:31:26 resolve Exp $ # # Time-stamp: <2002-04-01 00:25:37 resolve> # # Copyright (C) Damien Elmes , 2001. # This file is licensed under the GPL. Please see COPYING for more details. # """ Plugin for PyOSDd which facilitates changing volume """ import commands import os import re import pyosd, pyosd.daemon as pyd class plugin: def __init__(self): self.plugin_name = "volume" self.plugin_desc = "Alter main system volume" self.plugin_keys = ["vol"] def vol(self, *args): """ Set or display the volume """ if args: vol_str = args[0] # set the new volume os.system("aumix -v %s" % vol_str) self.display_volume() def display_volume(self): """ Determine current volume, and display it. """ # twisted bug import signal signal.signal(signal.SIGCHLD, signal.SIG_DFL) # read volume in output = commands.getoutput("aumix -q") # locate main volume m = re.match("vol (\d+),", output) vol = int(m.group(1)) # display! pyd.top.set_colour("#bbbbFF") pyd.top.set_timeout(3) pyd.top.display("Volume (%d%%)" % vol) pyd.top.display(vol, type=pyosd.TYPE_PERCENT, line=1) pyosd-0.2.14/pyosd/0000755000175000017500000000000010304534314014007 5ustar resolveresolvepyosd-0.2.14/pyosd/__init__.py0000644000175000017500000001547510304534004016130 0ustar resolveresolve#!/usr/bin/env python # # Started 5/8/01 by Damien Elmes # This file is licensed under the GPL. # Copyright 2001-2004 Damien Elmes # ''' pyosd - a wrapper of libxosd which allows the displaying of "on screen display" messages. example usage: | import pyosd | p = pyosd.osd() | # try fixed if the default_font gives you an error | | p.display("eschew obfuscation") | p.set_pos(pyosd.POS_BOT) | p.display("this will be down the bottom.") .. etc. Multiple instances can be used to display information in different fonts or colours across the screen. ''' import _pyosd import re import string POS_TOP=0 POS_BOT=1 POS_MID=2 ALIGN_LEFT=0 ALIGN_CENTER=1 ALIGN_RIGHT=2 TYPE_STRING=0 TYPE_PERCENT=1 TYPE_SLIDER=2 error = _pyosd.error default_font="-*-helvetica-medium-r-normal-*-*-360-*-*-p-*-*-*" class osd: """ osd is a class used to create an object which can display messages on the screen. """ def __init__(self, font=default_font, colour="#FFFFFF",timeout=3, \ pos=POS_TOP, offset=0, hoffset=0, shadow=0, align=ALIGN_LEFT, lines=2, noLocale=False): """ Initialise the OSD library. This must be done before display() will work. It will automatically deinit if necessary. font(pyosd.default_font): standard string-style X font description colour('#FFFFFF'): standard string-style X colour description timeout(3): number of seconds to remain on screen (-1 for infinite) pos(POS_TOP): position, one of POS_TOP or POS_BOT offset(0): vertical offset from pos shadow(0): black shadow size lines(2): the max number of lines available to display at once. noLocale(False): disable setlocale() In order to display foreign characters properly, pyosd calls setlocale() when a new object is created. If you are using threads in your application, or if you wish to set the locale yourself, pass noLocale=True, and use code like the following at the top of your application: import locale locale.setlocale(locale.LC_ALL, "") """ self._osd = _pyosd.init(lines) # save this as we won't have access to it on del self._deinit = _pyosd.deinit self.set_font(font) self.set_colour(colour) self.set_pos(pos) self.set_vertical_offset(offset) self.set_horizontal_offset(hoffset) self.set_shadow_offset(shadow) self.set_align(align) self.set_timeout(timeout) # this should be safe to run on each object initialisation if not noLocale: import locale locale.setlocale(locale.LC_ALL, "") def __del__(self): """ Shut down and clean up. Note that init() will automatically do this step if necessary. """ # prevent python from dying if a user's silly enough to call this # directly if hasattr(self, '_osd'): self._deinit(self._osd) del self._osd def display(self, arg, type=TYPE_STRING, line=0): """ Display a string/bargraph/percentage using information from init() arg: a string or integer from 1-100, depending on the type -- defaults -- type(TYPE_STRING): one of TYPE_STRING, TYPE_PERCENT, or TYPE_SLIDER line(0): the line to display text on The underlying library currently doesn't zero out previous lines that aren't being used, so if you wish to display something on, say, line 1, make sure you simultaneously display "" on line 0. """ if line >= self.get_number_lines() or line < 0: raise ValueError, "specified line is out of range" if type==TYPE_STRING: _pyosd.display_string(self._osd, line, arg) elif type==TYPE_PERCENT: _pyosd.display_perc(self._osd, line, int(arg)) elif type==TYPE_SLIDER: _pyosd.display_slider(self._osd, line, int(arg)) else: raise ValueError, "type not in list of valid values!" def set_font(self, font): """Change the font. `font' should be a normal X font specification.""" _pyosd.set_font(self._osd, font) def set_colour(self, c): """Change the colour.""" _pyosd.set_colour(self._osd, c) def set_timeout(self, t): """Change the timeout. This takes effect immediately; anything that is currently displayed will wait the new timeout time before clearing.""" _pyosd.set_timeout(self._osd, t) def set_pos(self, p): """Change the position to the top or bottom.""" _pyosd.set_pos(self._osd, p) def set_align(self, a): """Change the alignment to left, center or right.""" _pyosd.set_align(self._osd,a) def set_vertical_offset(self, o): """Change the vertical offset from the top or bottom.""" _pyosd.set_vertical_offset(self._osd, o) def set_offset(self, o): """This method is here for compability issues. Usage of this is deprecated. set_vertical_offset should be used instead.""" self.set_vertical_offset(o) def set_horizontal_offset(self,o): """Change the horizontal offset from the left or right.""" _pyosd.set_horizontal_offset(self._osd,o) def set_shadow_colour(self, col): """Change the colour of the shadow.""" _pyosd.set_shadow_colour(self._osd, col) def set_shadow_offset(self, o): """Change the offset of the shadow.""" _pyosd.set_shadow_offset(self._osd, o) def set_outline_offset(self, o): """Change the offset of the text outline.""" _pyosd.set_outline_offset(self._osd, o) def set_outline_colour(self, c): """Change the colour of the outline.""" _pyosd.set_outline_colour(self._osd, c) def set_bar_length(self, o): """Change the bar length.""" _pyosd.set_bar_length(self._osd, o) def scroll(self, lines=1): """Scroll the display.""" if lines >= self.get_number_lines() or lines < 0: raise ValueError, "specified line is out of range" _pyosd.scroll(self._osd, lines) def hide(self): """Hide the display.""" _pyosd.hide(self._osd) def show(self): """Show the display.""" _pyosd.show(self._osd) def wait_until_no_display(self): """Block until nothing is displayed.""" _pyosd.wait_until_no_display(self._osd) def is_onscreen(self): """True if PyOSD is currently displaying something.""" return _pyosd.is_onscreen(self._osd) def get_number_lines(self): "Returns the maximum number of lines which can be displayed." return _pyosd.get_number_lines(self._osd) pyosd-0.2.14/pyosd/daemon.py0000644000175000017500000000670010005064731015626 0ustar resolveresolve#!/usr/bin/env python # # $Id: daemon.py,v 1.2 2003/06/11 11:31:31 resolve Exp $ # # Time-stamp: <2004-01-26 12:14:00 resolve> # # Copyright (C) Damien Elmes , 2001. # This file is licensed under the GPL. Please see COPYING for more details. # """ A daemon to coordinate OSD messages. This is a program that uses the twisted event framework to listen on a TCP port for incoming messages. These messages consist of a command name, followed by zero or more optional arguments. The command can either be 'display', to display some text as an OSD, or the name of a command provided by a plugin module. The reason a daemon is useful is to allow separate programs to output to the screen without their messages overlapping each other. Earlier messages on that portion of the screen are hidden before the next one is displayed. Modules are bits of python code which can take arbitrary actions when they receive a string. A sample invocation of the 'volume' module, which takes an argument to set the volume to, and then displays the current volume in a bar graph: echo 'vol -5' | nc -q 0 localhost 8007 And to just print a string at the bottom of the screen, you might use: echo 'display -bot hello world' | nc -q 0 localhost 8007 nc is a program called 'netcat', available in most distributions, which makes it easy to send a string to a TCP port. """ import os import pyosd import pyosd.daemon import sys import string from twisted.protocols.basic import LineReceiver from twisted.internet.protocol import Factory from twisted.internet import reactor PYOSD_DIR = os.path.expanduser("~/.pyosd") PYOSD_SOCKET = os.path.join(PYOSD_DIR, "socket") MODULES_DIR = os.path.join(PYOSD_DIR, "modules") if __name__ == "__main__": if len(sys.argv)>1 and sys.argv[1] == "allinterfaces": allinterfaces=1 else: allinterfaces=0 args = [] kwargs = {'shadow': 0} pyosd.daemon.top = apply(pyosd.osd, args, kwargs) pyosd.daemon.top.set_pos(pyosd.POS_TOP) pyosd.daemon.bot = apply(pyosd.osd, args, kwargs) pyosd.daemon.bot.set_pos(pyosd.POS_BOT) pyosd.daemon.top.set_outline_offset(1) pyosd.daemon.bot.set_outline_offset(1) class PyOSDServ: modules = {} error = 0 files = os.listdir(MODULES_DIR) for f in files: try: namespace = {} execfile(os.path.join(MODULES_DIR, f), namespace) c = namespace['plugin']() except: print "Unable to load module: %s" % f error=1 if not error: print "Adding plugin: %s" % f for k in c.plugin_keys: modules[k] = c class PyOSDConn(LineReceiver): def __init__(self): self.delimiter = "\n" pass def lineReceived(self, line): s = string.split(line) if not s: print "Not s" return cmd = s[0] if PyOSDServ.modules.has_key(cmd): apply(getattr(PyOSDServ.modules[cmd], cmd), s[1:]) else: print "Unknown command: %s" % line factory = Factory() factory.protocol = PyOSDConn pyosd.daemon.reactor = reactor if allinterfaces: print "Binding to all interfaces.." reactor.listenTCP(8007, factory) #, interface='127.0.0.1') else: reactor.listenTCP(8007, factory, interface='127.0.0.1') reactor.run() pyosd-0.2.14/AUTHORS0000644000175000017500000000044610002471752013726 0ustar resolveresolvePyOSD was started by Damien Elmes Thanks to: * People who have sent patches * Everyone who worked on original libxosd :-) * The people who package pyosd for the various distributions * All the people in the python community who offer free advice and assistance pyosd-0.2.14/COPYING0000644000175000017500000004311007715351107013714 0ustar resolveresolve GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pyosd-0.2.14/ChangeLog0000644000175000017500000001403710303166121014424 0ustar resolveresolve# do not edit -- automatically generated by arch changelog # arch-tag: automatic-ChangeLog--arch@repose.cx--03/pyosd--dev--1.0 # 2005-08-24 21:53:04 GMT Damien Elmes patch-17 Summary: add note about wait_until_no_display(), update ver Revision: pyosd--dev--1.0--patch-17 add note about wait_until_no_display(), update ver modified files: README setup.py 2005-08-24 21:44:36 GMT Damien Elmes patch-16 Summary: cast slider/percentage argument to int Revision: pyosd--dev--1.0--patch-16 cast slider/percentage argument to int modified files: pyosd/__init__.py 2005-08-24 21:43:07 GMT Damien Elmes patch-15 Summary: fixed =tagging-method Revision: pyosd--dev--1.0--patch-15 fixed =tagging-method modified files: {arch}/=tagging-method 2005-08-24 21:09:56 GMT Damien Elmes patch-14 Summary: battery.py fixes Revision: pyosd--dev--1.0--patch-14 * cast totalCapacity as a float, to avoid erroneous "battery at 0%" messages * derive the last full battery capacity if available * don't rely on unix directory ordering - assume BAT0. * code tidy-up. modified files: modules/battery.py 2005-08-24 07:41:49 GMT Damien Elmes patch-13 Summary: add setlocale() support Revision: pyosd--dev--1.0--patch-13 pyosd now calls setlocale() each time a pyosd object is initialized. This should be fine for the majority of programmers out there and is thus provided as a time-saving measure. Multi-threaded applications should set up the locale themselves. modified files: pyosd/__init__.py 2005-08-24 07:11:16 GMT Damien Elmes patch-12 Summary: updated tagging defs Revision: pyosd--dev--1.0--patch-12 updated tagging defs modified files: {arch}/=tagging-method 2005-02-12 07:43:43 GMT Damien Elmes patch-11 Summary: change header includes to prevent warnings Revision: pyosd--dev--1.0--patch-11 change header includes to prevent warnings modified files: _pyosd.c 2005-01-27 12:46:39 GMT Damien Elmes patch-10 Summary: add python-side bindings Revision: pyosd--dev--1.0--patch-10 add python-side bindings modified files: pyosd/__init__.py setup.py 2004-10-28 16:08:10 GMT Damien Elmes patch-9 Summary: add set_bar_length Revision: pyosd--dev--1.0--patch-9 patch from Joe LaPenna (joelapenna /at/ gmail /dot/ com) to add support for changing the bar length. modified files: AUTHORS COPYING ChangeLog.old MANIFEST.in README.daemon _pyosd.c pyosd.html setup.py modified directories: modules pyosd 2004-07-25 11:59:09 GMT Damien Elmes patch-8 Summary: bugfix for scroll() Revision: pyosd--dev--1.0--patch-8 Fixed a bug in scroll(), thanks to Mikael Pirio (mikael /at/ pirio /dot/ org) modified files: pyosd/__init__.py setup.py 2004-03-01 05:19:14 GMT Damien Elmes patch-7 Summary: more function bindings Revision: pyosd--dev--1.0--patch-7 Another patch from Hans to add more function bindings. modified files: MANIFEST _pyosd.c pyosd/__init__.py setup.py {arch}/=tagging-method 2004-02-22 13:46:11 GMT Damien Elmes patch-6 Summary: added alignment support Revision: pyosd--dev--1.0--patch-6 Thanks to Hans Oluf Hagen (hohagen /at/ start /dot/ no), support for setting the alignment of the text has been added. For example: >>> import pyosd >>> p = pyosd.osd() >>> p.set_align(pyosd.ALIGN_CENTER) >>> p.display("hello") modified files: _pyosd.c pyosd/__init__.py 2004-01-26 01:14:31 GMT Damien Elmes patch-5 Summary: add outline in pyosd daemon Revision: pyosd--dev--1.0--patch-5 add outline in pyosd daemon modified files: pyosd/daemon.py 2004-01-18 12:17:02 GMT Damien Elmes patch-4 Summary: alter method defs to reflect new immediate behaviour Revision: pyosd--dev--1.0--patch-4 alter method defs to reflect new immediate behaviour modified files: pyosd/__init__.py 2004-01-18 11:55:44 GMT Damien Elmes patch-3 Summary: update for new release Revision: pyosd--dev--1.0--patch-3 update for new release modified files: AUTHORS MANIFEST.in README README.daemon 2004-01-18 11:51:54 GMT Damien Elmes patch-2 Summary: add display.py to daemon modules Revision: pyosd--dev--1.0--patch-2 (included in initial import - this log just for reference) Added display.py to the list of daemon modules, to display arbitrary messages. 2004-01-18 11:51:12 GMT Damien Elmes patch-1 Summary: add extra xosd functions Revision: pyosd--dev--1.0--patch-1 (included in initial import - this commit just for reference) Patch from "Alex V. Myltsev" libxosd (as of version 2.2.5) contains some functions missing from pyosd-0.2.6. Attached is a trivial patch that adds their support to pyosd. Also I think it's worth mentioning that libxosd-2.2.5 seems to honor all changes immediately: e.g. color of the font is changed when set_colour is called, not after a display(). 2004-01-18 11:49:02 GMT Damien Elmes base-0 Summary: initial import Revision: pyosd--dev--1.0--base-0 (automatically generated log message) new files: AUTHORS COPYING ChangeLog.old MANIFEST MANIFEST.in README README.daemon _pyosd.c modules/battery.py modules/display.py modules/volume.py pyosd.html pyosd/__init__.py pyosd/daemon.py setup.py pyosd-0.2.14/ChangeLog.old0000644000175000017500000000235507715351107015216 0ustar resolveresolve2002-01-08 Damien Elmes * pyosd.py 1.4: oops, forgot to update the module docstring * README 1.3: updated to reflect new API and version number. * _pyosd.c 1.4: * fixed a nasty bug which cropped up when readline was being used in the interactive interpreter. SIGINT is now blocked in the xosd library. * pyosd.py 1.3: * added defaults for the remaining args to __init__. who knows why i did not do it earlier. 2002-01-02 Damien Elmes * README 1.2: * oops. the different line should read "fixed", not the same as the original. * README 1.1: New file. * pyosd.py 1.2: * got rid of some trailing spaces in the source file. * pyosd.py 1.1: New file. * _pyosd.c 1.3: * added a bunch of set methods so that everything except lines can be changed on the fly now * most functions pass around a xosd * now instead of using a global one. this allows a bunch of different class instances to display different stuff at once 2001-12-19 Damien Elmes * _pyosd.c 1.2: * _pyosd.c should now raise an exception if libxosd fails to init 2001-12-11 Damien Elmes * _pyosd.c 1.1: New file. 2001-12-07 Damien Elmes * pyosd.c 1.1: New file. pyosd-0.2.14/README0000644000175000017500000000465610303165670013550 0ustar resolveresolvePyOSD: A python wrapper for libxosd ----------------------------------- Description ----------- PyOSD is a python module for displaying text on your X display, much like the "On Screen Displays" used on TVs and some monitors. This is useful for such things as displaying the currently playing song in your media player. Installation ------------ PyOSD will now run out of the box provided you have xosd version 1.0.0 or later. So fetch and install that first. You can find xosd here: http://www.ignavus.net/software.html Installing pyosd ---------------- All you need here is distutils, which is packaged with recent pythons. If you're using debian, install python2.1-dev (or your preferred version) People with a umask that doesn't allow files to be world readable have reported permission problems installing these files. If you're installing via sudo the umask will be inherited - make sure site-packages/{_pyosd.so,pyosd*/*} are world readable. Then: $ python setup.py build (then as root) # python setup.py install ** NOTE ** If you were previously using an older version of pyosd and didn't uninstall it first, you may have difficulty using the new version. The solution to that is to run a command like this: $ rm /usr/lib/python2.1/site-packages/pyosd.py Since pyosd is now a directory. How to use ---------- Here's an example python session with the basics: $ python ... >>> import pyosd >>> p = pyosd.osd() >>> p.display("this is a message") >>> p.set_pos(pyosd.POS_BOT) >>> p.display("this will be down the bottom") That code should display a message at the top of your screen, and then another at the bottom. If you receive an error, it's possible you don't have that font. You can try a line like this instead: >>> p = pyosd.osd("fixed", "white") The default font is: >>> pyosd.default_font '-adobe-helvetica-medium-r-normal-*-*-400-*-*-p-*-iso8859-1' When you use pyosd in a script, you need to make it wait for your message to be displayed. To do this, try: >>> p.wait_until_no_display() You can read more about the inteface by looking at pyosd.html Feedback -------- If you have any questions or problems with this, please don't hesitate to give me a yell. -- Damien Elmes pyosd@repose.cx http://repose.cx/pyosd pyosd-0.2.14/README.daemon0000644000175000017500000000144010002472030014761 0ustar resolveresolvePyOSD daemon ------------- PyOSD ships with a simple "daemon", which can help coordinate messages so that, say, successive attempts to update a slider bar don't result in 5 slider bars displayed over each other, but instead each one replaces the former. To use this daemon, * create ~/.pyosd/modules, and copy the modules you'd like. * install pyosd as per README, then run: python /usr/lib/python2.1/site-packages/pyosd/daemon.py (or the path to your location) * now you can send things to port 8007. try telnet or netcat. example in my sawfish config: (bind-keys global-keymap "F13" '(system "echo 'vol -5' | nc -q 0 localhost 8007")) The daemon only binds to localhost, so should not present a security risk from external machines. -- Damien Elmes pyosd@repose.cx http://repose.cx/pyosd pyosd-0.2.14/_pyosd.c0000644000175000017500000003464310303016443014321 0ustar resolveresolve/* pyosd - a wrapper of libxosd which allows the displaying of "on screen display" messages. Started 7/12/01. Copyright (C) 2001-2004, Damien Elmes . This file is licensed under the GPL. Please see the file COPYING for more details. To compile this file, you will need libxosd. I'm waiting for a response from the author about some patches, so for now use the version included with this distribution. */ #include #include #include // raised if there's an error in the underlying library (such as X not running) static PyObject *pyosd_error; // lazy prototypes static PyObject *pyosd_init(PyObject *self, PyObject *args); static PyObject *pyosd_deinit(PyObject *self, PyObject *args); static PyObject *pyosd_display_string(PyObject *self, PyObject *args); static PyObject *pyosd_display_perc(PyObject *self, PyObject *args); static PyObject *pyosd_display_slider(PyObject *self, PyObject *args); static PyObject *pyosd_set_colour(PyObject *self, PyObject *args); static PyObject *pyosd_set_font(PyObject *self, PyObject *args); static PyObject *pyosd_set_timeout(PyObject *self, PyObject *args); static PyObject *pyosd_set_pos(PyObject *self, PyObject *args); static PyObject *pyosd_set_vertical_offset(PyObject *self, PyObject *args); static PyObject *pyosd_set_shadow_offset(PyObject *self, PyObject *args); static PyObject *pyosd_set_shadow_colour(PyObject *self, PyObject *args); static PyObject *pyosd_set_outline_offset(PyObject *self, PyObject *args); static PyObject *pyosd_set_outline_colour(PyObject *self, PyObject *args); static PyObject *pyosd_set_align(PyObject *self, PyObject *args); static PyObject *pyosd_set_bar_length(PyObject *self, PyObject *args); static PyObject *pyosd_scroll(PyObject *self, PyObject *args); static PyObject *pyosd_hide(PyObject *self, PyObject *args); static PyObject *pyosd_show(PyObject *self, PyObject *args); static PyObject *pyosd_wait_until_no_display(PyObject *self, PyObject *args); static PyObject *pyosd_is_onscreen(PyObject *self, PyObject *args); static PyObject *pyosd_get_number_lines(PyObject *self, PyObject *args); static PyObject *pyosd_set_horizontal_offset(PyObject* self, PyObject *args); static PyMethodDef pyosd_methods[] = { {"init", pyosd_init, METH_VARARGS}, {"deinit", pyosd_deinit, METH_VARARGS}, {"display_string", pyosd_display_string, METH_VARARGS}, {"display_perc", pyosd_display_perc, METH_VARARGS}, {"display_slider", pyosd_display_slider, METH_VARARGS}, {"set_font", pyosd_set_font, METH_VARARGS}, {"set_colour", pyosd_set_colour, METH_VARARGS}, {"set_timeout", pyosd_set_timeout, METH_VARARGS}, {"set_pos", pyosd_set_pos, METH_VARARGS}, {"set_vertical_offset",pyosd_set_vertical_offset, METH_VARARGS}, {"set_horizontal_offset",pyosd_set_horizontal_offset, METH_VARARGS}, {"set_shadow_offset", pyosd_set_shadow_offset, METH_VARARGS}, {"set_shadow_colour", pyosd_set_shadow_colour, METH_VARARGS}, {"set_outline_offset",pyosd_set_outline_offset,METH_VARARGS}, {"set_outline_colour",pyosd_set_outline_colour,METH_VARARGS}, {"set_align", pyosd_set_align, METH_VARARGS}, {"set_bar_length", pyosd_set_bar_length, METH_VARARGS}, {"scroll", pyosd_scroll, METH_VARARGS}, {"hide", pyosd_hide, METH_VARARGS}, {"show", pyosd_show, METH_VARARGS}, {"wait_until_no_display", pyosd_wait_until_no_display, METH_VARARGS}, {"is_onscreen", pyosd_is_onscreen, METH_VARARGS}, {"get_number_lines", pyosd_get_number_lines, METH_VARARGS}, {NULL, NULL} }; void init_pyosd(void) { PyObject *self; PyObject *dict; // create the module and add the functions self = Py_InitModule("_pyosd", pyosd_methods); // init custom exception dict = PyModule_GetDict(self); pyosd_error = PyErr_NewException("pyosd.error", NULL, NULL); PyDict_SetItemString(dict, "error", pyosd_error); } //////////////////////////////////////////////////////////////////////// // check to see that osd is a valid pointer. if it's not, raise an error // and return return 0 static int assert_osd(xosd *osd, char *error) { if (!osd) { PyErr_SetString(pyosd_error, error); return 0; } return 1; } // pyosd_init(lines) // initialise the osd interface static PyObject * pyosd_init(PyObject *self, PyObject *args) { int lines; PyObject *pyc_osd; xosd *osd = NULL; sigset_t newset; if(!PyArg_ParseTuple(args, "i", &lines)) return NULL; // ensure we're not currently initialised if (osd) pyosd_deinit(NULL, NULL); // due to an unfortunate interaction with readline, we have to ensure // that signals are disabled while calling xosd_init - this stops the // threads it spawns from accepting SIGINT, and tripping up python sigemptyset(&newset); sigaddset(&newset, SIGINT); sigprocmask(SIG_BLOCK, &newset, NULL); // bring it up osd = xosd_create(lines); // turn SIGINT back on for the main app sigprocmask(SIG_UNBLOCK, &newset, NULL); if(!osd) { // we don't use assert_osd here, because we want to pass back the error // from the underlying code PyErr_SetString(pyosd_error, xosd_error); return NULL; } // we've now got a osd reference, which we need to package up and return // to the surrounding python code pyc_osd = PyCObject_FromVoidPtr((void *)osd, NULL); return pyc_osd; } static PyObject * pyosd_deinit(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(osd==NULL) { PyErr_SetString(pyosd_error, "Already deinitialised"); return NULL; } // deinit - the wrapping python should clear out the // cobject as well, as it's no longer valid. xosd_destroy(osd); osd = NULL; Py_INCREF(Py_None); return Py_None; } // pyosd_display_string(line, string) static PyObject * pyosd_display_string(PyObject *self, PyObject *args) { int line; char *str; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Ois", &pyc_osd, &line, &str)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_display(osd, line, XOSD_string, str); Py_INCREF(Py_None); return Py_None; } // FIXME // pyosd_display_perc(line, percentage) static PyObject * pyosd_display_perc(PyObject *self, PyObject *args) { int line; int perc; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oii", &pyc_osd, &line, &perc)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_display(osd, line, XOSD_percentage, perc); Py_INCREF(Py_None); return Py_None; } // pyosd_display_slider(line, slider) static PyObject * pyosd_display_slider(PyObject *self, PyObject *args) { int line; int slider; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oii", &pyc_osd, &line, &slider)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_display(osd, line, XOSD_slider, slider); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_font(PyObject *self, PyObject *args) { char *font; int res; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Os", &pyc_osd, &font)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; res = xosd_set_font(osd, font); if(res==-1) { PyErr_SetString(pyosd_error, xosd_error); return NULL; } Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_colour(PyObject *self, PyObject *args) { char *colour; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Os", &pyc_osd, &colour)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_colour(osd, colour); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_timeout(PyObject *self, PyObject *args) { int timeout; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &timeout)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_timeout(osd, timeout); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_pos(PyObject *self, PyObject *args) { int pos; PyObject *pyc_osd; xosd *osd; xosd_pos osd_pos; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &pos)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; if (pos==0) osd_pos = XOSD_top; else if (pos==1) osd_pos = XOSD_bottom; else if (pos == 2) osd_pos = XOSD_middle; else { PyErr_SetString(PyExc_ValueError, "OSD position not in range"); return NULL; } xosd_set_pos(osd, pos); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_align(PyObject *self, PyObject *args) { int align; PyObject *pyc_osd; xosd *osd; xosd_align osd_align; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &align)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; if (align==0) osd_align = XOSD_left; else if (align==1) osd_align = XOSD_center; else if (align==2) osd_align = XOSD_right; else{ PyErr_SetString(PyExc_ValueError, "OSD align not in range"); return NULL; } xosd_set_align(osd, align); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_bar_length(PyObject *self, PyObject *args) { int bar_length; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &bar_length)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_bar_length(osd, bar_length); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_vertical_offset(PyObject *self, PyObject *args) { int offset; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &offset)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_vertical_offset(osd, offset); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_horizontal_offset(PyObject *self, PyObject *args) { int offset; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &offset)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_horizontal_offset(osd, offset); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_shadow_colour(PyObject *self, PyObject *args) { char *colour; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Os", &pyc_osd, &colour)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_shadow_colour(osd, colour); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_shadow_offset(PyObject *self, PyObject *args) { int offset; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &offset)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_shadow_offset(osd, offset); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_outline_offset(PyObject *self, PyObject *args) { int offset; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &offset)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_outline_offset(osd, offset); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_set_outline_colour(PyObject *self, PyObject *args) { char *colour; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Os", &pyc_osd, &colour)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_set_outline_colour(osd, colour); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_scroll(PyObject *self, PyObject *args) { int amount; PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "Oi", &pyc_osd, &amount)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_scroll(osd, amount); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_hide(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_hide(osd); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_show(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_show(osd); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_wait_until_no_display(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; xosd_wait_until_no_display(osd); Py_INCREF(Py_None); return Py_None; } static PyObject * pyosd_is_onscreen(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; return Py_BuildValue("i", xosd_is_onscreen(osd)); } static PyObject * pyosd_get_number_lines(PyObject *self, PyObject *args) { PyObject *pyc_osd; xosd *osd; if(!PyArg_ParseTuple(args, "O", &pyc_osd)) return NULL; osd = (xosd *)PyCObject_AsVoidPtr(pyc_osd); if(!assert_osd(osd, "Run init() first!")) return NULL; return Py_BuildValue("i", xosd_get_number_lines(osd)); } // vim: set sw=2 ts=2: pyosd-0.2.14/pyosd.html0000644000175000017500000002476507715351107014724 0ustar resolveresolve Python: module pyosd
 
 
pyosd
index
/home/resolve/Code/pyosd/pyosd.py

pyosd - a wrapper of libxosd which allows the displaying of "on screen display"
         messages.
 
         example usage:
 
         | import pyosd
         | p = pyosd.osd()
         | # try fixed if the default_font gives you an error
         |
         | p.display("eschew obfuscation")
         | p.set_pos(pyosd.POS_BOT)
         | p.display("this will be down the bottom.")
 
 
         .. etc.
 
         Multiple instances can be used to display information in different
         fonts or colours across the screen.

 
Modules
            
_pyosd

 
Classes
            
exceptions.Exception
error
osd

 
class error(exceptions.Exception)
       
  
__getitem__(...) from exceptions.Exception
__init__(...) from exceptions.Exception
__str__(...) from exceptions.Exception

 
class osd
       osd is a class used to create an object which can display messages on
the screen.
 
  
__del__(self)
 Shut down and clean up.
 
Note that init() will automatically do this step if necessary.
__init__(self, font='-adobe-helvetica-medium-r-normal-*-*-400-*-*-p-*-iso8859-1', colour='#FFFFFF', timeout=3, pos=0, offset=0, shadow=0, lines=2)
 Initialise the OSD library.
 
This must be done before display() will work. It will automatically
deinit if necessary.
 
font(pyosd.default_font): standard string-style X font description
colour('#FFFFFF'): standard string-style X colour description
timeout(3): number of seconds to remain on screen (-1 for infinite)
pos(POS_TOP): position, one of POS_TOP or POS_BOT
offset(0): vertical offset from pos
shadow(0): black shadow size
lines(2): the max number of lines available to display at once
 
Unfortunately due to constraints with the underlying library, lines has
to be hard coded on init() at the moment.
display(self, arg, type=0, line=0)
 Display a string/bargraph/percentage using information from init()
 
arg: a string or integer from 1-100, depending on the type
-- defaults --
type(TYPE_STRING): one of TYPE_STRING, TYPE_PERCENT, or TYPE_SLIDER
line(0): the line to display text on
 
The underlying library currently doesn't zero out previous lines that
aren't being used, so if you wish to display something on, say, line 1,
make sure you simultaneously display "" on line 0.
set_colour(self, c)
 Change the colour.
 
This will update when display() is next called.
set_font(self, font)
 Change the font.
 
This takes effect immediately.
set_offset(self, o)
 Change the vertical offset from the top or bottom.
 
This change is immediate.
set_pos(self, p)
 Change the position to the top or bottom.
 
This change is immediate.
set_shadow_offset(self, o)
 Set the offset of the shadow.
 
This change will take effect on the next display()
set_timeout(self, t)
 Change the timeout.
 
This takes effect immediately; anything that is currently displayed
will wait the new timeout time before clearing.

 
Data
             POS_BOT = 1
POS_TOP = 0
TYPE_PERCENT = 1
TYPE_SLIDER = 2
TYPE_STRING = 0
__file__ = './pyosd.py'
__name__ = 'pyosd'
default_font = '-adobe-helvetica-medium-r-normal-*-*-400-*-*-p-*-iso8859-1'
pyosd-0.2.14/setup.py0000755000175000017500000000064710304534164014400 0ustar resolveresolve#!/usr/bin/env python from distutils.core import setup, Extension setup (name = "pyosd", version = "0.2.14", description = "Python wrapper for libosd", url = "http://repose.cx/pyosd/", author = "Damien Elmes", author_email = "pyosd@repose.cx", packages = ['pyosd'], ext_modules = \ [Extension("_pyosd", ["_pyosd.c"], libraries=["xosd"])] ) pyosd-0.2.14/PKG-INFO0000644000175000017500000000034310304534314013746 0ustar resolveresolveMetadata-Version: 1.0 Name: pyosd Version: 0.2.14 Summary: Python wrapper for libosd Home-page: http://repose.cx/pyosd/ Author: Damien Elmes Author-email: pyosd@repose.cx License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN