Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(at': 0.04; 'everyone!': 0.07; 'modify': 0.07; 'purpose.': 0.07; 'python3': 0.07; 'collier': 0.09; 'launchpad': 0.09; 'performs': 0.09; 'systems.': 0.12; '<>.': 0.14; 'fitness': 0.14; 'useful,': 0.14; '#this': 0.16; 'url:gnu': 0.16; 'url:licenses': 0.16; 'warranty;': 0.16; 'version.': 0.19; 'foundation,': 0.20; 'later': 0.20; 'not,': 0.20; 'help.': 0.21; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'subject:Code': 0.24; 'script': 0.25; 'skip:p 30': 0.29; 'unix': 0.29; 'along': 0.30; 'received:10.0.0': 0.31; 'implied': 0.31; 'option)': 0.31; 'prints': 0.31; 'everyone': 0.33; 'skip:# 10': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'licensed': 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'even': 0.60; 'hope': 0.61; 'free': 0.61; 'details.': 0.61; 'email addr:gmail.com': 0.63; 'soon': 0.63; 'more': 0.64; 'license': 0.66; 'account.': 0.80; 'skip:/ 30': 0.84; 'subject:Laptop': 0.84; 'subject:State': 0.84; 'johnson,': 0.91; '2013.': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=XdgBCR61UtdE4ST1c4V465PAn+1bO321W7+zcImUVCo=; b=bMRyYDAtSdn8ADBe1+bzKFO4KGEiC8GhFydduiuXLnErEWxvKCKppEAhrB9JMCyv6s 4OSxW4f1+yoSt0GbMTqqIE1phbV+RjBx/imAbn6guryEYDeLc4k2pkZv3MFDTPN6AD9t TRHx7zwxrsbb1vJzr2ph6PF15ZfXdEawF49vksmwiUm0Shri2nzEMe2hpfuWkDGCCG8G CEyaEKH3wquNJhgmsNyhgoCKZcpeI2xdlRZESj4v4Tv67ZxZ3GGgeNzktNwXpOx4EE/d 4fVpsZ3Uy2vpGyeeeRt1TvXNfzRTgf+BSx39E1MDGy5DbbGpTyowdSEDwCtihnJIxloU xTGg== X-Received: by 10.236.90.79 with SMTP id d55mr10750515yhf.195.1375193188290; Tue, 30 Jul 2013 07:06:28 -0700 (PDT) Date: Tue, 30 Jul 2013 10:06:25 -0400 From: Devyn Collier Johnson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Python Mailing List Subject: Share Code: Laptop Lid State Content-Type: multipart/mixed; boundary="------------020105000508080905030108" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375199680 news.xs4all.nl 16010 [2001:888:2000:d::a6]:57054 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51572 This is a multi-part message in MIME format. --------------020105000508080905030108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Aloha everyone! I attached a script that I thought I could share with everyone for your help. This Python3 script only works on Unix systems. It prints the current state of the lid. This can be used to make a script that performs some action when the lid is closed or open. The script is licensed under LGPLv3 and I will soon upload it to my Launchpad account. Enjoy! Mahalo, DevynCJohnson@Gmail.com --------------020105000508080905030108 Content-Type: text/plain; charset=UTF-8; name="lid_state" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="lid_state" #!/usr/bin/env python3 #Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS # LGPLv3 - 2013. (Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS)© #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 3 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, see . import subprocess; print(subprocess.getoutput('cat /proc/acpi/button/lid/LID/state | awk \'{ print $2 }\'')) --------------020105000508080905030108--