parent
fb7ee5c17a
commit
76f42f4812
@ -1,3 +0,0 @@
|
||||
[submodule "admin"]
|
||||
path = admin
|
||||
url = https://system@scm.trinitydesktop.org/scm/git/tde-common-admin
|
@ -1,15 +0,0 @@
|
||||
messagesold:
|
||||
LIST=`find . -name \*.py`; \
|
||||
if test -n "$$LIST"; then \
|
||||
xgettext -ki18n -LPython $$LIST -o po/guidance.pot; \
|
||||
fi
|
||||
|
||||
sh /usr/lib/kubuntu-desktop-i18n/findfiles LIST
|
||||
perl /usr/lib/kubuntu-desktop-i18n/createdesktop.pl --file-list=LIST --base-dir=. > desktop.guidance.tmp
|
||||
msguniq --to-code=UTF-8 --no-wrap -o desktop.guidance desktop.guidance.tmp 2>/dev/null
|
||||
python /usr/lib/kubuntu-desktop-i18n/msgsplit desktop.guidance
|
||||
mv desktop.guidance po/desktop_guidance.pot
|
||||
rm -f desktop.guidance desktop.guidance.tmp
|
||||
|
||||
messages:
|
||||
true
|
@ -1 +0,0 @@
|
||||
Subproject commit 34c35e11fbc7237f94ec8ede61ef0c8c9b6c58b3
|
@ -1,516 +0,0 @@
|
||||
/*#########################################################################
|
||||
# ixf86misc.c - #
|
||||
# ------------------------------ #
|
||||
# copyright : (C) 2004-2007 by Simon Edwards #
|
||||
# email : simon@simonzone.com #
|
||||
# #
|
||||
###########################################################################
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
###########################################################################
|
||||
# A small binding for playing with the gamma and RandR settings under #
|
||||
# XFree86. #
|
||||
# #
|
||||
# Simon Edwards <simon@simonzone.com> #
|
||||
#########################################################################*/
|
||||
|
||||
#include "Python.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
|
||||
/***************************************************************************
|
||||
XOpenDisplay(displayname)
|
||||
|
||||
Args:
|
||||
displayname - String
|
||||
|
||||
Returns:
|
||||
opaque display reference.
|
||||
*/
|
||||
static void ixf86misc_destroydisplay(void *ptr) {
|
||||
if(ptr!=NULL) {
|
||||
XCloseDisplay((Display *)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *ixf86misc_xopendisplay(PyObject *self, PyObject *args) {
|
||||
Display *dpy;
|
||||
char *displayname = NULL;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "z", &displayname)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(displayname);
|
||||
if(dpy==NULL) {
|
||||
return Py_BuildValue("");
|
||||
} else {
|
||||
return PyCObject_FromVoidPtr((void *)dpy,ixf86misc_destroydisplay);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
DefaultScreen(display)
|
||||
|
||||
Args:
|
||||
display - display object.
|
||||
Returns:
|
||||
|
||||
screen number - integer
|
||||
*/
|
||||
static PyObject *ixf86misc_defaultscreen(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
int screen;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||
return NULL;
|
||||
}
|
||||
screen = DefaultScreen((Display *)PyCObject_AsVoidPtr(pydisplay));
|
||||
return Py_BuildValue("i", screen);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
ScreenCount(display)
|
||||
|
||||
Args:
|
||||
display - display object.
|
||||
Returns:
|
||||
|
||||
number of screens - integer
|
||||
*/
|
||||
static PyObject *ixf86misc_screencount(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
int count;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||
return NULL;
|
||||
}
|
||||
count = ScreenCount((Display *)PyCObject_AsVoidPtr(pydisplay));
|
||||
return Py_BuildValue("i", count);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
RootWindow(display,screennumber)
|
||||
|
||||
*/
|
||||
static PyObject *ixf86misc_rootwindow(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
int screen = 0;
|
||||
Drawable pydrawable;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pydrawable = RootWindow((Display *)PyCObject_AsVoidPtr(pydisplay),screen);
|
||||
return Py_BuildValue("l",pydrawable);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
static PyObject *ixf86misc_getgamma(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
int screen = 0;
|
||||
XF86VidModeGamma gamma;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!XF86VidModeGetGamma((Display *)PyCObject_AsVoidPtr(pydisplay), screen, &gamma)) {
|
||||
/* FIXME set an exception? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_BuildValue("(fff)", gamma.red, gamma.green, gamma.blue);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
static PyObject *ixf86misc_setgamma(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display;
|
||||
int screen = 0;
|
||||
XF86VidModeGamma gamma;
|
||||
float red,green,blue;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oifff", &pydisplay, &screen, &red, &green, &blue)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
if(!XF86VidModeGetGamma(display, screen, &gamma)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gamma.red = red;
|
||||
gamma.green = green;
|
||||
gamma.blue = blue;
|
||||
if(!XF86VidModeSetGamma(display, screen, &gamma)) {
|
||||
/* FIXME set an exception? */
|
||||
return NULL;
|
||||
}
|
||||
XFlush(display);
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
XRRQueryExtension (Display *dpy,
|
||||
int *event_basep, int *error_basep);
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrqueryextension(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display;
|
||||
int event_basep, error_basep;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
Bool rc = XRRQueryExtension(display, &event_basep, &error_basep);
|
||||
return Py_BuildValue("(iii)",(int)rc, event_basep, error_basep);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
XRRScreenConfiguration *XRRGetScreenInfo(Display *dpy,Drawable d)
|
||||
*/
|
||||
static void ixf86misc_destroyxrrscreenconfig(void *ptr) {
|
||||
if(ptr!=NULL) {
|
||||
XRRFreeScreenConfigInfo((XRRScreenConfiguration *)ptr);
|
||||
}
|
||||
}
|
||||
static PyObject *ixf86misc_xrrgetscreeninfo(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Drawable pydrawable;
|
||||
XRRScreenConfiguration *xrrconfig;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Ol", &pydisplay, &pydrawable)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xrrconfig = XRRGetScreenInfo((Display *)PyCObject_AsVoidPtr(pydisplay), pydrawable);
|
||||
|
||||
if(xrrconfig==NULL) {
|
||||
return Py_BuildValue("");
|
||||
} else {
|
||||
return PyCObject_FromVoidPtr((void *)xrrconfig,ixf86misc_destroyxrrscreenconfig);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
SizeID XRRConfigCurrentConfiguration(XRRScreenConfiguration *config)
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrconfigcurrentconfiguration(PyObject *self, PyObject *args) {
|
||||
PyObject *pyconfig = NULL;
|
||||
Rotation currentrotation;
|
||||
SizeID currentsize;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||
return NULL;
|
||||
}
|
||||
currentsize = XRRConfigCurrentConfiguration((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig), ¤trotation);
|
||||
return Py_BuildValue("(ll)", (long)currentsize, (long)currentrotation);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
XRRRotations(display,screen)
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrrotations(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display;
|
||||
int screen = 0;
|
||||
Rotation currentrotation,availablerotations;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
availablerotations = XRRRotations(display, screen, ¤trotation);
|
||||
return Py_BuildValue("l", (long)availablerotations);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
XRRSizes(display,screen)
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrsizes(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
PyObject *sizelist,*item;
|
||||
Display *display;
|
||||
XRRScreenSize *sizes;
|
||||
int screen = 0;
|
||||
int numSizes;
|
||||
int i;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
sizelist = PyList_New(0);
|
||||
sizes = XRRSizes(display, screen, &numSizes);
|
||||
for(i = 0; i < numSizes; i++) {
|
||||
item = Py_BuildValue("(iiii)",sizes[i].width, sizes[i].height,sizes[i].mwidth, sizes[i].mheight);
|
||||
PyList_Append(sizelist, item);
|
||||
}
|
||||
|
||||
return sizelist;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
short XRRConfigCurrentRate(config)
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrconfigcurrentrate(PyObject *self, PyObject *args) {
|
||||
PyObject *pyconfig = NULL;
|
||||
int rate;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||
return NULL;
|
||||
}
|
||||
rate = XRRConfigCurrentRate((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig));
|
||||
return Py_BuildValue("i", (int)rate);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrrates(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
PyObject *ratelist,*item;
|
||||
Display *display;
|
||||
int numrates;
|
||||
int size;
|
||||
int screen = 0;
|
||||
int i;
|
||||
short *rates;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oii", &pydisplay, &screen,&size)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
rates = XRRRates(display, screen, (SizeID)size, &numrates);
|
||||
|
||||
ratelist = PyList_New(0);
|
||||
for(i = 0; i < numrates; i++) {
|
||||
item = Py_BuildValue("i",(int)rates[i]);
|
||||
PyList_Append(ratelist, item);
|
||||
}
|
||||
return ratelist;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Time XRRConfigTimes( XRRScreenConfiguration *config, Time *config_timestamp )
|
||||
*/
|
||||
|
||||
static PyObject *ixf86misc_xrrconfigtimes(PyObject *self, PyObject *args) {
|
||||
PyObject *pyconfig = NULL;
|
||||
int rate;
|
||||
Time ts,ts2;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||
return NULL;
|
||||
}
|
||||
ts2 = XRRConfigTimes((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig),&ts);
|
||||
return Py_BuildValue("l", (long)ts);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
status = XRRSetScreenConfigAndRate(display, config, window, newsize, newrotation, newrefresh, currenttime)
|
||||
*/
|
||||
static PyObject *ixf86misc_xrrsetscreenconfigandrate(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display = NULL;
|
||||
PyObject *pyconfig = NULL;
|
||||
Drawable pydrawable;
|
||||
Rotation newrotation;
|
||||
long newrefresh;
|
||||
// Time currenttime;
|
||||
Status status;
|
||||
long newsize;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "OOllll", &pydisplay, &pyconfig, &pydrawable, &newsize, &newrotation, &newrefresh /*, ¤ttime*/ )) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
status = XRRSetScreenConfigAndRate(display, (XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig), pydrawable,
|
||||
(SizeID)newsize, newrotation, newrefresh, CurrentTime);
|
||||
|
||||
return Py_BuildValue("i", (int)status);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
(dotclock,hdisplay,hsyncstart,hsyncend,htotal,vdisplay,vsyncstart,vsyncend,vtotal,flags) = \
|
||||
ixf86misc_vidmodegetmodeline(display,screen)
|
||||
|
||||
*/
|
||||
|
||||
static PyObject *ixf86misc_vidmodegetmodeline(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display = NULL;
|
||||
long screen;
|
||||
int dotclock_return;
|
||||
XF86VidModeModeLine modeline;
|
||||
PyObject *returnvalue;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Ol", &pydisplay, &screen)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
if(XF86VidModeGetModeLine(display,screen,&dotclock_return,&modeline)) {
|
||||
returnvalue = Py_BuildValue("(iiiiiiiiii)",
|
||||
dotclock_return,
|
||||
modeline.hdisplay, /* Number of display pixels horizontally */
|
||||
modeline.hsyncstart, /* Horizontal sync start */
|
||||
modeline.hsyncend, /* Horizontal sync end */
|
||||
modeline.htotal, /* Total horizontal pixels */
|
||||
modeline.vdisplay, /* Number of display pixels vertically */
|
||||
modeline.vsyncstart, /* Vertical sync start */
|
||||
modeline.vsyncend, /* Vertical sync start */
|
||||
modeline.vtotal, /* Total vertical pixels */
|
||||
modeline.flags /* Mode flags */);
|
||||
if(modeline.private!=NULL) {
|
||||
XFree(modeline.private);
|
||||
}
|
||||
return returnvalue;
|
||||
} else {
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
DisplaySize(display,screen_num)
|
||||
|
||||
Args:
|
||||
display - display object.
|
||||
screen_num - screen number
|
||||
Returns:
|
||||
|
||||
dimensions - a tuple consisting of 4 integers (width_pixels, height_pixels,
|
||||
width_mm, height_mm)
|
||||
*/
|
||||
static PyObject *ixf86misc_displaysize(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display = NULL;
|
||||
int screennum = 0;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "Oi", &pydisplay,&screennum)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
|
||||
return Py_BuildValue("(iiii)",
|
||||
DisplayWidth(display,screennum),
|
||||
DisplayHeight(display,screennum),
|
||||
DisplayWidthMM(display,screennum),
|
||||
DisplayHeightMM(display,screennum));
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
static PyObject *ixf86misc_xscreensaverqueryextension(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay = NULL;
|
||||
Display *display;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
int event_base, error_base;
|
||||
|
||||
int rc = XScreenSaverQueryExtension(display, &event_base, &error_base);
|
||||
return Py_BuildValue("i", rc);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
static void ixf86misc_destroyscreensaver(void *ptr) {
|
||||
if(ptr!=NULL) {
|
||||
XFree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *ixf86misc_xscreensaverallocinfo(PyObject *self, PyObject *args) {
|
||||
XScreenSaverInfo *ss_info;
|
||||
ss_info = XScreenSaverAllocInfo();
|
||||
return PyCObject_FromVoidPtr((void *)ss_info,ixf86misc_destroyscreensaver);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
|
||||
static PyObject *ixf86misc_xscreensaverqueryinfo(PyObject *self, PyObject *args) {
|
||||
PyObject *pydisplay;
|
||||
Display *display;
|
||||
Drawable window;
|
||||
PyObject *pyscreensaverinfo;
|
||||
XScreenSaverInfo *screensaverinfo;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "OlO", &pydisplay, &window, &pyscreensaverinfo)) {
|
||||
return NULL;
|
||||
}
|
||||
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||
screensaverinfo = (XScreenSaverInfo *)PyCObject_AsVoidPtr(pyscreensaverinfo);
|
||||
|
||||
int state = 0;
|
||||
int kind = 0;
|
||||
unsigned long idle = 0;
|
||||
unsigned long til_or_since = 0;
|
||||
if(XScreenSaverQueryInfo(display, window, screensaverinfo)) {
|
||||
state = screensaverinfo->state;
|
||||
kind = screensaverinfo->kind;
|
||||
til_or_since = screensaverinfo->til_or_since;
|
||||
idle = screensaverinfo->idle;
|
||||
}
|
||||
|
||||
return Py_BuildValue("(iikk)", state, kind ,til_or_since, idle);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*/
|
||||
|
||||
static struct PyMethodDef ixf86misc_methods[] = {
|
||||
{ "XOpenDisplay", ixf86misc_xopendisplay, METH_VARARGS },
|
||||
{ "DefaultScreen", ixf86misc_defaultscreen, METH_VARARGS },
|
||||
{ "ScreenCount", ixf86misc_screencount, METH_VARARGS },
|
||||
{ "GetGamma", ixf86misc_getgamma, METH_VARARGS },
|
||||
{ "SetGamma", ixf86misc_setgamma, METH_VARARGS },
|
||||
{ "RootWindow", ixf86misc_rootwindow, METH_VARARGS },
|
||||
{ "XRRGetScreenInfo", ixf86misc_xrrgetscreeninfo, METH_VARARGS },
|
||||
{ "XRRConfigCurrentConfiguration", ixf86misc_xrrconfigcurrentconfiguration, METH_VARARGS },
|
||||
{ "XRRRotations", ixf86misc_xrrrotations, METH_VARARGS },
|
||||
{ "XRRSizes", ixf86misc_xrrsizes, METH_VARARGS },
|
||||
{ "XRRConfigCurrentRate", ixf86misc_xrrconfigcurrentrate, METH_VARARGS },
|
||||
{ "XRRRates", ixf86misc_xrrrates, METH_VARARGS },
|
||||
{ "XRRConfigTimes", ixf86misc_xrrconfigtimes, METH_VARARGS },
|
||||
{ "XRRSetScreenConfigAndRate", ixf86misc_xrrsetscreenconfigandrate, METH_VARARGS },
|
||||
{ "XF86VidModeGetModeLine", ixf86misc_vidmodegetmodeline, METH_VARARGS },
|
||||
{ "DisplaySize", ixf86misc_displaysize, METH_VARARGS },
|
||||
{ "XScreenSaverQueryExtension", ixf86misc_xscreensaverqueryextension, METH_VARARGS },
|
||||
{ "XScreenSaverAllocInfo", ixf86misc_xscreensaverallocinfo, METH_VARARGS },
|
||||
{ "XScreenSaverQueryInfo", ixf86misc_xscreensaverqueryinfo, METH_VARARGS },
|
||||
{ "XRRQueryExtension", ixf86misc_xrrqueryextension, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
void initixf86misc(void) {
|
||||
PyObject *ixf86misc = Py_InitModule3("ixf86misc",ixf86misc_methods,"Bindings for some XFree86 config functions.");
|
||||
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
###########################################################################
|
||||
# xf86misc.py - #
|
||||
# ------------------------------ #
|
||||
# copyright : (C) 2004 by Simon Edwards #
|
||||
# email : simon@simonzone.com #
|
||||
# #
|
||||
###########################################################################
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
###########################################################################
|
||||
"""A simple interface for changing the current gamma setting under XFree86.
|
||||
"""
|
||||
import ixf86misc
|
||||
import os, time
|
||||
|
||||
class XF86Screen(object):
|
||||
|
||||
RR_Rotate_0 = 1
|
||||
RR_Rotate_90 = 2
|
||||
RR_Rotate_180 = 4
|
||||
RR_Rotate_270 = 8
|
||||
RR_Reflect_X = 16
|
||||
RR_Reflect_Y = 32
|
||||
|
||||
def __init__(self,display,screenid):
|
||||
self.screenid = screenid
|
||||
self.display = display
|
||||
self.ssinfo = None
|
||||
self.starttime = time.time()
|
||||
self.resettime = 0
|
||||
self.lastidle = 0
|
||||
|
||||
self.screenconfig = None
|
||||
self._load()
|
||||
|
||||
def _load(self):
|
||||
# Check for the presence of the xrandr extension.
|
||||
try:
|
||||
(rc,x,y) = ixf86misc.XRRQueryExtension(self.display)
|
||||
if rc==0:
|
||||
return
|
||||
except AttributeError as errmsg:
|
||||
print("Trapped AttributeError:", errmsg, " - attempting to continue.")
|
||||
return
|
||||
|
||||
self.screenconfig = ixf86misc.XRRGetScreenInfo(self.display, ixf86misc.RootWindow(self.display, self.screenid))
|
||||
if self.screenconfig is not None:
|
||||
(self.currentsizeid,self.currentrotation) = ixf86misc.XRRConfigCurrentConfiguration(self.screenconfig)
|
||||
self.availablerotations = ixf86misc.XRRRotations(self.display, self.screenid)
|
||||
self.sizes = ixf86misc.XRRSizes(self.display, self.screenid)
|
||||
self.currentrefreshrate = ixf86misc.XRRConfigCurrentRate(self.screenconfig)
|
||||
|
||||
def resolutionSupportAvailable(self):
|
||||
return self.screenconfig is not None
|
||||
|
||||
def getScreenId(self):
|
||||
return self.screenid
|
||||
|
||||
def getGamma(self):
|
||||
return ixf86misc.GetGamma(self.display,self.screenid)
|
||||
|
||||
def setGamma(self,gammatuple):
|
||||
ixf86misc.SetGamma(self.display,self.screenid,gammatuple[0],gammatuple[1],gammatuple[2])
|
||||
|
||||
def getRotation(self):
|
||||
return self.currentrotation
|
||||
|
||||
def getAvailableRotations(self):
|
||||
return self.availablerotations
|
||||
|
||||
def getSize(self):
|
||||
return self.sizes[self.currentsizeid]
|
||||
|
||||
def getSizeID(self):
|
||||
return self.currentsizeid
|
||||
|
||||
def getAvailableSizes(self):
|
||||
return self.sizes[:]
|
||||
|
||||
def getRefreshRate(self):
|
||||
return self.currentrefreshrate
|
||||
|
||||
def getAvailableRefreshRates(self,sizeid):
|
||||
return ixf86misc.XRRRates(self.display,self.screenid,sizeid)
|
||||
|
||||
def setScreenConfigAndRate(self, sizeid, rotation, refresh):
|
||||
rc = ixf86misc.XRRSetScreenConfigAndRate(self.display, self.screenconfig, \
|
||||
ixf86misc.RootWindow(self.display, self.screenid), sizeid, rotation, refresh)
|
||||
#ixf86misc.XRRConfigTimes(self.screenconfig) \
|
||||
|
||||
self._load()
|
||||
return rc # FIXME handle failures due to the timestamp.
|
||||
|
||||
def getDimensions(self):
|
||||
return ixf86misc.DisplaySize(self.display,self.screenid)
|
||||
|
||||
def getIdleSeconds(self):
|
||||
data = self.__getScreenSaverInfo()
|
||||
if data is None:
|
||||
return 0
|
||||
|
||||
(state, kind, til_or_since, idle) = data
|
||||
idletime = idle/1000.0
|
||||
|
||||
if (self.lastidle > idletime) or (self.resettime > idletime): # Something has moved in the meantime
|
||||
self.starttime = 0
|
||||
self.resettime = 0
|
||||
else:
|
||||
idletime = idletime - self.resettime
|
||||
self.lastidle = idletime
|
||||
return idletime
|
||||
|
||||
def resetIdleSeconds(self):
|
||||
self.resettime = time.time() - self.starttime
|
||||
|
||||
# See man XScreenSaver(3)
|
||||
def __getScreenSaverInfo(self):
|
||||
if self.ssinfo is None:
|
||||
if ixf86misc.XScreenSaverQueryExtension(self.display):
|
||||
self.ssinfo = ixf86misc.XScreenSaverAllocInfo()
|
||||
else:
|
||||
return 0 # Error actually.
|
||||
|
||||
return ixf86misc.XScreenSaverQueryInfo(self.display,
|
||||
ixf86misc.RootWindow(self.display, self.screenid), self.ssinfo)
|
||||
|
||||
|
||||
class XF86Server(object):
|
||||
def __init__(self,displayname=None):
|
||||
if displayname==None:
|
||||
if 'DISPLAY' in os.environ:
|
||||
displayname = os.environ['DISPLAY']
|
||||
else:
|
||||
displayname = ":0.0"
|
||||
self.displayname = displayname
|
||||
self.display = ixf86misc.XOpenDisplay(displayname)
|
||||
if self.display is None:
|
||||
raise XF86Error("Couldn't connect to X server.")
|
||||
|
||||
self._defaultscreen = ixf86misc.DefaultScreen(self.display)
|
||||
|
||||
self.screens = []
|
||||
for i in range(ixf86misc.ScreenCount(self.display)):
|
||||
self.screens.append(XF86Screen(self.display,i))
|
||||
|
||||
def getDefaultScreen(self):
|
||||
return self.screens[self._defaultscreen]
|
||||
|
||||
def getDisplay(self):
|
||||
return self.display
|
||||
|
||||
def getDisplayName(self):
|
||||
return self.displayname
|
||||
|
||||
def getScreens(self):
|
||||
return self.screens[:]
|
||||
|
||||
def resolutionSupportAvailable(self):
|
||||
return self.screens[0].resolutionSupportAvailable()
|
||||
|
||||
class XF86Error(Exception):
|
||||
"""Just an exception when some goes wrong with X."""
|
||||
|
||||
if __name__=='__main__':
|
||||
xg = XF86Server()
|
||||
xs = xg.getDefaultScreen()
|
||||
print("Number of screens:",str(len(xg.screens)))
|
||||
print("Idle seconds:",xs.getIdleSeconds())
|
||||
print()
|
||||
print("Gamma:"+str(xs.getGamma()))
|
||||
print()
|
||||
if xg.resolutionSupportAvailable():
|
||||
print("SizeID:"+str(xs.getSizeID()))
|
||||
print("Size:"+str(xs.getSize()))
|
||||
sizes = xs.getAvailableSizes()
|
||||
print("Available Sizes:" + str(sizes))
|
||||
print()
|
||||
print("Rotation:" + str(xs.getRotation()))
|
||||
print("Available Rotations:" + str(xs.getAvailableRotations()))
|
||||
print()
|
||||
print("Refresh rate:" + str(xs.getRefreshRate()))
|
||||
print("Refresh rates for the current screen:"+str(xs.getAvailableRefreshRates(xs.getSizeID())))
|
||||
|
||||
for i in range(len(sizes)):
|
||||
print("All Refresh Rates:"+str(xs.getAvailableRefreshRates(i)))
|
||||
xs.setScreenConfigAndRate(0,1,75)
|
||||
print("SizeID:"+str(xs.getSizeID()))
|
||||
print("Size:"+str(xs.getSize()))
|
||||
sizes = xs.getAvailableSizes()
|
||||
print("Available Sizes:" + str(sizes))
|
||||
else:
|
||||
print("(no resolution / randr support available)")
|
@ -1,100 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
###########################################################################
|
||||
# setup - description #
|
||||
# ------------------------------ #
|
||||
# begin : Fri Jun 27 2003 #
|
||||
# copyright : (C) 2003-2006 by Simon Edwards #
|
||||
# email : simon@simonzone.com #
|
||||
# #
|
||||
###########################################################################
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
###########################################################################
|
||||
|
||||
|
||||
from distutils.core import Extension
|
||||
import tdedistutils
|
||||
|
||||
|
||||
def doit():
|
||||
tdedistutils.setup(
|
||||
name = "guidance",
|
||||
version = "0.8.0",
|
||||
author = "Simon Edwards",
|
||||
author_email = "simon@simonzone.com",
|
||||
url = "http://www.simonzone.com/software/guidance/",
|
||||
min_kde_version = "3.0.0",
|
||||
min_tqt_version = "3.0.0",
|
||||
license = "GPL",
|
||||
docbooks = [('doc/en','en')],
|
||||
package_dir = {'':'modules'},
|
||||
py_modules = ['xf86misc'],
|
||||
|
||||
ext_modules = [Extension('ixf86misc',\
|
||||
sources = ['modules/ixf86misc.c'],\
|
||||
library_dirs = ['/usr/X11R6/lib'],\
|
||||
libraries = ['X11','Xxf86vm','Xext','Xrandr','Xrender','Xss'])],
|
||||
|
||||
executable_links = [('serviceconfig','serviceconfig.py'),
|
||||
('userconfig','userconfig.py'),
|
||||
('mountconfig','mountconfig.py')],
|
||||
|
||||
kcontrol_modules = [('serviceconfig/serviceconfig.desktop','serviceconfig.py'),
|
||||
('userconfig/userconfig.desktop','userconfig.py'),
|
||||
('mountconfig/mountconfig.desktop','mountconfig.py')],
|
||||
|
||||
data_files = [('share/icons/crystalsvg/16x16/apps',['kde/serviceconfig/pics/16x16/daemons.png',
|
||||
'kde/mountconfig/pics/16x16/disksfilesystems.png',
|
||||
'kde/userconfig/pics/16x16/userconfig.png'])],
|
||||
|
||||
i18n = ('po',['mountconfig','userconfig','serviceconfig']),
|
||||
|
||||
application_data = [('pics',['kde/serviceconfig/pics/laserwarn.png',
|
||||
'kde/serviceconfig/pics/hi32-app-daemons.png',
|
||||
'kde/userconfig/pics/hi16-encrypted.png',
|
||||
'kde/userconfig/pics/hi32-user.png',
|
||||
'kde/userconfig/pics/hi32-group.png',
|
||||
'kde/userconfig/pics/hi32-identity.png',
|
||||
'kde/userconfig/pics/hi32-password.png',
|
||||
'kde/mountconfig/pics/kcmpartitions.png',
|
||||
'kde/mountconfig/pics/trinity1.png',
|
||||
'kde/mountconfig/pics/trinity2.png',
|
||||
'kde/mountconfig/pics/trinity3.png',
|
||||
'kde/mountconfig/pics/trinity4.png',
|
||||
'kde/mountconfig/pics/trinity5.png',
|
||||
'kde/mountconfig/pics/trinity6.png',
|
||||
'kde/mountconfig/pics/hi32-samba.png',
|
||||
'kde/mountconfig/pics/hi16-hdd.png',
|
||||
'kde/mountconfig/pics/hi16-cdrom.png',
|
||||
'kde/mountconfig/pics/hi16-burner.png',
|
||||
'kde/mountconfig/pics/hi16-floppy.png',
|
||||
'kde/mountconfig/pics/hi16-blockdevice.png',
|
||||
'kde/mountconfig/pics/hi16-password.png',
|
||||
'kde/mountconfig/pics/hi16-memory.png',
|
||||
'kde/mountconfig/pics/hi16-network.png',
|
||||
'kde/mountconfig/pics/hi16-lock.png',
|
||||
'kde/mountconfig/pics/hi16-usbpen.png',
|
||||
'kde/mountconfig/pics/greenled.png',
|
||||
'kde/mountconfig/pics/greyled.png',
|
||||
'kde/mountconfig/pics/exec.png',
|
||||
'kde/mountconfig/pics/file.png',
|
||||
'kde/mountconfig/pics/important.png',
|
||||
'kde/mountconfig/pics/tux.png',
|
||||
'kde/mountconfig/pics/user.png']),
|
||||
'serviceconfig/serviceconfig.py',
|
||||
'userconfig/userconfig.py',
|
||||
'userconfig/unixauthdb.py',
|
||||
'mountconfig/mountconfig.py',
|
||||
'mountconfig/MicroHAL.py',
|
||||
'mountconfig/SMBShareSelectDialog.py',
|
||||
'mountconfig/SimpleCommandRunner.py',
|
||||
'mountconfig/fuser.py',
|
||||
'mountconfig/fuser_ui.ui',
|
||||
'mountconfig/sizeview.py'])
|
||||
|
||||
doit()
|
Loading…
Reference in new issue