diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch) | |
tree | 8d927b7b47a90c4adb646482a52613f58acd6f8c /kmilo/asus | |
download | tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmilo/asus')
-rw-r--r-- | kmilo/asus/Makefile.am | 37 | ||||
-rw-r--r-- | kmilo/asus/README | 43 | ||||
-rw-r--r-- | kmilo/asus/asus.cpp | 213 | ||||
-rw-r--r-- | kmilo/asus/asus.h | 88 | ||||
-rw-r--r-- | kmilo/asus/kmilo_asus.desktop | 97 |
5 files changed, 478 insertions, 0 deletions
diff --git a/kmilo/asus/Makefile.am b/kmilo/asus/Makefile.am new file mode 100644 index 0000000..39217c0 --- /dev/null +++ b/kmilo/asus/Makefile.am @@ -0,0 +1,37 @@ +# This file is part of the KDE project +# Copyright (C) 2003 George Staikos <staikos@kde.org> +# Copyright (C) 2004 Chris Howells <howells@kde.org> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. + +# This library 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public License +# along with this library; see the file COPYING.LIB. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +#SUBDIRS = . kcmthinkpad + +INCLUDES=-I$(srcdir)/../kmilod $(all_includes) + +kde_module_LTLIBRARIES = kmilo_asus.la + +kmilo_asus_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +kmilo_asus_la_LIBADD = ../kmilod/libkmilo.la $(LIB_KIO) +kmilo_asus_la_SOURCES = asus.cpp +METASOURCES = AUTO + +noinst_HEADERS = asus.h + +services_DATA = kmilo_asus.desktop +servicesdir = $(kde_servicesdir)/kmilo + +messages: + $(XGETTEXT) $(asus_thinkpad_la_SOURCES) -o $(podir)/kmilo_asus.pot diff --git a/kmilo/asus/README b/kmilo/asus/README new file mode 100644 index 0000000..b375940 --- /dev/null +++ b/kmilo/asus/README @@ -0,0 +1,43 @@ +Asus Laptop plugin for KMilo + +Chris Howells <howells@kde.org> + +About +----- + +This KMilo module, in conjunction with the Asus asus_acpi Linux kernel +module, allows some of the special keys on the keyboard of an Asus laptop to +be fully utilised. + +The asus_acpi kernel modules exports a control and monitoring interface +using the Linux kernel's /proc psuedo file system. + +The /proc file system +--------------------- + +/proc/acpi/asus/brn - Sets/gets the brightness of the LCD backlight +Values between 0 (most dim) and 15 (most bright) + +/proc/acpi/asus/info - Shows information about the laptop + +/proc/acpi/asus/lcd - Sets/gets whether the LCD is on or off +Values of 0 or 1 + +/proc/acpi/asus/disp - Sets/gets whether the LCD/VGA/TV out is used +Values of +0 - no display +1 - LCD only +2 - CRT only +3 - LCD + CRT +4 - TV out only +5 - LCD + TV out +6 - CRT + TV out +7 - LCD + CRT + TV out + +Changes +------- + +Todo +---- +* Support lcd and disp stuff +* Maybe support volume stuff diff --git a/kmilo/asus/asus.cpp b/kmilo/asus/asus.cpp new file mode 100644 index 0000000..e1fbfa0 --- /dev/null +++ b/kmilo/asus/asus.cpp @@ -0,0 +1,213 @@ +/* + This file is part of the KDE project + + Copyright (c) 2004 Chris Howells <howells@kde.org> + Much code and ideas stolen from Jonathan Riddell's ThinkPad plugin + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; version + 2 of the License. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include <kgenericfactory.h> +#include <kconfig.h> +#include <krun.h> +#include <kurl.h> + +#include <qfile.h> +#include <qdir.h> + +#include "kmilointerface.h" + +#include "asus.h" + +#ifdef Q_OS_FREEBSD +#include <sys/types.h> +#include <sys/sysctl.h> +#endif + +#define ROUND(x) (int(x + 0.5)) + +namespace KMilo { + +AsusMonitor::AsusMonitor(QObject* parent, const char* name, const QStringList& args): Monitor(parent, name, args) +{ +} + +AsusMonitor::~AsusMonitor() +{ +} + +bool AsusMonitor::init() +{ + kdDebug() << "loading asus kmilo plugin" << endl; + +#ifdef Q_OS_FREEBSD + /* + * Check if the sysctls are in place by looking up their MIBs. + * Caching the MIBs results in a major speedup. + */ + size_t len = 4; + if ( sysctlnametomib("hw.acpi.asus.lcd_brightness", brightness_mib, &len) == -1 || + sysctlnametomib("hw.acpi.asus.lcd_backlight", backlight_mib, &len) == -1 || + sysctlnametomib("hw.acpi.asus.video_output", video_mib, &len) == -1 ) + { + kdDebug() << "The driver's sysctls don't seem to exist, check that the acpi_asus module is loaded" << endl; + return false; + } +#else + // we need to read the /proc file system and store the current values into a struct + QDir dir("/proc/acpi/asus"); + if (!dir.exists()) + { + kdDebug() << "/proc/acpi/asus doesn't exist, check that the asus_acpi module is loaded" << endl; + return false; + } +#endif + else + { + clearStruct(asus_state); + clearStruct(last_asus_state); + if (!readProc(&asus_state)) + { + return false; + } + } + + return true; +} + +Monitor::DisplayType AsusMonitor::poll() +{ + + // save last state and get new one + memcpy(&last_asus_state, &asus_state, sizeof(asus_state_struct)); + readProc(&asus_state); + + Monitor::DisplayType pollResult = None; + + if (last_asus_state.brightness != asus_state.brightness) + { + pollResult = Brightness; + float value = (float)asus_state.brightness / 15; + m_progress = ROUND(value * 100); + } + + /*if (last_asus_state.lcd != asus_state.lcd) + { + if (asus_state.lcd == 0) + { + _interface->displayText(i18n("Display changed: LCD off")); + } + else + { + _interface->displayText(i18n("Display changed: LCD on")); + } + }*/ + + if (last_asus_state.display != asus_state.display) + { + switch (asus_state.display) + { + case 0: + _interface->displayText(i18n("Display changed: off")); + break; + case 1: + _interface->displayText(i18n("Display changed: LCD on")); + break; + case 2: + _interface->displayText(i18n("Display changed: CRT on")); + break; + case 3: + _interface->displayText(i18n("Display changed: LCD and CRT on")); + break; + case 4: + _interface->displayText(i18n("Display changed: TV out on")); + break; + case 5: + _interface->displayText(i18n("Display changed: LCD and TV out on")); + break; + case 6: + _interface->displayText(i18n("Display changed: CRT and TV out on")); + break; + case 7: + _interface->displayText(i18n("Display changed: LCD, CRT and TV out on")); + break; + } + } + + return pollResult; +} + + +int AsusMonitor::progress() const +{ + return m_progress; +} + +bool AsusMonitor::readProc(asus_state_struct* asus_state) +{ +#ifdef Q_OS_FREEBSD + int value; + size_t value_len = sizeof(value); + + if ( sysctl(brightness_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->brightness = value; + + if ( sysctl(backlight_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->lcd = value; + + if ( sysctl(video_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->display = value; +#else + asus_state->brightness = readProcEntry(QString("brn")); + //asus_state->lcd = readProcEntry(QString("lcd")); + //disabled because it does not yet work on my S5200N (asus_acpi bug) + //asus_state->display = readProcEntry(QString("disp")); + //FIXME +#endif + return true; +} + +int AsusMonitor::readProcEntry(const QString &name) +{ + QFile f(QString("/proc/acpi/asus/%1").arg(name).local8Bit()); + + if (f.open(IO_ReadOnly)) + { + QString line; + if (f.readLine(line, 1024) > 0) + { + line = line.stripWhiteSpace(); + int value = line.section(' ', 0, 0).toInt(); + if (value > 0) + { + return value; + } + } + } + return 0; +} + +void AsusMonitor::clearStruct(asus_state_struct& asus_state) +{ + asus_state.brightness = 0; + asus_state.lcd = 0; + asus_state.display = 0; +} + +} + +K_EXPORT_COMPONENT_FACTORY(kmilo_asus, KGenericFactory<KMilo::AsusMonitor>("kmilo_asus")) diff --git a/kmilo/asus/asus.h b/kmilo/asus/asus.h new file mode 100644 index 0000000..90361d8 --- /dev/null +++ b/kmilo/asus/asus.h @@ -0,0 +1,88 @@ +/* + This file is part of the KDE project + + Copyright (c) 2004 Chris Howells <howells@kde.org> + Much code and ideas stolen from Jonathan Riddell's ThinkPad plugin + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; version + 2 of the License. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ +#ifndef ASUS_H +#define ASUS_H + +#include <kapplication.h> +#include <dcopref.h> + +#include "monitor.h" + +namespace KMilo { + +typedef struct +{ + unsigned int brightness; + unsigned int lcd; + unsigned int display; +} asus_state_struct; + +/** + * KMilo plugin for Asus Laptops + */ +class AsusMonitor: public Monitor { + public: + AsusMonitor(QObject *parent, const char *name, const QStringList&); + virtual ~AsusMonitor(); + + /** + * Reimplemented from KMilo::Monitor. + * Loads configuration. + */ + virtual bool init(); + + /** + * Reimplemented from KMilo::Monitor. + * Called by KMilo, this checks the /proc file system and acts on any changes + */ + virtual DisplayType poll(); + + /** + * Reimplemented from KMilo::Monitor. + * Called by KMilo if poll() returns a brightness change. + * Returns the new brightness percentage. + */ + virtual int progress() const; + + private: + + int m_progress; + + asus_state_struct last_asus_state; + asus_state_struct asus_state; + + bool readProc(asus_state_struct* ); + int readProcEntry(const QString &); + + void clearStruct(asus_state_struct& asus_state); + +#ifdef Q_OS_FREEBSD + int brightness_mib[4]; + int backlight_mib[4]; + int video_mib[4]; +#endif +}; + +} // close namespace + +#endif diff --git a/kmilo/asus/kmilo_asus.desktop b/kmilo/asus/kmilo_asus.desktop new file mode 100644 index 0000000..5e662bb --- /dev/null +++ b/kmilo/asus/kmilo_asus.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KMilo Plugin +X-KDE-ModuleType=Plugin +Name=Asus Laptop Plugin +Name[ar]=ملحق حاسوب Asus المحمول +Name[br]=Lugent hezoug Asus +Name[bs]=Dodatak za Asus laptope +Name[ca]=Connector per portàtils Asus +Name[cs]=Asus Laptop modul +Name[da]=Asus bærbar plugin +Name[de]=Asus Notebook-Plugin +Name[el]=Πρόσθετο Sony Vaio +Name[es]=Extensión para el portátil Asus +Name[et]=Asuse sülearvuti plugin +Name[eu]=Asus Laptop plugina +Name[fa]=وصلۀ رایانۀ کیفی Asus +Name[fi]=Asus-kannettavan liitännäinen +Name[fr]=Module externe pour les portables Asus +Name[ga]=Breiseán Ríomhaire Glúine Asus +Name[he]=תוסף למחשבי ברכיים בעלי ASUS +Name[hu]=ASUS modul +Name[is]=Asus ferðatölvuíforrit +Name[it]=Plugin per portatili Asus +Name[ja]=Asus ラップトップ プラグイン +Name[ka]=Asus-ის ლეპტოპის მოდული +Name[kk]=Asus ноутбуктің модулі +Name[km]=កម្មវិធីជំនួយកុំព្យូទ័រយួរដៃ Asus +Name[lt]=Asus Laptop priedas +Name[nb]=Asus Laptop tillegg +Name[nds]=Asus-Klappreeknermoduul +Name[ne]=एसस ल्यापटप प्लगइन +Name[nl]=Asus Laptop-plugin +Name[nn]=Programtillegg for Asus-bærbare +Name[pa]=Asus ਲੈਪਟਾਪ ਪਲੱਗਿੰਨ +Name[pl]=Wtyczka laptopa Asus +Name[pt]='Plugin' para Portáteis Asus +Name[pt_BR]=Plugin para Laptops Asus +Name[ru]=Ноутбук Asus +Name[sk]=Modul pre Asus laptop +Name[sl]=Vstavek za prenosnik Asus +Name[sr]=Прикључак за Asus-ове лаптопе +Name[sr@Latn]=Priključak za Asus-ove laptope +Name[sv]=Insticksprogram för Asus bärbar dator +Name[ta]=Asus மடிக்கணினி சொருகுப்பொருள் +Name[tr]=Asus Dizüstü Bilgisayar Eklentisi +Name[uk]=Втулок лептопа Asus +Name[uz]=Asus laptopi uchun plagin +Name[uz@cyrillic]=Asus лаптопи учун плагин +Name[zh_CN]=华硕笔记本插件 +Name[zh_TW]=華碩筆記型電腦外掛程式 +Comment=Enables support for special Asus laptop keys +Comment[ar]=تمكّن الدعم لمفاتيح حاسوب Asus المحمول الخاصة +Comment[bg]=Тази приставка позволява поддръжката на специалните клавиши на Asus +Comment[bs]=Omogućuje podršku za posebne tipke na Asus laptopima +Comment[ca]=Habilita el funcionament per a tecles especials dels portàtils Asus +Comment[cs]=Umožňuje podporu speciálních kláves laptopů Asus +Comment[da]=Aktiverer støtte for specielle Asus bærbares taster +Comment[de]=Dieses Plugin aktiviert die Unterstützung für Sondertasten bei Asus-Tastaturen +Comment[el]=Ενεργοποιεί την υποστήριξη για ειδικά πλήκτρα φορητού Asus +Comment[es]=Activa el soporte de las teclas especiales del portátil Asus +Comment[et]=Võimaldab kasutada Asuse sülearvuti eriklahve +Comment[eu]=Asus eramangarrien tekla berezientzako euskarria gaitzen du +Comment[fa]=Asus فعالسازی پشتیبانی برای کلیدهای ویژۀ رایانۀ کیفی +Comment[fi]=Tämä liitännäinen mahdollistaa erikoisnäppäinten tuen Asus-merkkisille kannettaville tietokoneille. +Comment[fr]=Ce module active la gestion des touches spéciales des ordinateurs portables Asus +Comment[ga]=Tacaigh le heochracha speisialta ar ríomhairí glúine Asus +Comment[he]=מוסיף תמיכה בשביל מקשים מיוחדים של Asus +Comment[hu]=Ez a bővítőmodul lehetővé teszi az ASUS noteszgépek speciális billentyűinek használatát +Comment[is]=Virkjar stuðning fyrir sérhnappa Asus ferðavéla +Comment[it]=Abilita il supporto per i tasti speciali dei portatili Asus +Comment[ja]=Asus ラップトップの特殊キーをサポートします +Comment[ka]=რთავს Asus-ის ლეპტოპის სპეციალური კლავიშების მხარდაჭერას +Comment[kk]=Asus ноутбугінің арнаулы пернелерін қолдауы +Comment[km]=បើកការគាំទ្រគ្រាប់ចុចកុំព្យូទ័រយួរដៃ Asus ពិសេស +Comment[lt]=Įgalina specialų Asus laptop raktų palaikymą +Comment[nb]=Muliggjør støtte for spesielle taster på Asus maskiner +Comment[nds]=Maakt de Sünnertasten-Ünnerstütten för Asus-Klappreekners an +Comment[ne]=विशेष ल्यापटप कुञ्जीका लागि समर्थन सक्षम पार्दछ +Comment[nl]=Activeert de ondersteuning voor speciale Asus-laptop-toetsen +Comment[nn]=Dette programtillegget gjer det mogleg å bruka spesialtastar på Asus-bærbare +Comment[pa]=ਖਾਸ Asus ਲੈਪਟਾਪ ਸਵਿੱਚਾਂ ਲਈ ਖਾਸ ਸਹਿਯੋਗ +Comment[pl]=Włącza obsługę specjalnych klawiszy laptopa Asus +Comment[pt]=Activa o suporte a teclas especiais dos portáteis Asus +Comment[pt_BR]=Habilita suporte à teclas especiais dos laptops Asus +Comment[ru]=Этот модуль поддерживает специальные клавиши ноутбука Asus +Comment[sk]=Povoľuje podporu pre špeciálne klávesy Asus laptopu +Comment[sl]=Omogoči podporo posebnim tipkam prenosnikov Asus +Comment[sr]=Подршка за посебне тастере на Asus-овим лаптопима +Comment[sr@Latn]=Podrška za posebne tastere na Asus-ovim laptopima +Comment[sv]=Aktiverar stöd för speciella tangenter på Asus bärbar dator +Comment[ta]=விசேஷ ஆஸ்சஸ் மடிக்கணினி விசைகளுக்கான ஆதரவை செயல்படுத்துகிறது +Comment[tr]=Asus dizüstü bilgisayarlar için özel tuş desteğini etkinleştirir +Comment[uk]=Уможливлює підтримку спеціальних клавіш для лептопа Asus +Comment[zh_CN]=启用华硕笔记本的特殊按键 +Comment[zh_TW]=開啟華碩筆記型電腦特殊鍵支援 +X-KDE-Library=kmilo_asus |