diff --git a/docs/README.md b/docs/README.md index 834c28f..619a774 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,7 @@ # SYNOPSIS -powerkit *`[--config]`* +powerkit *`[--config]`* *`[--set-brightness-up]`* *`[--set-brightness-down]`* # DESCRIPTION @@ -49,6 +49,14 @@ You can override the lock command with *``screensaver_lock_cmd=``* in * The current display brightness (on laptops and supported displays) can be adjusted with the mouse wheel on the system tray icon or through the system tray menu. +powerkit also supports the following commands that can be used for global shortcuts, scripts etc: + +*`powerkit --set-brightness-up`* +: Set default display brightness up. + +*`powerkit --set-brightness-down`* +: Set default display brightness down. + ## HIBERNATE If hibernate works depends on your system, a swap partition (or file) is needed by the kernel to support hibernate. @@ -140,6 +148,12 @@ cpack -G RPM *``--config``* : Launch configuration. +*`--set-brightness-up`* +: Set default display brightness up. + +*`--set-brightness-down`* +: Set default display brightness down. + # FILES *``~/.config/powerkit/powerkit.conf``* diff --git a/docs/build.sh b/docs/build.sh index 4c380f4..4ac0e5b 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -1,11 +1,18 @@ #!/bin/sh +CWD=`pwd` + +if [ ! -f "${CWD}/CMakeLists.txt" ]; then + echo "Run this script from the powerkit root directory" + exit 1 +fi + PANDOC=${PANDOC:-pandoc} MONTH=`echo $(LANG=en_us_88591; date "+%B")` YEAR=`echo $(LANG=en_us_88591; date "+%Y")` -VERSION=`cat CMakeLists.txt | sed '/powerkit VERSION/!d;s/)//' | awk '{print $3}'` -echo "% POWERKIT(1) Version ${VERSION} | PowerKit Documentation" > tmp.md -echo "% Ole-André Rodlie" >> tmp.md -echo "% ${MONTH} ${YEAR}" >> tmp.md -cat docs/README.md >> tmp.md -$PANDOC tmp.md -s -t man > docs/powerkit.1 -rm tmp.md +VERSION=`cat ${CWD}/CMakeLists.txt | sed '/powerkit VERSION/!d;s/)//' | awk '{print $3}'` +echo "% POWERKIT(1) Version ${VERSION} | PowerKit Documentation" > ${CWD}/tmp.md +echo "% Ole-André Rodlie" >> ${CWD}/tmp.md +echo "% ${MONTH} ${YEAR}" >> ${CWD}/tmp.md +cat ${CWD}/docs/README.md >> ${CWD}/tmp.md +${PANDOC} ${CWD}/tmp.md -s -t man > ${CWD}/docs/powerkit.1 +rm ${CWD}/tmp.md diff --git a/docs/powerkit.1 b/docs/powerkit.1 index 9fac518..a9fef78 100644 --- a/docs/powerkit.1 +++ b/docs/powerkit.1 @@ -5,6 +5,8 @@ \f[I]powerkit\f[R] - Desktop independent Linux power manager .SH SYNOPSIS powerkit \f[I]\f[CI][--config]\f[I]\f[R] +\f[I]\f[CI][--set-brightness-up]\f[I]\f[R] +\f[I]\f[CI][--set-brightness-down]\f[I]\f[R] .SH DESCRIPTION Desktop independent Linux power manager for alternative X11 desktop environments and window managers. @@ -70,6 +72,15 @@ Note that the command must not contain spaces. The current display brightness (on laptops and supported displays) can be adjusted with the mouse wheel on the system tray icon or through the system tray menu. +.PP +powerkit also supports the following commands that can be used for +global shortcuts, scripts etc: +.TP +\f[I]\f[CI]powerkit --set-brightness-up\f[I]\f[R] +Set default display brightness up. +.TP +\f[I]\f[CI]powerkit --set-brightness-down\f[I]\f[R] +Set default display brightness down. .SS HIBERNATE If hibernate works depends on your system, a swap partition (or file) is needed by the kernel to support hibernate. @@ -183,6 +194,12 @@ Major code changes .TP \f[I]\f[CI]--config\f[I]\f[R] Launch configuration. +.TP +\f[I]\f[CI]--set-brightness-up\f[I]\f[R] +Set default display brightness up. +.TP +\f[I]\f[CI]--set-brightness-down\f[I]\f[R] +Set default display brightness down. .SH FILES .TP \f[I]\f[CI]\[ti]/.config/powerkit/powerkit.conf\f[I]\f[R] diff --git a/src/powerkit.cpp b/src/powerkit.cpp index 13c652d..cdfec17 100644 --- a/src/powerkit.cpp +++ b/src/powerkit.cpp @@ -11,6 +11,10 @@ #include "powerkit_app.h" #include "powerkit_dialog.h" #include "powerkit_common.h" +#include "powerkit_backlight.h" + +#define CMD_OPT_BRIGHTNESS_UP "--set-brightness-up" +#define CMD_OPT_BRIGHTNESS_DOWN "--set-brightness-down" int main(int argc, char *argv[]) { @@ -24,6 +28,12 @@ int main(int argc, char *argv[]) PowerKit::Dialog dialog; dialog.show(); return a.exec(); + } else if (args.contains(CMD_OPT_BRIGHTNESS_UP) || + args.contains(CMD_OPT_BRIGHTNESS_DOWN)) { + int val = PowerKit::Backlight::getCurrentBrightness(); + if (args.contains(CMD_OPT_BRIGHTNESS_UP)) { val += BACKLIGHT_MOVE_VALUE; } + else if (args.contains(CMD_OPT_BRIGHTNESS_DOWN)) { val -= BACKLIGHT_MOVE_VALUE; } + return PowerKit::Backlight::setBrightness(val); } QDBusInterface session(POWERKIT_SERVICE,