screen-resolution-extra-0.17.3/0000755000000000000000000000000013261663120013271 5ustar screen-resolution-extra-0.17.3/COPYING0000644000000000000000000004310311702550506014326 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General Public License instead of this License. screen-resolution-extra-0.17.3/Makefile0000644000000000000000000000146311702550506014736 0ustar DOMAIN=screen-resolution-extra PO_FILES=$(wildcard po/*.po) DESKTOP_FILES=$(basename $(wildcard */*.desktop.in)) all: po/$(DOMAIN).pot build-mo $(DESKTOP_FILES) clean: rm -rf po/mo/ rm -f po/$(DOMAIN).pot rm -f $(DESKTOP_FILES) # # i18n for po/* # # update the pot po/$(DOMAIN).pot: cd po; intltool-update -p -g $(DOMAIN) # merge the new stuff into the po files merge-po: $(PO_FILES) po/$(DOMAIN.pot) cd po; intltool-update -r -g $(DOMAIN) # create mo from po files %.mo : %.po mkdir -p $(basename $(subst po/,po/mo/,$<))/LC_MESSAGES/ msgfmt $< -o $(basename $(subst po/,po/mo/,$<))/LC_MESSAGES/$(DOMAIN).mo # generate all *.mo files build-mo: $(patsubst %.po,%.mo,$(PO_FILES)) # # i18n for *.desktop files # %.desktop : %.desktop.in intltool-merge -d po/ $< $@ .PHONY: all clean build-mo merge-po screen-resolution-extra-0.17.3/PKG-INFO0000644000000000000000000000052711702550506014373 0ustar Metadata-Version: 1.0 Name: screen-resolution-extra Version: 0.1 Summary: Extension for the GNOME Screen Resolution applet Home-page: https://launchpad.net/screen-resolution-extra Author: Alberto Milone Author-email: albertomilone@alice.it License: GPLv2 Description: Extension for the GNOME Screen Resolution applet Platform: Linux screen-resolution-extra-0.17.3/ScreenResolution/0000755000000000000000000000000012273662665016613 5ustar screen-resolution-extra-0.17.3/ScreenResolution/__init__.py0000755000000000000000000000000011702550506020677 0ustar screen-resolution-extra-0.17.3/ScreenResolution/ui.py0000755000000000000000000000543312273662665017612 0ustar # -*- coding: utf-8 -*- # ui.py # # Copyright 2008 Alberto Milone # # 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., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. import gettext class AbstractUI: '''Abstract user interface. This encapsulates the entire program logic and all strings, but does not implement any concrete user interface. ''' def __init__(self): ''' Initialize system. ''' self.gettext_domain = 'screen-resolution-extra' gettext.textdomain(self.gettext_domain) self.init_strings() def _(self, str, convert_keybindings=False): '''Keyboard accelerator aware gettext() wrapper. This optionally converts keyboard accelerators to the appropriate format for the frontend. All strings in the source code should use the '_' prefix for key accelerators (like in GTK). For inserting a real '_', use '__'. ''' # KDE compatible conversion #result = unicode(gettext.gettext(str), 'UTF-8') result = gettext.gettext(str) if convert_keybindings: result = self.convert_keybindings(result) return result def init_strings(self): '''Initialize all static strings which are used in UI implementations.''' self.string_permission_text = self._('Monitor Resolution Settings has detected that the virtual resolution \ must be set in your configuration file in order to apply your settings.\ \n\nWould you like Screen Resolution to set the virtual resolution for you? (Recommended)') self.string_dbus_cant_connect = self._('Could not connect to Monitor Resolution Settings DBUS service.') self.string_operation_complete = self._('Please log out and log back in again. You will then be able to use Monitor Resolution Settings to setup your monitors') self.string_cant_apply_settings = self._('Monitor Resolution Settings can\'t apply your settings.') self.string_title = self._('Monitor Resolution Settings') screen-resolution-extra-0.17.3/__init__.py0000644000000000000000000000000011702550506015371 0ustar screen-resolution-extra-0.17.3/com.ubuntu.ScreenResolution.Mechanism.conf0000644000000000000000000000136712300644534023454 0ustar screen-resolution-extra-0.17.3/com.ubuntu.ScreenResolution.Mechanism.service0000644000000000000000000000075612300644642024170 0ustar # Service description of the configuration backend of screen-resolution-extra. # The service must be run as root for changing Screen Resolution. # # IMPORTANT NOTICE: You have to update the service's configuration file # /etc/dbus-1/system.d/com.ubuntu.ScreenResolution.Mechanism.conf when feeling # adventurous and trying other user ids for this service. # [D-BUS Service] Name=com.ubuntu.ScreenResolution.Mechanism Exec=/usr/share/screen-resolution-extra/screenresolution-mechanism User=root screen-resolution-extra-0.17.3/debian/0000755000000000000000000000000013261663125014520 5ustar screen-resolution-extra-0.17.3/debian/changelog0000644000000000000000000002256613261663125016405 0ustar screen-resolution-extra (0.17.3) bionic; urgency=medium * SECURITY UPDATE: PID race in screenresolution-mechanism - screenresolution-mechanism: Pass the system bus name of the calling process to Policykit, rather than the PID - CVE-2018-8885 -- Chris Coulson Fri, 06 Apr 2018 13:21:41 +0100 screen-resolution-extra (0.17.2) bionic; urgency=medium * Depend on policykit-1-gnome | polkit-1-auth-agent for desktop environments that provide their own PolicyKit authentication agents. (LP: #1745815) -- Vlad Orlov Sun, 28 Jan 2018 01:14:32 +0300 screen-resolution-extra (0.17.1) trusty; urgency=low * screenresolution-mechanism: - Make sure that the mechanism uses python 3 (LP: #1274733). - Replace gobject with the gir libraries. -- Alberto Milone Tue, 18 Feb 2014 13:08:10 +0100 screen-resolution-extra (0.17) trusty; urgency=low * debian/control, debian/rules, setup.py: - Drop support for Python 2.x. * nvidia-prime.py: - Do not import gtk, gobject, os, re modules (LP: #1275223). -- Alberto Milone Mon, 03 Feb 2014 16:02:52 +0100 screen-resolution-extra (0.16ubuntu2) trusty; urgency=low * debian/control: - Add the correct Vcs-Git and Vcs-Browser. -- Alberto Milone Mon, 11 Nov 2013 11:12:44 +0100 screen-resolution-extra (0.16ubuntu1) trusty; urgency=low * Fix syntax error in nvidia-prime.py which broke upgrades. (LP: #1249460) -- Iain Lane Sat, 09 Nov 2013 17:47:47 +0000 screen-resolution-extra (0.16) trusty; urgency=low * nvidia-prime.py, screenresolution-mechanism.py, screenresolution-mechanism.policy.in, setup.py: - Add action and mechanism for Nvidia PRIME. -- Alberto Milone Fri, 08 Nov 2013 18:03:51 +0100 screen-resolution-extra (0.15ubuntu1) raring; urgency=low * Build depend on the python*-all-dev packages. -- Matthias Klose Fri, 26 Oct 2012 11:29:40 +0200 screen-resolution-extra (0.15) quantal; urgency=low * Add support for python 3. * Migrate to python-gi. * Fix issue with the new XKit API (LP: #1012774). * Drop obsolete code for the DontZap option. -- Alberto Milone Thu, 12 Jul 2012 18:58:36 +0200 screen-resolution-extra (0.14ubuntu3) quantal; urgency=low * debian/control: - Depend on python-xkit (>= 0.5.0). * policyui.py: - Add support for the new python-xkit API. -- Alberto Milone Tue, 05 Jun 2012 16:47:54 +0200 screen-resolution-extra (0.14ubuntu2) precise; urgency=low * Finish conversion to dh_python2. Fixes issue where none of screen-resolution-extra's files are installed, which prevents nvidia config from making changes to xorg.conf. (LP: #913690) * Add dependency on policykit-gnome since some scripts use gtk policykit, which won't work on KDE where gtk2 may not be installed by default. (LP: #673733, #454261) -- Bryce Harrington Mon, 09 Jan 2012 03:39:12 -0800 screen-resolution-extra (0.14ubuntu1) precise; urgency=low * Build using dh_python2. -- Matthias Klose Wed, 14 Dec 2011 16:01:42 +0100 screen-resolution-extra (0.14build2) oneiric; urgency=low * debian/rules: - Replace /usr/share/cdbs/1/rules/langpack.mk with /usr/share/cdbs/1/class/langcore.mk to fix FTBFS (LP: #829489). -- Alberto Milone Fri, 19 Aug 2011 18:56:20 +0200 screen-resolution-extra (0.14build1) natty; urgency=low * Rebuild with python 2.7 as the python default. -- Matthias Klose Wed, 08 Dec 2010 15:10:44 +0000 screen-resolution-extra (0.14) maverick; urgency=low * Update the icon name for the dialog so that the latter doesn't crash (LP: #638085). -- Alberto Milone Sat, 25 Sep 2010 16:14:11 +0200 screen-resolution-extra (0.13) lucid; urgency=low * screenresolution-mechanism.py: - Explicitly pass start-time to PolicyKit CheckAuthorization call so that it works with polkit-1 0.95. Thanks to Martin Pitt for the fix. -- Alberto Milone Thu, 21 Jan 2010 10:20:04 +0100 screen-resolution-extra (0.12) lucid; urgency=low * setup.py: - Do not install policy-dontzap.py any longer. - Install nvidia-polkit.py which will be used by nvidia-settings. -- Alberto Milone Fri, 08 Jan 2010 21:00:52 +0100 screen-resolution-extra (0.11) karmic; urgency=low * Set the virtual resolution to 2048x2048 only if a smaller framebuffer size was requested (LP: #433856). -- Alberto Milone Wed, 14 Oct 2009 14:13:27 +0200 screen-resolution-extra (0.10) karmic; urgency=low * policy-dontzap.py, policyui.py: Add missing hashbang lines (files are executable). * debian/control: Update Vcs-Bzr: to ubuntu-desktop branch. * Port to polkit-1: (LP: #435709): - screenresolution-mechanism.policy.in: auth_self_keep_always → auth_admin_keep. - setup.{py,cfg}: Install policy file into share/polkit-1/actions. - Drop ScreenResolution/policykit.py, and its usage in policyui.py and policy-dontzap.py; client-side handling of PK is not necessary any more. - screenresolution-mechanism.py: Drop PolicyKitAuthentication class, it's way too complicated. - screenresolution-mechanism.py, _check_permission(): Call polkit-1 instead of old PolicyKit. * screenresolution-mechanism.py: Actually enforce privilege check by calling _check_permission() in the service methods. * debian/control: Add policykit-1 dependency. * debian/control: Bump Standards-Version to 3.8.3 (no changes necessary). -- Martin Pitt Thu, 08 Oct 2009 14:02:54 +0200 screen-resolution-extra (0.9) karmic; urgency=low * policyui.py: - Normalise docstrings in checkVirtual(). - Remove computeVirtual() and compareFrameBuffer() as they were not used since gnome-control-center already checks the available front buffer size. - Add the optimal_virtual_resolution attribute set to [2048, 2048] (usually the highest virtual resolution which doesn't break direct rendering) to the BootWindow class and make sure that, if the required resolution is lower than optimal_virtual_resolution, the latter is used instead of the former (LP: #412948). -- Alberto Milone Thu, 13 Aug 2009 14:14:03 +0200 screen-resolution-extra (0.8) jaunty; urgency=low * Drop DEB_PYTHON_INSTALL_ARGS_ALL from debian/rules and use the default one from cdbs (fixes FTBFS). -- Michael Bienia Tue, 07 Apr 2009 10:04:14 +0200 screen-resolution-extra (0.7) jaunty; urgency=low * policyui.py: - Catch AttributeError exception if there are duplicate virtual options (LP: #282283). - Import xorgparser so that XKit exceptions are actually caught. -- Alberto Milone Mon, 06 Apr 2009 10:17:42 +0200 screen-resolution-extra (0.6) jaunty; urgency=low * Build for python2.6, include the symlinks in the package. -- Matthias Klose Tue, 24 Feb 2009 22:43:54 +0100 screen-resolution-extra (0.5) jaunty; urgency=low * debian/control: Add dependency on python-distutils-extra * screenresolution-mechanism.policy.in: - localise messages and descriptions - add new dontzap action * policy-dontzap.py: new app to set dontzap * screenresolution-mechanism.py: new setDontZap method -- Alberto Milone (tseliot) Tue, 27 Jan 2009 17:59:00 +0100 screen-resolution-extra (0.4) jaunty; urgency=low [ Scott James Remnant ] * com.ubuntu.ScreenResolution.Mechanism.conf: - allow messages to be sent to the service. LP: #306705. [ Martin Pitt ] * debian/control: Add Vcs-Bzr header. -- Scott James Remnant Sun, 04 Jan 2009 11:28:07 +0100 screen-resolution-extra (0.3) intrepid; urgency=low * Do not calculate the virtual resolution. * Modify the virtual resolution only if the required resolution is greater than the one which is currently set. -- Alberto Milone (tseliot) Wed, 24 Sep 2008 17:08:50 +0200 screen-resolution-extra (0.2) intrepid; urgency=low * Change the section to utils/x11 * Make sure that backup creation takes place only when the xorg.conf exists * Change string_operation_complete in ui.py into something easier to understand * Do not use logging logging.error when informing users in policyui.py -- Alberto Milone (tseliot) Wed, 27 Aug 2008 19:13:45 +0200 screen-resolution-extra (0.1.2) intrepid; urgency=low * Don't try and use XKit, as it hasn't been imported. Instead import xorgparser from it and use that instead. (LP: #269757) -- James Westby Sat, 13 Sep 2008 12:38:51 +0100 screen-resolution-extra (0.1.1) intrepid; urgency=low * Don't try and concatenate a string and a float (LP: #262906) - Also use strftime() to give a more understandable date suffix to the backup name. -- James Westby Fri, 12 Sep 2008 19:31:54 +0100 screen-resolution-extra (0.1) intrepid; urgency=low * First release -- Alberto Milone (tseliot) Sat, 16 Aug 2008 11:18:41 +0200 screen-resolution-extra-0.17.3/debian/compat0000644000000000000000000000000211702550506015712 0ustar 5 screen-resolution-extra-0.17.3/debian/control0000644000000000000000000000141113233174710016114 0ustar Source: screen-resolution-extra Section: x11 Priority: optional Build-Depends: debhelper (>= 7.0.50~), python3-all-dev, intltool, python3-distutils-extra Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Alberto Milone (tseliot) Standards-Version: 3.8.3 X-Python3-Version: >= 3.2 Vcs-Git: git://github.com/tseliot/screen-resolution-extra.git Vcs-Browser: https://github.com/tseliot/screen-resolution-extra.git Package: screen-resolution-extra Architecture: all Depends: ${python:Depends}, python3-xkit (>= 0.5.0), policykit-1-gnome | polkit-1-auth-agent, python3-gi, ${misc:Depends} Description: Extension for the GNOME screen resolution applet Extension for the GNOME screen resolution applet. screen-resolution-extra-0.17.3/debian/copyright0000644000000000000000000000204512273662665016466 0ustar This package has been debianized by Alberto Milone on September 21, 2007. Copyright: (C) 2007, 2008 Alberto Milone. (C) 2013 Canonical Ltd. Authors: Alberto Milone (tseliot) 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. screen-resolution-extra-0.17.3/debian/pycompat0000644000000000000000000000000211316653310016261 0ustar 2 screen-resolution-extra-0.17.3/debian/rules0000755000000000000000000000122012273674514015601 0ustar #!/usr/bin/make -f PYTHON3=$(shell py3versions -vr) PYTHON3MJ=$(shell py3versions -vr | cut -c1-1) %: dh $@ --with python3 build-python%: python$* setup.py build override_dh_auto_build: $(PYTHON3:%=build-python%) dh_auto_build install-python%: python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb override_dh_auto_install: $(PYTHON3:%=install-python%) dh_auto_install #override_dh_installchangelogs: # dh_installchangelogs -k foo/NEWS.rst #override_dh_installdocs: # python setup.py build_sphinx # dh_installdocs build/sphinx/html override_dh_auto_clean: dh_auto_clean rm -rf build rm -rf *.egg-info rm -f po/*.pot screen-resolution-extra-0.17.3/debian/screen-resolution-extra.install0000644000000000000000000000005412273662665022722 0ustar debian/tmp/usr/* usr/ debian/tmp/etc/* etc/ screen-resolution-extra-0.17.3/nvidia-polkit.py0000644000000000000000000000552512273662665016443 0ustar #!/usr/bin/python # -*- coding: utf-8 -*- ## Copyright (C) 2001-2008 Alberto Milone ## 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., 675 Mass Ave, Cambridge, MA 02139, USA. import sys, dbus, logging, os, re import optparse SERVICE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' OBJECT_PATH = '/' INTERFACE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' # Usage: # python /usr/share/screen-resolution-extra/nvidia-polkit.py --help # def get_xkit_service(widget=None): '''returns a dbus interface to the screenresolution mechanism''' service_object = dbus.SystemBus().get_object(SERVICE_NAME, OBJECT_PATH) service = dbus.Interface(service_object, INTERFACE_NAME) return service def main(options): exit_code = 1 conf = get_xkit_service() if not conf: # dbus_cant_connect logging.error("cannot connect to dbus service") sys.exit(1) if options.filename and options.backup_filename: logging.debug('making backup of /etc/X11/xorg.conf to %s and writing %s to /etc/X11/xorg.conf' \ % (options.backup_filename, options.filename)) exit_code = conf.backupAndWriteXorgConf([options.backup_filename, options.filename]) elif options.filename and not options.backup_filename: logging.debug('writing %s to /etc/X11/xorg.conf' % options.filename) exit_code = conf.writeXorgConf(options.filename) elif not options.filename and options.backup_filename: logging.debug('making backup of /etc/X11/xorg.conf to %s' % options.backup_filename) exit_code = conf.backupXorgConf(options.backup_filename) elif not options.filename and not options.backup_filename: logging.error("called with wrong arguments") return exit_code # All went well if exit_code == 0 return exit_code if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option("-w", "--write-from", dest="filename", help="write xorg.conf from FILE", metavar="FILE") parser.add_option("-b", "--backup-to", dest="backup_filename", help="backup file to FILE", metavar="FILE") (options, args) = parser.parse_args() operation_status = main(options) sys.exit(operation_status) screen-resolution-extra-0.17.3/nvidia-prime.py0000644000000000000000000000435312273663366016252 0ustar #!/usr/bin/python # -*- coding: utf-8 -*- ## Copyright 2013 Canonical Ltd. ## ## Author: Alberto Milone ## ## 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., 675 Mass Ave, Cambridge, MA 02139, USA. import sys, dbus, logging SERVICE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' OBJECT_PATH = '/' INTERFACE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' # Usage: # python /usr/share/screen-resolution-extra/nvidia-prime.py --help # def get_prime_service(widget=None): '''returns a dbus interface to the screenresolution mechanism''' service_object = dbus.SystemBus().get_object(SERVICE_NAME, OBJECT_PATH) service = dbus.Interface(service_object, INTERFACE_NAME) return service def usage(): sys.stderr.write("Usage: %s nvidia|intel\n" % (sys.argv[0])) if __name__ == '__main__': try: arg = sys.argv[1] except IndexError: arg = None if len(sys.argv[1:]) != 1: usage() exit(1) if arg == 'intel' or arg == 'nvidia': conf = get_prime_service() if not conf: # dbus_cant_connect logging.error("cannot connect to dbus service") sys.exit(1) # Exit using the retcode try: sys.exit(conf.prime_select(arg)) except dbus.exceptions.DBusException as e: message = '%s' % e sys.stderr.write(message) if 'AccessDeniedException' in message: # The user probably did not enter the password # or cancelled sys.exit(5) else: sys.exit(1) else: usage() sys.exit(1) screen-resolution-extra-0.17.3/po/0000755000000000000000000000000013233174710013710 5ustar screen-resolution-extra-0.17.3/po/POTFILES.in0000644000000000000000000000011611702550506015463 0ustar [encoding: UTF-8] ScreenResolution/ui.py screenresolution-mechanism.policy.in screen-resolution-extra-0.17.3/po/createpot.py0000644000000000000000000000042411702550506016250 0ustar #!/usr/bin/env python import os, sys if len(sys.argv) <= 1: os.system("xgettext -k_ -kN_ -o screen-resolution-extra.pot ../ScreenResolution/ui.py") print "Now edit messages.pot, save it as .po, and send it" \ " to albertomilone@alice.it.\nThanks!\n" screen-resolution-extra-0.17.3/policyui.py0000755000000000000000000001524112273662665015525 0ustar #!/usr/bin/python # -*- coding: utf-8 -*- ## Copyright (C) 2001-2008 Alberto Milone ## 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., 675 Mass Ave, Cambridge, MA 02139, USA. from gi.repository import Gtk import sys, dbus, logging from ScreenResolution import ui SERVICE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' OBJECT_PATH = '/' INTERFACE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' usage = 'python policyui.py 1024x768' import os import sys from subprocess import Popen, PIPE import xkit from xkit import xutils, xorgparser clean = False def checkVirtual(virtres): '''See if it's necessary to set the virtual resolution''' source = '/etc/X11/xorg.conf' try: a = xutils.XUtils(source) except(IOError, xkit.xorgparser.ParseException):#if xorg.conf is missing or broken return False if len(a.globaldict['Screen']) > 0: # See if the virtual resolution is already there and if it's big enough res = None for screen in a.globaldict['Screen']: try: res = a.getValue('SubSection', 'virtual', 0, identifier='Display', sect="Screen", reference=None) if res: if 'x' in res.lower(): res = res.lower().split('x') elif ' ' in res.lower().strip(): res = res.lower().split(' ') res = [x for x in res if x != ''] if len(res) == 2 and int(virtres[0]) <= int(res[0]) and int(virtres[1]) <= int(res[1]): # Nothing to do, the virtual resolution is already there return True except (xkit.xorgparser.SectionException, xkit.xorgparser.OptionException, AttributeError): pass return False def get_xkit_service(widget=None): ''' returns a dbus interface to the screenresolution mechanism ''' service_object = dbus.SystemBus().get_object(SERVICE_NAME, OBJECT_PATH) service = dbus.Interface(service_object, INTERFACE_NAME) return service def gui_dialog(message, parent_dialog, message_type=None, widget=None, page=0, broken_widget=None): ''' Displays an error dialog. ''' if message_type == 'error': message_type = Gtk.MessageType.ERROR logging.error(message) elif message_type == 'info': message_type = Gtk.MessageType.INFO logging.info(message) dialog = Gtk.MessageDialog(parent_dialog, Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT, message_type, Gtk.ButtonsType.OK, message) translation = ui.AbstractUI() dialog.set_title(translation.string_title) if widget != None: if isinstance (widget, Gtk.CList): widget.select_row (page, 0) elif isinstance (widget, Gtk.Notebook): widget.set_current_page (page) if broken_widget != None: broken_widget.grab_focus () if isinstance (broken_widget, Gtk.Entry): broken_widget.select_region (0, -1) if parent_dialog: dialog.set_position (Gtk.WindowPosition.CENTER_ON_PARENT) dialog.set_transient_for(parent_dialog) else: dialog.set_position (Gtk.WindowPosition.CENTER) ret = dialog.run () dialog.destroy() return ret class BootWindow: optimal_virtual_resolution = ['2048', '2048'] def __init__(self, resolution): translation = ui.AbstractUI() self.permission_text = translation.string_permission_text self.dbus_cant_connect = translation.string_dbus_cant_connect self.operation_complete = translation.string_operation_complete self.cant_apply_settings = translation.string_cant_apply_settings self.resolution = resolution self.question_dialog(translation.string_title, self.permission_text) def question_dialog(self, title, message): '''question_dialog(title, message) This is a generic Gtk MessageDialog function for questions. ''' dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.DialogFlags.DESTROY_WITH_PARENT, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO) dialog.set_markup("%s" % title) dialog.format_secondary_markup(message) response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: dialog.hide() self.on_button1_clicked(dialog) elif response == Gtk.ResponseType.NO: self.on_button2_clicked(dialog) else: self.on_button2_clicked(dialog) def on_button1_clicked(self, widget, data=None): #self.window.hide() self.conf = get_xkit_service() if not self.conf: sys.exit(1) # If the required resolution is lower than the optimal virtual # resolution (usually the highest resolution which doesn't break # direct rendering) then use the latter instead. if int(self.resolution[0]) < int(self.optimal_virtual_resolution[0]) and \ int(self.resolution[1]) < int(self.optimal_virtual_resolution[1]): self.resolution = self.optimal_virtual_resolution status = self.conf.setVirtual(self.resolution) #print 'Status', status if status == True: global clean clean = True def on_button2_clicked(self, widget, data=None): pass #self.window.hide() if __name__ == "__main__": if len(sys.argv) > 1: for param in sys.argv[1:]: if 'x' not in param: sys.exit(0) else: sys.exit(0) res = sys.argv[1] res = res.strip().split('x') if checkVirtual(res): sys.exit(0) window = BootWindow(res) if not clean: sys.exit(1) screen-resolution-extra-0.17.3/screenresolution-mechanism0000755000000000000000000003643713261663120020601 0ustar #!/usr/bin/python3 # -*- coding: utf-8 -*- # # Copyright (C) 2008 Fluendo Embedded S.L. (www.fluendo.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. # # 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., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # taken from: # https://code.fluendo.com/remotecontrol/trac/browser/trunk/ # gnome_lirc_properties/backend.py?rev=217 # # modified by Harald Hoyer # # modified by Alberto Milone (tseliot) import dbus, dbus.service, logging import os, os.path import sys import time import shutil import subprocess from gi.repository import GLib, GObject from xkit import xutils, xorgparser # Modern flavors of dbus bindings have that symbol in dbus.lowlevel, # for old flavours the internal _dbus_bindings module must be used. try: # pylint: disable-msg=E0611 from dbus.lowlevel import HANDLER_RESULT_NOT_YET_HANDLED except ImportError: from _dbus_bindings import HANDLER_RESULT_NOT_YET_HANDLED class AccessDeniedException(dbus.DBusException): '''This exception is raised when some operation is not permitted.''' _dbus_error_name = 'com.ubuntu.screenresolution.Mechanism.AccessDeniedException' class UnsupportedException(dbus.DBusException): '''This exception is raised when some operation is not supported.''' _dbus_error_name = 'com.ubuntu.screenresolution.Mechanism.UnsupportedException' class UsageError(dbus.DBusException): '''This exception is raised when some operation was not used properly.''' _dbus_error_name = 'com.ubuntu.screenresolution.Mechanism.UsageError' class PolicyKitService(dbus.service.Object): '''A D-BUS service that uses PolicyKit for authorization.''' def _check_permission(self, sender, conn, action, reconnect=True): ''' Verifies if the specified action is permitted, and raises an AccessDeniedException if not. ''' if sender is None and conn is None: # called locally, not through D-BUS return # get peer PID dbus_info = dbus.Interface(conn.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus/Bus', False), 'org.freedesktop.DBus') pid = dbus_info.GetConnectionUnixProcessID(sender) # query PolicyKit polkit = dbus.Interface(get_service_bus().get_object( 'org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority', False), 'org.freedesktop.PolicyKit1.Authority') try: # we don't need is_challenge return here, since we call with AllowUserInteraction (is_auth, _, details) = polkit.CheckAuthorization( ('system-bus-name', {'name': dbus.String(sender, variant_level=1)}), action, {'': ''}, dbus.UInt32(1), '', timeout=600) except dbus.DBusException as e: if reconnect and e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown': # polkitd timed out, connect again return self._check_polkit_privilege(sender, conn, action, reconnect=False) else: raise if not is_auth: logging.debug('_check_permission: sender %s on connection %s pid %i is not authorized for %s: %s' % (sender, conn, pid, action, str(details))) raise AccessDeniedException(action) class BackendService(PolicyKitService): '''A D-Bus service that PolicyKit controls access to.''' # pylint: disable-msg=C0103,E0602 INTERFACE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' SERVICE_NAME = 'com.ubuntu.ScreenResolution.Mechanism' IDLE_TIMEOUT = 30 def __init__(self, connection=None, path='/'): if connection is None: connection = get_service_bus() super(BackendService, self).__init__(connection, path) self.__name = dbus.service.BusName(self.SERVICE_NAME, connection) self.__loop = GObject.MainLoop() self.__timeout = 0 connection.add_message_filter(self.__message_filter) def __message_filter(self, connection, message): ''' D-BUS message filter that keeps the service alive, as long as it receives message. ''' if self.__timeout: self.__start_idle_timeout() return HANDLER_RESULT_NOT_YET_HANDLED def __start_idle_timeout(self): '''Restarts the timeout for terminating the service when idle.''' if self.__timeout: GObject.source_remove(self.__timeout) self.__timeout = GObject.timeout_add(self.IDLE_TIMEOUT * 1000, self.__timeout_cb) def __timeout_cb(self): '''Timeout callback that terminates the service when idle.''' # Keep service alive, as long as additional objects are exported: if self.connection.list_exported_child_objects('/'): return True print('Terminating %s due to inactivity.' % self.SERVICE_NAME) self.__loop.quit() return False def run(self): '''Creates a GLib main loop for keeping the service alive.''' print('Running %s.' % self.SERVICE_NAME) print(('Terminating it after %d seconds of inactivity.' % self.IDLE_TIMEOUT)) self.__start_idle_timeout() self.__loop.run() # pylint: disable-msg=R0913 @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='as', out_signature='b', sender_keyword='sender', connection_keyword='conn') def setVirtual(self, virtres, sender=None, conn=None): ''' Replace the first line of this example with a source and a destination file ''' self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.configure') virtual = ' '.join(virtres) source = '/etc/X11/xorg.conf' destination = '/etc/X11/xorg.conf' if os.path.exists(source): #make a backup of the xorg.conf backup = source + "." + time.strftime("%Y%m%d%H%M%S") shutil.copyfile(source, backup) try: a = xutils.XUtils(source) except(IOError, xorgparser.ParseException):#if xorg.conf is missing or broken a = xutils.XUtils()#start from scratch empty = True for section in a.globaldict: if len(a.globaldict[section]) > 0: empty = False break if empty: a.make_section('Device', 'Configured Video Device') a.make_section('Screen', identifier='Configured Screen Device') a.add_reference('Screen', 'Device', 'Configured Video Device', position=0) a.make_subsection('Screen', 'Display', position=0) a.add_suboption('Screen', 'Display', 'Virtual', value=virtual, position=0) else:#if xorg.conf exists and is not empty devicelen = len(a.globaldict['Device']) screenlen = len(a.globaldict['Screen']) if screenlen == 0: screen = a.make_section('Screen', identifier='Configured Screen Device') if devicelen == 0: device = a.make_section('Device', 'Configured Video Device') else: device = 0 a.add_reference('Screen', 'Device', 'Configured Video Device', position=device) a.make_subsection('Screen', 'Display', position=0) a.add_suboption('Screen', 'Display', 'Virtual', value=virtual, position=0) else:#if at least 1 Screen section exists ''' Set the virtual section in all the Screen sections ''' for screen in a.globaldict['Screen']: a.make_subsection('Screen', 'Display', position=screen) a.add_suboption('Screen', 'Display', 'Virtual', value=virtual, position=screen) ''' Write the changes to the destination file ''' a.write(destination) return True @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='s', out_signature='i', sender_keyword='sender', connection_keyword='conn') def setDontZap(self, enable, sender=None, conn=None): '''Try to set the DontZap option in the xorg.conf and return the exit code of dontzap''' self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.dontzap') dontzap_file = '/usr/bin/dontzap' if not os.path.isfile(dontzap_file): logging.error('/usr/bin/dontzap does not exist') return 1 if enable in ['--enable', '--disable']: logging.debug('calling dontzap with %s' % enable) retcode = subprocess.call([dontzap_file, enable]) return retcode else: logging.error('called with wrong arguments = %s' % enable) return 1 @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='s', out_signature='i', sender_keyword='sender', connection_keyword='conn') def backupXorgConf(self, backup_file, sender=None, conn=None): '''Make a backup of xorg.conf and return the exit code''' self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.configure') xorg_path = '/etc/X11' backup_path = os.path.join(xorg_path, backup_file) try: os.unlink(backup_path) logging.debug('Removing previous backup: %s' % backup_path) except(OSError, IOError): logging.debug('Nothing to remove. %s does not exist' % backup_path) pass xorg_source_path = '/etc/X11/xorg.conf' try: #make a backup of the xorg.conf shutil.copyfile(xorg_source_path, backup_path) except IOError: logging.error('%s does not exist' % xorg_source_path) return 1 return 0 @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='s', out_signature='i', sender_keyword='sender', connection_keyword='conn') def writeXorgConf(self, src_file, sender=None, conn=None): '''Validate and copy src_file to xorg.conf and return the exit code''' self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.configure') xorg_file_path = '/etc/X11/xorg.conf' try: xutils.XUtils(src_file) logging.debug('%s is a valid xorg.conf file.' % src_file) except(IOError, xorgparser.ParseException):#if xorg.conf is missing or broken logging.error('%s does not seem to be a valid xorg.conf file.' % src_file) return 1 try: shutil.copyfile(src_file, xorg_file_path) logging.debug('%s was written successfully to %s.' % (src_file, xorg_file_path)) except IOError: logging.error('%s does not exist' % xorg_source_path) return 1 return 0 @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='as', out_signature='i', sender_keyword='sender', connection_keyword='conn') def backupAndWriteXorgConf(self, files, sender=None, conn=None): '''Make a backup of xorg.conf, validate and copy a file to xorg.conf and return the exit code''' try: backup_file = files[0] src_file = files[1] except IndexError: logging.error('Invalid arguments.') return 1 self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.configure') xorg_path = '/etc/X11' xorg_file_path = os.path.join(xorg_path, 'xorg.conf') backup_path = os.path.join(xorg_path, backup_file) # Try to remove any previous backup in backup_path try: os.unlink(backup_path) logging.debug('Removing previous backup: %s' % backup_path) except(OSError, IOError): logging.debug('Nothing to remove. %s does not exist' % backup_path) pass # Try to make a backup of xorg.conf try: shutil.copyfile(xorg_file_path, backup_path) except IOError: logging.debug('%s does not exist' % xorg_file_path) # Validate src_file before writing it to xorg.conf try: xutils.XUtils(src_file) logging.debug('%s is a valid xorg.conf file.' % src_file) except(IOError, xorgparser.ParseException):#if xorg.conf is missing or broken logging.error('%s does not seem to be a valid xorg.conf file.' % src_file) return 1 try: shutil.copyfile(src_file, xorg_file_path) logging.debug('%s was written successfully to %s.' % (src_file, xorg_file_path)) except IOError: logging.error('%s does not exist' % xorg_source_path) return 1 return 0 @dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='s', out_signature='i', sender_keyword='sender', connection_keyword='conn') def prime_select(self, mode, sender=None, conn=None): '''Select and set the power profile with PRIME''' self._check_permission(sender, conn, 'com.ubuntu.screenresolution.mechanism.prime') prime_switcher = '/usr/bin/prime-select' if not os.path.isfile(prime_switcher): logging.error('%s does not exist' % prime_switcher) return 1 if mode in ['intel', 'nvidia']: logging.debug('calling %s with %s' % (prime_switcher, mode)) retcode = subprocess.call([prime_switcher, mode]) return retcode else: logging.error('called %s with wrong arguments = %s' % (prime_switcher, mode)) return 1 def get_service_bus(): '''Retrieves a reference to the D-BUS system bus.''' return dbus.SystemBus() def get_service(bus=None): '''Retrieves a reference to the D-BUS driven configuration service.''' if not bus: bus = get_service_bus() service = bus.get_object(BackendService.SERVICE_NAME, '/') service = dbus.Interface(service, BackendService.INTERFACE_NAME) return service if __name__ == '__main__': # Support full tracing when --debug switch is passed: import sys from sys import argv # Integrate DBus with GLib main loops. from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) # Run the service. if '--debug' in argv or '-d' in argv: logging.basicConfig(stream=sys.stderr) logging.getLogger().setLevel(logging.NOTSET) BackendService().run() screen-resolution-extra-0.17.3/screenresolution-mechanism.policy.in0000644000000000000000000000304012273662665022500 0ustar Screen Resolution Extra https://launchpad.net/screen-resolution-extra <_description>Change Screen Resolution Configuration <_message>Changing the Screen Resolution configuration requires privileges. no auth_admin_keep <_description>Change the effect of Ctrl+Alt+Backspace <_message>Changing the effect of Ctrl+Alt+Backspace requires privileges. no auth_admin_keep <_description>Enable or disable the NVIDIA GPU with PRIME <_message>Enabling or disabling the NVIDIA GPU requires privileges. no auth_admin_keep screen-resolution-extra-0.17.3/setup.cfg0000644000000000000000000000017711702550506015120 0ustar [build_i18n] domain=screen-resolution-extra xml_files=[ ('share/polkit-1/actions', ['screenresolution-mechanism.policy.in'])] screen-resolution-extra-0.17.3/setup.py0000755000000000000000000000325412300644642015013 0ustar #!/usr/bin/python from distutils.core import setup import subprocess, glob, os.path from DistUtilsExtra.command import * #mo_files = [] ## HACK: make sure that the mo files are generated and up-to-date #subprocess.call(["make", "-C", "po", "build-mo"]) #for filepath in glob.glob("po/mo/*/LC_MESSAGES/*.mo"): # lang = filepath[len("po/mo/"):] # targetpath = os.path.dirname(os.path.join("share/locale",lang)) # mo_files.append((targetpath, [filepath])) setup( name="screen-resolution-extra", author="Alberto Milone", author_email="albertomilone@alice.it", maintainer="Alberto Milone", maintainer_email="albertomilone@alice.it", url="http://www.albertomilone.com", license="gpl", description="Extension for the GNOME Screen Resolution applet", packages=["ScreenResolution"], data_files=[ ("/etc/dbus-1/system.d", glob.glob("com.ubuntu.ScreenResolution.Mechanism.conf")), ("share/dbus-1/system-services", glob.glob("com.ubuntu.ScreenResolution.Mechanism.service")), ("share/polkit-1/actions", glob.glob("screenresolution-mechanism.policy")), ("share/screen-resolution-extra", glob.glob("screenresolution-mechanism")), ("share/screen-resolution-extra", glob.glob("policyui.py")), ("share/screen-resolution-extra", glob.glob("nvidia-polkit.py")), ("share/screen-resolution-extra", glob.glob("nvidia-prime.py")), ], cmdclass = { "build" : build_extra.build_extra, "build_i18n" : build_i18n.build_i18n, "build_help" : build_help.build_help, "build_icons" : build_icons.build_icons } ) screen-resolution-extra-0.17.3/usr/0000755000000000000000000000000011326015443014101 5ustar screen-resolution-extra-0.17.3/usr/share/0000755000000000000000000000000011326015443015203 5ustar screen-resolution-extra-0.17.3/usr/share/screen-resolution-extra/0000755000000000000000000000000011326016364022007 5ustar