Skip to content

Commit

Permalink
Merge branch 'lmt-upstream' into qatest
Browse files Browse the repository at this point in the history
* lmt-upstream: (41 commits)
  Extend blacklist by device types of devtype
  send echo errors to verbose log
  Add module invocation example
  runtime-pm: Make {black,white}lists work with non-USB devices
  tiny typo
  tolerate broken device interfaces quietly
  fix bash syntax
  Fix typo
  Prefer to use the new runtime pm autosuspend_delay_ms interface
  Control all available cards in radeon-dpm
  Install new SVG pixmap
  - added icon - added icon path to .desktop file
  We still need policy for the main gui script
  Call the correct pkexec script
  Update installer to includes gui wrappers
  Add desktop file to upstream repo and invoke script
  Add pkexec invocation script
  Add btrfs to list of filesystems for which we can set commit interval
  Invoke with py3 in calling script
  Fix indentation error
  ...
  • Loading branch information
rickysarraf committed Jan 18, 2018
2 parents 66a74e0 + 9c93667 commit 7cffeb7
Show file tree
Hide file tree
Showing 22 changed files with 256 additions and 107 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -20,7 +20,7 @@ This will install laptop mode, which will be enabled automatically
when your laptop works on batteries.

Debian users, please install the Debian package that can
be found on the home page and in the unstable repository!
be found in the Debian Package repository at <https://packages.debian.org/search?keywords=laptop-mode-tools>


Notes
Expand All @@ -45,4 +45,4 @@ GUI Configuration Tool
References
----------

The laptop mode tools website: <http://rickysarraf.github.io/laptop-mode-tools/>
The laptop mode tools website: <https://github.com/rickysarraf/laptop-mode-tools/wiki>
2 changes: 1 addition & 1 deletion etc/laptop-mode/conf.d/battery-level-polling.conf
Expand Up @@ -23,6 +23,6 @@ DEBUG=0
#
CONTROL_BATTERY_LEVEL_POLLING=0

# Blacklist this module's exectuion in flock
# Blacklist this module's execution in flock
# This is a workaround to ensure that batter-polling-daemon does not acquire the lock
BLACKLIST_IN_FLOCK=1
2 changes: 1 addition & 1 deletion etc/laptop-mode/conf.d/intel-sata-powermgmt.conf
Expand Up @@ -11,7 +11,7 @@
#
#__COMMENT If you enable this setting, laptop mode tools will automatically enable the
#__COMMENT link power management mode of Intel AHCI compliant SATA chipsets.
#__COMMENT On newner kernels (4.6+), it can also help enabled AHCI Runtime PM savings
#__COMMENT On newer kernels (4.6+), it can also help enable AHCI Runtime PM savings
#
###############################################################################

Expand Down
13 changes: 7 additions & 6 deletions etc/laptop-mode/conf.d/runtime-pm.conf
Expand Up @@ -36,22 +36,23 @@ AUTOSUSPEND_USE_WHITELIST=0

# The list of Device IDs that should not use autosuspend. Use system commands or
# look into sysfs to find out the IDs of your devices.
# Example: AUTOSUSPEND_DEVID_BLACKLIST="046d:c025 0123:abcd"
# Example: AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST="046d:c025 0123:abcd"
AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST=""

# The list of device driver types that should not use autosuspend. The driver
# type is given by "DRIVER=..." in a device's uevent file.
# Example: AUTOSUSPEND_DEVID_BLACKLIST="usbhid usb-storage"
# The list of 'device driver types' or 'device types' that should not use autosuspend.
# The driver type is given by "DRIVER=..." in a device's uevent file.
# The driver type is given by "DEVTYPE=..." in a device's uevent file.
# Example: AUTOSUSPEND_RUNTIME_DEVTYPE_BLACKLIST="usbhid usb-storage"
AUTOSUSPEND_RUNTIME_DEVTYPE_BLACKLIST="hub usbhid usb-storage"

# The list of Device IDs that should use autosuspend. Use system commands or
# look into sysfs to find out the IDs of your devices.
# Example: AUTOSUSPEND_DEVID_WHITELIST="046d:c025 0123:abcd"
# Example: AUTOSUSPEND_RUNTIME_DEVID_WHITELIST="046d:c025 0123:abcd"
AUTOSUSPEND_RUNTIME_DEVID_WHITELIST=""

# The list of device driver types that should use autosuspend. The driver
# type is given by "DRIVER=..." in a device's uevent file.
# Example: AUTOSUSPEND_DEVTYPE_WHITELIST="usbhid usb-storage"
# Example: AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST="usbhid usb-storage"
AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST=""

# Trigger auto-suspension of the deivce under conditional circumstances
Expand Down
2 changes: 1 addition & 1 deletion etc/laptop-mode/laptop-mode.conf
Expand Up @@ -11,7 +11,7 @@
# active
# AC_something=value Value of "something" when the computer is running
# on AC power
# BATT_something=value Value of "something when the computer is running
# BATT_something=value Value of "something" when the computer is running
# on battery power
#
# There can be combinations of LM_/NOLM_ and AC_/BATT_ prefixes, but the
Expand Down
3 changes: 3 additions & 0 deletions etc/rules/99-laptop-mode.rules
@@ -1,3 +1,6 @@
ACTION=="change", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="|AC|ACAD", RUN+="lmt-udev auto"
ACTION=="add|remove", SUBSYSTEM=="machinecheck", RUN+="lmt-udev auto"
ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force"

# Run a particular module only
#ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force modules=runtime-pm devices=%k"
21 changes: 6 additions & 15 deletions gui/LMT.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


Expand All @@ -11,20 +11,11 @@
from shutil import move
from webbrowser import open_new_tab

try:
from PyQt4.QtGui import (QWidget, QMessageBox, QVBoxLayout, QHBoxLayout,
QGroupBox, QScrollArea, QCheckBox, QPushButton,
QApplication, QMainWindow, QIcon, QDialogButtonBox,
QColor, QGraphicsDropShadowEffect, QShortcut)
print("Using PyQt4")
except ImportError:
from PySide.QtGui import (QWidget, QMessageBox, QVBoxLayout, QHBoxLayout,
QGroupBox, QScrollArea, QCheckBox, QPushButton,
QApplication, QMainWindow, QIcon, QShortcut,
QDialogButtonBox, QColor,
QGraphicsDropShadowEffect)
print("Using PySide")

from PyQt5.QtWidgets import (QWidget, QMessageBox, QVBoxLayout, QHBoxLayout,
QGroupBox, QScrollArea, QCheckBox, QPushButton,
QApplication, QMainWindow, QDialogButtonBox,
QGraphicsDropShadowEffect, QShortcut)
from PyQt5.QtGui import (QIcon, QColor)


# This seems to be needed, atleast of Debian
Expand Down
9 changes: 9 additions & 0 deletions gui/laptop-mode-tools.desktop
@@ -0,0 +1,9 @@
[Desktop Entry]
Type=Application
Name=Laptop Mode Tools Configuration
GenericName=Laptop Mode Tools Configuration
Icon=laptop-mode-tools
Exec=/usr/sbin/lmt-config-gui-pkexec
Categories=System;
Comment=Enable/disable Laptop Mode Tools settings
Keywords=Preferences;
91 changes: 91 additions & 0 deletions gui/laptop-mode-tools.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gui/lmt-config-gui
Expand Up @@ -3,4 +3,4 @@
# Needed for annoying QT MIT bug
export QT_X11_NO_MITSHM=1

python2 /usr/share/laptop-mode-tools/lmt.py
python3 /usr/share/laptop-mode-tools/lmt.py
8 changes: 8 additions & 0 deletions gui/lmt-config-gui-pkexec
@@ -0,0 +1,8 @@
#!/bin/sh

PKEXEC=`which pkexec`;

if [ -x $PKEXEC ]; then
echo "Exec with pkexec"
$PKEXEC /usr/sbin/lmt-config-gui
fi
21 changes: 21 additions & 0 deletions install.sh
Expand Up @@ -119,6 +119,8 @@ $INSTALL -d -m 755 "$DESTDIR/usr/share/laptop-mode-tools/module-helpers"
$INSTALL -d -m 755 "$DESTDIR/etc/laptop-mode/conf.d"
$INSTALL -d -m 755 "$DESTDIR/etc/laptop-mode/modules"
$INSTALL -d -m 755 "$DESTDIR/usr/share/polkit-1/actions"
$INSTALL -d -m 755 "$DESTDIR/usr/share/applications"
$INSTALL -d -m 755 "$DESTDIR/usr/share/pixmaps"
$INSTALL -d -m 755 "$DESTDIR/usr/sbin"
$INSTALL -d -m 755 "$DESTDIR/$UDEV_D/rules.d"
$INSTALL -d -m 755 "$DESTDIR/$MAN_D/man8"
Expand Down Expand Up @@ -192,6 +194,25 @@ if ( ! $INSTALL -m 744 man/* "$DESTDIR/$MAN_D/man8" ) ; then
exit 23
fi

if ( ! $INSTALL -m 644 gui/laptop-mode-tools.desktop "$DESTDIR/usr/share/applications" ) ; then
echo "$0: Failed to install $DESTDIR/usr/share/applications/laptop-mode-tools.desktop"
exit 11
fi

if ( ! $INSTALL -m 755 gui/lmt-config-gui* "$DESTDIR/usr/sbin" ) ; then
echo "$0: Failed to install $DESTDIR/usr/sbin/lmt-config-gui*"
exit 11
fi

if ( ! $INSTALL -m 644 gui/laptop-mode-tools.svg "$DESTDIR/usr/share/pixmaps" ) ; then
echo "$0: Failed to install $DESTDIR/usr/share/pixmaps/laptop-mode-tools.svg";
exit 11
fi

if ( ! $INSTALL -m 644 gui/LMT.py "$DESTDIR/usr/share/laptop-mode-tools" ) ; then
echo "$0: Failed to install $DESTDIR/usr/share/laptop-mode-tools/lmt.py";
exit 11
fi

# Install pm-utils hook only if pm-utils config dir is present, or force the
# install if we have a DESTDIR.
Expand Down
2 changes: 1 addition & 1 deletion man/laptop-mode.conf.8
Expand Up @@ -480,7 +480,7 @@ to "/dev/null".


.IP "\fBCONTROL_VGASWITCHEROO\fP" 10
When this option is enabled, laptop mode will use the vgaswitcheroo inteface
When this option is enabled, laptop mode will use the vgaswitcheroo interface
to disable the unused hybrid graphics card.
For this module to work, you need to ensure you have debugfs enabled/mounted

Expand Down
14 changes: 6 additions & 8 deletions usr/sbin/laptop_mode
Expand Up @@ -451,12 +451,12 @@ lmt_load_config ()
# Determine the power state.

# First try /sys/class/power_supply/*
FOUND_SYS_CLASS_POWER_SUPPLY_AC=0
SYSFS_POWER_SUPPLY=0
export ON_AC=0
BATTERY_NOT_DISCHARGING=0
for POWER_SUPPLY in /sys/class/power_supply/* ; do
if [ -f $POWER_SUPPLY/type ] ; then
FOUND_SYS_CLASS_POWER_SUPPLY_AC=1
SYSFS_POWER_SUPPLY=1
if [ "$(cat $POWER_SUPPLY/type)" = "Mains" ]; then
log "VERBOSE" "Determining power state from $POWER_SUPPLY/online."
if [ "$(cat $POWER_SUPPLY/online)" = 1 ]; then
Expand Down Expand Up @@ -484,14 +484,12 @@ lmt_load_config ()
fi
done

if [ $FOUND_SYS_CLASS_POWER_SUPPLY_AC != 1 ] && [ $BATTERY_NOT_DISCHARGING = 1 ]; then
log "VERBOSE" "Marking it as online ON_AC because we found no AC and the battery is not discharging"
ON_AC=1
fi

if [ $FOUND_SYS_CLASS_POWER_SUPPLY_AC = 1 ] ; then
if [ $SYSFS_POWER_SUPPLY = 1 ] ; then
# Already found it!
log "VERBOSE" "Not trying other options, already found a power supply."
elif [ $BATTERY_NOT_DISCHARGING = 1 ]; then
log "VERBOSE" "Marking it as online ON_AC because we found no AC and the battery is not discharging"
ON_AC=1
elif [ -d /proc/acpi/ac_adapter ] ; then
log "VERBOSE" "Determining power state from /proc/acpi/ac_adapter."
ADAPTERS_FOUND=0
Expand Down
8 changes: 7 additions & 1 deletion usr/share/laptop-mode-tools/modules/dpms-standby
Expand Up @@ -17,7 +17,13 @@ getXuser() {
export XAUTHORITY=""
if [ x"$user" != x"" ]; then
xauthdir=`getent passwd $user | cut -d: -f6`
if [ -f "$xauthdir/.Xauthority" ]; then
xauthuser=`getent passwd $user | cut -d: -f1`
xauthuserid=`getent passwd $user | cut -d: -f3`

if [ -f /run/user/$xauthuserid/*/Xauthority ]; then
export XAUTHORITY=/run/user/$xauthuserid/*/Xauthority
log "VERBOSE" "XAUTHORITY path is: $XAUTHORITY"
elif [ -f "$xauthdir/.Xauthority" ]; then
export XAUTHORITY=$xauthdir/.Xauthority
fi
else
Expand Down
25 changes: 16 additions & 9 deletions usr/share/laptop-mode-tools/modules/hdparm
Expand Up @@ -238,21 +238,21 @@ if [ x$CONTROL_HD_IDLE_TIMEOUT = x1 ] ; then
log "VERBOSE" "(hdparm configuration value = $HD_IDLE_TIMEOUT.)"
for THISHD in $HD ; do
if is_capable $THISHD IDLE_TIMEOUT ; then
if is_capable $THISHD HDPARM ; then
if [ "$HDPARM_AVAILABLE" = "1" ]; then
log "VERBOSE" "Executing: hdparm -S $HD_IDLE_TIMEOUT $THISHD"
log "VERBOSE" "`hdparm -S $HD_IDLE_TIMEOUT $THISHD 2>&1`"
else
log "VERBOSE" "ERROR: hdparm not installed."
fi
elif is_capable $THISHD SDPARM ; then
if is_capable $THISHD SDPARM ; then
if [ "$SDPARM_AVAILABLE" = "1" ]; then
HD_IDLE_TIMEOUT_DECISECONDS=$(($HD_IDLE_TIMEOUT_SECONDS*10))
log "VERBOSE" "Executing: sdparm -q -s SCT=$HD_IDLE_TIMEOUT_DECISECONDS $THISHD"
log "VERBOSE" "`sdparm -q -s SCT=$HD_IDLE_TIMEOUT_DECISECONDS $THISHD 2>&1`"
else
log "ERR" "ERROR: sdparm not installed."
fi
elif is_capable $THISHD HDPARM ; then
if [ "$HDPARM_AVAILABLE" = "1" ]; then
log "VERBOSE" "Executing: hdparm -S $HD_IDLE_TIMEOUT $THISHD"
log "VERBOSE" "`hdparm -S $HD_IDLE_TIMEOUT $THISHD 2>&1`"
else
log "VERBOSE" "ERROR: hdparm not installed."
fi
else
log "VERBOSE" "Skipping $THISHD: drive supports neither hdparm nor sdparm."
fi
Expand Down Expand Up @@ -282,7 +282,14 @@ if [ x$CONTROL_HD_WRITECACHE = x1 ] ; then
log "VERBOSE" "Setting write cache on drives to $HD_WRITECACHE."
for THISHD in $HD ; do
if is_capable $THISHD WRITECACHE ; then
if is_capable $THISHD HDPARM ; then
if is_capable $THISHD SDPARM ; then
if [ "$SDPARM_AVAILABLE" = "1" ]; then
log "VERBOSE" "Executing: sdparm Write Cache $HD_WRITECACHE $THISHD"
log "VERBOSE" "`sdparm --set WCE=$HD_WRITECACHE $THISHD 2>&1`"
else
log "ERR" "ERROR: sdparm not installed."
fi
elif is_capable $THISHD HDPARM ; then
if [ "$HDPARM_AVAILABLE" = "1" ]; then
log "VERBOSE" "Executing: hdparm -W $HD_WRITECACHE $THISHD"
log "VERBOSE" "`hdparm -W $HD_WRITECACHE $THISHD 2>&1`"
Expand Down
6 changes: 3 additions & 3 deletions usr/share/laptop-mode-tools/modules/laptop-mode
Expand Up @@ -133,7 +133,7 @@ control_mount_options() {
MP="$(echo $MP)"

case "$FST" in
ext*|reiserfs|xfs)
ext*|reiserfs|xfs|btrfs)
log "VERBOSE" "$FST mount options apply"
;;
*)
Expand Down Expand Up @@ -225,7 +225,7 @@ control_mount_options() {
SAVED_OPTS=${SAVED_OPTS#* } # trim device name

case "$FST" in
"ext3"|"reiserfs"|"ext4dev"|"ext4")
"ext3"|"reiserfs"|"ext4dev"|"ext4"|"btrfs")
PARSEDOPTS="$(replace_numeric_mount_option commit commit=0 $SAVED_OPTS $OPTS)"
PARSEDOPTS="$(replace_atime_mount_option $SAVED_OPTS $PARSEDOPTS)"
log "VERBOSE" "Executing: mount $DEV $MP -t $FST -o remount,$PARSEDOPTS"
Expand Down Expand Up @@ -271,7 +271,7 @@ control_mount_options() {
FST=${FST%%,*}

case "$FST" in
"ext3"|"reiserfs"|"ext4dev"|"ext4")
"ext3"|"reiserfs"|"ext4dev"|"ext4"|"btrfs")
log "VERBOSE" "Removing commit mount option from original options."
PARSEDOPTS="$(remove_numeric_mount_option commit "$OPTS")"
log "VERBOSE" "Executing: mount $DEV $MP -t $FST -o remount,$PARSEDOPTS,commit=$MAX_LOST_WORK_SECONDS$NOATIME_OPT"
Expand Down

0 comments on commit 7cffeb7

Please sign in to comment.