Skip to content

Commit

Permalink
Support new console options
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Feb 8, 2024
1 parent a80352d commit cc2293c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
16 changes: 15 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# SYNOPSIS

powerkit *`[--config]`*
powerkit *`[--config]`* *`[--set-brightness-up]`* *`[--set-brightness-down]`*

# DESCRIPTION

Expand Down Expand Up @@ -49,6 +49,14 @@ You can override the lock command with *``screensaver_lock_cmd=<command>``* 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.
Expand Down Expand Up @@ -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``*
Expand Down
21 changes: 14 additions & 7 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions docs/powerkit.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions src/powerkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[])
{
Expand All @@ -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,
Expand Down

0 comments on commit cc2293c

Please sign in to comment.