diff --git a/.gitignore b/.gitignore index d56a6b60..fe4a0406 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,7 @@ autom4te.cache /compile /config.guess /config.h.in +/config.h /config.log /config.status /config.sub @@ -86,6 +87,7 @@ autom4te.cache # https://www.gnu.org/software/libtool/ /ltmain.sh +/libtool # http://www.gnu.org/software/texinfo @@ -110,9 +112,12 @@ m4/lt~obsolete.m4 /data/applications/redshift-gtk.desktop /data/systemd/redshift.service /data/systemd/redshift-gtk.service +/Makefile /m4 +/src/Makefile /src/redshift /src/redshift-gtk/defs.py +/src/redshift-gtk/Makefile /src/redshift-gtk/redshift-gtk /src/redshift-gtk/__pycache__/ @@ -130,3 +135,10 @@ m4/lt~obsolete.m4 /po/insert-header.sin /po/quot.sed /po/remove-potcdate.sin +/po/Makefile +/po/.intltool-merge-cache +/src/.deps/*.Po +/src/.deps/*.Plo + +# IntelliJ IDE folder +.idea/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c8a29e75..7d8bc356 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,37 +2,65 @@ Building from git clone ----------------------- +### 1. Execute bootstrap script ``` shell $ ./bootstrap -$ ./configure ``` - The bootstrap script will use autotools to set up the build environment and create the `configure` script. -Use `./configure --help` for options. Use `--prefix` to make an install in -your home directory. This is necessary to test python scripts. The systemd -user unit directory should be set to avoid writing to the system location. - -Systemd will look for the unit files in `~/.config/systemd/user` so this +### 2. Execute configure script + +#### Enabling adjustment methods and location providers +* Which methods and providers your redshift build will support, is determined during execution of `./configure`. +* If you install none of the suggested dependencies (see below), **redshift will only work in a very limited manner**! Especially, **adjusting screen temperature will not be possible**. +* Therefore, make sure you have installed the required dependencies listed below, before `./configure` +* The `configure` script actually tells you which adjustment methods/providers will be included in the build: + ```shell + (...) + Adjustment methods: + DRM: no + RANDR: yes + VidMode: no + Quartz (macOS): no + WinGDI (Windows): no + + Location providers: + Geoclue2: yes + CoreLocation (macOS): no + (...) + ``` +* At least one of the adjustment methods should have "yes". +* Use `./configure --help` to see all available options. +* Use `--prefix` to make an install in your home directory. This is necessary to test python scripts. The systemd user unit directory should be set to avoid writing to the system location. +* Systemd will look for the unit files in `~/.config/systemd/user` so this directory can be used as a target if the unit files will be used. Otherwise the location can be set to `no` to disable the systemd files. -Example: +#### Example: ``` shell -$ ./configure --prefix=$HOME/redshift/root \ +$ ./configure --enable-randr --prefix=$HOME/redshift/root \ --with-systemduserunitdir=$HOME/.config/systemd/user ``` -Now, build the files: +### 3. Build and mount +Now, build the files and mount the Elektra specification: +(Mounting the specification requires root privileges. `redshift-conf.mount.sh` uses `sudo` to achieve that). ``` shell $ make +$ APP_PATH=`pwd`/src/redshift sh src/elektra/redshift-conf.mount.sh +``` + +### 4. Execute redshift +The main redshift program can be run at this point: +```shell +$ src/redshift ``` -The main redshift program can be run at this point. To install to the -prefix directory run: +### 5. Optional: Install +To install to the prefix directory run: ``` shell $ make install @@ -44,21 +72,34 @@ You can now run the python script. Example: $ $HOME/redshift/root/bin/redshift-gtk ``` +### Updating the Elektra specification file +When you update the Elektra specification file, make sure to regenerate the files `src/elektra/redshift-conf.*` and `src/elektra/windows/redshift-conf.*`: + +```sh +cd src/elektra +kdb gen -F ni=redshift.ni highlevel "/sw/jonls/redshift/#0/current" redshift-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; +cd windows +kdb gen -F dump=redshift-win.dump highlevel "/sw/jonls/redshift/#0/current" redshift-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; +``` Dependencies ------------ * autotools, gettext * intltool, libtool -* libdrm (Optional, for DRM support) -* libxcb, libxcb-randr (Optional, for RandR support) -* libX11, libXxf86vm (Optional, for VidMode support) +* libelektra5 +* libdrm (Suggested but optional, for DRM support) +* libxcb, libxcb-randr (Suggested but optional, for RandR support) +* libX11, libXxf86vm (Suggested but optional, for VidMode support) * Glib 2 (Optional, for GeoClue2 support) * python3, pygobject, pyxdg (Optional, for GUI support) * appindicator (Optional, for Ubuntu-style GUI status icon) -Ubuntu users will find all these dependencies in the packages listed in ``.travis.yml``. +#### Notes +* Install at least one adjustment method and location provider. Otherwise, redshift will only work in a very limited manner (see "2. Execute configure script" above). +* Ubuntu users will find all these dependencies in the packages listed in ``.travis.yml``. +* **Note that you also have to install the "-dev" packages for these libraries, if redshift should be able to use them**! Coding style for C code diff --git a/Makefile.am b/Makefile.am index 7e58f082..fd22d804 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,8 +12,7 @@ EXTRA_ROOTDOC_FILES = \ CONTRIBUTING.md \ DESIGN \ README \ - README-colorramp \ - redshift.conf.sample + README-colorramp _HICOLOR_FILES = \ data/icons/hicolor/scalable/apps/redshift.svg \ diff --git a/README.md b/README.md index 85c00e0d..f811e164 100644 --- a/README.md +++ b/README.md @@ -54,19 +54,31 @@ Use the packages provided by your distribution, e.g. for Ubuntu: `apt-get install redshift` or `apt-get install redshift-gtk`. For developers, please see _Building from source_ and _Latest builds from master branch_ below. -### How do I setup a configuration file? - -A configuration file is not required but is useful for saving custom -configurations and manually defining the location in case of issues with the -automatic location provider. An example configuration can be found in -[redshift.conf.sample](redshift.conf.sample). - -The configuration file should be saved in the following location depending on -the platform: - -- Linux/macOS: `~/.config/redshift/redshift.conf` (if the environment variable `XDG_CONFIG_HOME` is undefined) or `${XDG_CONFIG_HOME}/redshift/redshift.conf` (if `XDG_CONFIG_HOME` is defined). -- Windows: Put `redshift.conf` in `%USERPROFILE%\AppData\Local\` - (aka `%localappdata%`). +### How do I configure Redshift? + +* For temporary configuration execute Redshift with command-line (CLI) options. + `redshift --help` prints a list of supported options. +* For permanent changes use [Elektra's](https://www.libelektra.org/home) `kdb set` command. + +#### Example: Change coordinates +* To temporariliy set your location coordinates via CLI options execute: +`redshift --location-provider=manual --lat 52.0 --lon 14.0` + +* To set your location via `kdb` execute: + +``` +kdb set user:/sw/jonls/redshift/#0/current/provider/location manual +kdb set user:/sw/jonls/redshift/#0/current/provider/location/manual/lat 52.0 +kdb set user:/sw/jonls/redshift/#0/current/provider/location/manual/lon 14.0 +``` + +#### Supported configuration options +* For a list of supported CLI options execute `redshift --help`. +* For a list of supported options configureable via `kdb` execute: + * `kdb ls spec:/sw/jonls/redshift/#0/current` +* For details on a configuration option execute: + * `kdb meta-get spec:/sw/jonls/redshift/#0/current/INSERT_OPTION_NAME description` + * e.g.: `kdb meta-get spec:/sw/jonls/redshift/#0/current/fade description` ### Where can I find my coordinates to put in the configuration file? diff --git a/appveyor.yml b/appveyor.yml index 0ac39835..88adc058 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,29 +13,59 @@ build_script: - ps: | If ($env:arch -Match "x86_64") { $env:MSYSTEM = "MINGW64" + # TODO: switch to release channel after Elektra 0.9.8 is released + $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64-x86_64/elektra.zip" + $env:PATH_FOR_ELEKTRA_FILES = "C:\msys64\mingw64" } Else { $env:MSYSTEM = "MINGW32" + # TODO: switch to release channel after Elektra 0.9.8 is released + $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64-i686/elektra.zip" + $env:PATH_FOR_ELEKTRA_FILES = "C:\msys64\mingw32" } $env:CONFIGURE_FLAGS = "--disable-drm --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32" - ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER root) + +# Download and extract Elektra. +- ps: | + md (Join-Path $env:APPVEYOR_BUILD_FOLDER elektra-download) + cd $env:APPVEYOR_BUILD_FOLDER/elektra-download + Start-FileDownload $env:ELEKTRA_DOWNLOAD_URL + 7z x elektra.zip + + # Copied from https://stackoverflow.com/a/44931279 + function CopyFilesToFolder ($fromFolder, $toFolder) { + $childItems = Get-ChildItem $fromFolder + $childItems | ForEach-Object { + Copy-Item -Path $_.FullName -Destination $toFolder -Recurse -Force + } + Write-Output "Copied all items of $fromFolder to $toFolder" + } + CopyFilesToFolder elektra\usr\local\lib $env:PATH_FOR_ELEKTRA_FILES\lib + CopyFilesToFolder elektra\usr\local\include $env:PATH_FOR_ELEKTRA_FILES\include + md $env:APPVEYOR_BUILD_FOLDER\root\bin + Copy-Item -Path elektra\usr\local\bin\kdb-static.exe $env:APPVEYOR_BUILD_FOLDER\root\bin + Copy-Item -Path elektra\usr\local\lib\libelektra-full.dll $env:APPVEYOR_BUILD_FOLDER\root\bin + cd $env:APPVEYOR_BUILD_FOLDER + - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./configure --prefix=\"$APPVEYOR_BUILD_FOLDER/root\" $CONFIGURE_FLAGS" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && make distcheck DISTCHECK_CONFIGURE_FLAGS=\"$CONFIGURE_FLAGS\"" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && make install" test_script: + - | - %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe -l 12:-34 -pv -- | - %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe -l 12:-34 -m dummy -vo -- ps: Set-Content -Value "[redshift]`ndawn-time=6:30`ndusk-time=18:00-19:30`n" -Path time.config + mkdir C:\ProgramData\usr\local\kdb\ + %APPVEYOR_BUILD_FOLDER%\root\bin\kdb-static.exe mount ../../../../projects/redshift/src/elektra/windows/redshift-win.dump spec:/sw/jonls/redshift/#0/current dump + %APPVEYOR_BUILD_FOLDER%\root\bin\kdb-static.exe spec-mount /sw/jonls/redshift/#0/current + - | - %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe -c time.config -pv + %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe --help - | - %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe -c time.config -m dummy -vo - + %APPVEYOR_BUILD_FOLDER%\root\bin\redshift.exe --mode=print --location-provider=manual --lat=12 --lon=-34 --method=dummy -v + after_build: - ps: | $ZIP_NAME = "redshift-windows-$env:arch" @@ -43,10 +73,12 @@ after_build: md $ZIP_NAME Copy-Item -Path $env:APPVEYOR_BUILD_FOLDER\root\bin\redshift.exe -Destination $ZIP_NAME + Copy-Item -Path $env:APPVEYOR_BUILD_FOLDER\root\bin\kdb-static.exe -Destination $ZIP_NAME + Copy-Item -Path $env:APPVEYOR_BUILD_FOLDER\root\bin\libelektra-full.dll -Destination $ZIP_NAME + Copy-Item -Path $env:APPVEYOR_BUILD_FOLDER\src\elektra\windows\redshift-win.dump -Destination $ZIP_NAME Copy-Item -Path README.md -Destination $ZIP_NAME/README.txt Copy-Item -Path NEWS.md -Destination $ZIP_NAME/NEWS.txt Copy-Item -Path COPYING -Destination $ZIP_NAME/COPYING.txt - Copy-Item -Path redshift.conf.sample -Destination $ZIP_NAME 7z a $ZIP_FILE $ZIP_NAME/ - ps: Push-AppveyorArtifact $ZIP_FILE diff --git a/configure.ac b/configure.ac index b4116262..d06e8d4c 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ esac AC_CHECK_TOOL([WINDRES], [windres], []) AS_IF([test "x$build_windows" = "xyes" -a -n "x$WINDRES"], [ enable_windows_resource=yes + AC_DEFINE([WINDOWS_BUILD], [1], [Add a DEFINE that this is a Windows build]) ], [ enable_windows_resource=no ]) @@ -71,6 +72,10 @@ PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr], PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no]) PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no]) +# No action-if-not-found is given, because we the build to fail, if elektra is missing. +# The build will fail, because that is the default behavior if action-if-not-found is not set ("end the execution with an error for not having found the dependency.", https://autotools.io/pkgconfig/pkg_check_modules.html) +PKG_CHECK_MODULES([ELEKTRA], [ elektra elektra-codegen elektra-highlevel >= 0.9.7]) + # macOS headers AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h], [have_appserv_h=yes], [have_appserv_h=no]) diff --git a/po/POTFILES.in b/po/POTFILES.in index 5ef8dacc..aeee0b3c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,7 +6,6 @@ data/applications/redshift-gtk.desktop.in src/redshift.c src/options.c -src/config-ini.c src/gamma-drm.c src/gamma-randr.c diff --git a/po/redshift.pot b/po/redshift.pot deleted file mode 100644 index 619f4a5a..00000000 --- a/po/redshift.pot +++ /dev/null @@ -1,809 +0,0 @@ -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: https://github.com/jonls/redshift/issues\n" -"POT-Creation-Date: 2017-10-18 11:46-0700\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2018-05-21 01:04+0000\n" -"X-Generator: Launchpad (build 18658)\n" -"Language: \n" - -#: ../data/appdata/redshift-gtk.appdata.xml.in.h:1 -msgid "" -"Redshift adjusts the color temperature of your screen according to your " -"surroundings. This may help your eyes hurt less if you are working in front " -"of the screen at night." -msgstr "" - -#: ../data/appdata/redshift-gtk.appdata.xml.in.h:2 -msgid "" -"The color temperature is set according to the position of the sun. A " -"different color temperature is set during night and daytime. During twilight " -"and early morning, the color temperature transitions smoothly from night to " -"daytime temperature to allow your eyes to slowly adapt." -msgstr "" - -#: ../data/appdata/redshift-gtk.appdata.xml.in.h:3 -msgid "" -"This program provides a status icon that allows the user to control Redshift." -msgstr "" - -#: ../data/appdata/redshift-gtk.appdata.xml.in.h:4 -msgid "" -"The Redshift information window overlaid with an example of the redness " -"effect" -msgstr "" - -#: ../data/applications/redshift.desktop.in.h:1 -#: ../data/applications/redshift-gtk.desktop.in.h:1 -msgid "Redshift" -msgstr "" - -#: ../data/applications/redshift.desktop.in.h:2 -#: ../data/applications/redshift-gtk.desktop.in.h:2 -msgid "Color temperature adjustment" -msgstr "" - -#: ../data/applications/redshift.desktop.in.h:3 -#: ../data/applications/redshift-gtk.desktop.in.h:3 -msgid "Color temperature adjustment tool" -msgstr "" - -#. TRANSLATORS: Name printed when period of day is unknown -#: ../src/redshift.c:135 -msgid "None" -msgstr "" - -#: ../src/redshift.c:136 ../src/redshift.c:1107 -msgid "Daytime" -msgstr "" - -#: ../src/redshift.c:137 ../src/redshift.c:1111 -msgid "Night" -msgstr "" - -#: ../src/redshift.c:138 -msgid "Transition" -msgstr "" - -#: ../src/redshift.c:225 -#, c-format -msgid "Period: %s\n" -msgstr "" - -#: ../src/redshift.c:228 -#, c-format -msgid "Period: %s (%.2f%% day)\n" -msgstr "" - -#. TRANSLATORS: Abbreviation for `north' -#: ../src/redshift.c:240 -msgid "N" -msgstr "" - -#. TRANSLATORS: Abbreviation for `south' -#: ../src/redshift.c:242 -msgid "S" -msgstr "" - -#. TRANSLATORS: Abbreviation for `east' -#: ../src/redshift.c:244 -msgid "E" -msgstr "" - -#. TRANSLATORS: Abbreviation for `west' -#: ../src/redshift.c:246 -msgid "W" -msgstr "" - -#. TRANSLATORS: Append degree symbols after %f if possible. -#. The string following each number is an abreviation for -#. north, source, east or west (N, S, E, W). -#: ../src/redshift.c:251 -#, c-format -msgid "Location: %.2f %s, %.2f %s\n" -msgstr "" - -#: ../src/redshift.c:325 ../src/redshift.c:416 -#, c-format -msgid "Initialization of %s failed.\n" -msgstr "" - -#: ../src/redshift.c:340 ../src/redshift.c:384 ../src/redshift.c:431 -#: ../src/redshift.c:463 -#, c-format -msgid "Failed to set %s option.\n" -msgstr "" - -#. TRANSLATORS: `help' must not be -#. translated. -#. TRANSLATORS: `help' must not be translated. -#: ../src/redshift.c:345 ../src/redshift.c:387 -#, c-format -msgid "Try `-l %s:help' for more information.\n" -msgstr "" - -#: ../src/redshift.c:373 ../src/redshift.c:453 -#, c-format -msgid "Failed to parse option `%s'.\n" -msgstr "" - -#: ../src/redshift.c:400 -#, c-format -msgid "Failed to start provider %s.\n" -msgstr "" - -#. TRANSLATORS: `help' must not be -#. translated. -#: ../src/redshift.c:436 -#, c-format -msgid "Try `-m %s:help' for more information.\n" -msgstr "" - -#. TRANSLATORS: `help' must not be translated. -#: ../src/redshift.c:466 -#, c-format -msgid "Try -m %s:help' for more information.\n" -msgstr "" - -#: ../src/redshift.c:478 -#, c-format -msgid "Failed to start adjustment method %s.\n" -msgstr "" - -#: ../src/redshift.c:509 -#, c-format -msgid "Latitude must be between %.1f and %.1f.\n" -msgstr "" - -#: ../src/redshift.c:518 -#, c-format -msgid "Longitude must be between %.1f and %.1f.\n" -msgstr "" - -#: ../src/redshift.c:545 ../src/redshift.c:564 ../src/redshift.c:696 -#: ../src/redshift.c:1187 -msgid "Unable to read system time.\n" -msgstr "" - -#: ../src/redshift.c:635 -msgid "Waiting for initial location to become available...\n" -msgstr "" - -#: ../src/redshift.c:641 ../src/redshift.c:832 ../src/redshift.c:847 -#: ../src/redshift.c:1172 -msgid "Unable to get location from provider.\n" -msgstr "" - -#: ../src/redshift.c:647 ../src/redshift.c:871 -msgid "Invalid location returned from provider.\n" -msgstr "" - -#: ../src/redshift.c:656 ../src/redshift.c:788 ../src/redshift.c:1222 -#: ../src/redshift.c:1253 -#, c-format -msgid "Color temperature: %uK\n" -msgstr "" - -#: ../src/redshift.c:657 ../src/redshift.c:793 ../src/redshift.c:1224 -#, c-format -msgid "Brightness: %.2f\n" -msgstr "" - -#: ../src/redshift.c:686 -#, c-format -msgid "Status: %s\n" -msgstr "" - -#: ../src/redshift.c:687 ../src/redshift-gtk/statusicon.py:301 -msgid "Disabled" -msgstr "" - -#: ../src/redshift.c:687 ../src/redshift-gtk/statusicon.py:73 -#: ../src/redshift-gtk/statusicon.py:301 -msgid "Enabled" -msgstr "" - -#: ../src/redshift.c:802 ../src/redshift.c:1233 ../src/redshift.c:1263 -#: ../src/redshift.c:1285 -msgid "Temperature adjustment failed.\n" -msgstr "" - -#: ../src/redshift.c:854 -msgid "" -"Location is temporarily unavailable; Using previous location until it " -"becomes available...\n" -msgstr "" - -#: ../src/redshift.c:967 -msgid "Partitial time-configuration not supported!\n" -msgstr "" - -#: ../src/redshift.c:975 -msgid "Invalid dawn/dusk time configuration!\n" -msgstr "" - -#: ../src/redshift.c:1006 -#, c-format -msgid "Trying location provider `%s'...\n" -msgstr "" - -#: ../src/redshift.c:1011 -msgid "Trying next provider...\n" -msgstr "" - -#: ../src/redshift.c:1017 -#, c-format -msgid "Using provider `%s'.\n" -msgstr "" - -#: ../src/redshift.c:1025 -msgid "No more location providers to try.\n" -msgstr "" - -#: ../src/redshift.c:1034 -#, c-format -msgid "" -"High transition elevation cannot be lower than the low transition " -"elevation.\n" -msgstr "" - -#. TRANSLATORS: Append degree symbols if possible. -#: ../src/redshift.c:1041 -#, c-format -msgid "Solar elevations: day above %.1f, night below %.1f\n" -msgstr "" - -#: ../src/redshift.c:1049 -#, c-format -msgid "Temperatures: %dK at day, %dK at night\n" -msgstr "" - -#: ../src/redshift.c:1060 ../src/redshift.c:1071 -#, c-format -msgid "Temperature must be between %uK and %uK.\n" -msgstr "" - -#: ../src/redshift.c:1083 -#, c-format -msgid "Brightness values must be between %.1f and %.1f.\n" -msgstr "" - -#: ../src/redshift.c:1089 -#, c-format -msgid "Brightness: %.2f:%.2f\n" -msgstr "" - -#: ../src/redshift.c:1098 -#, c-format -msgid "Gamma value must be between %.1f and %.1f.\n" -msgstr "" - -#. TRANSLATORS: The string in parenthesis is either -#. Daytime or Night (translated). -#: ../src/redshift.c:1106 ../src/redshift.c:1110 -#, c-format -msgid "Gamma (%s): %.3f, %.3f, %.3f\n" -msgstr "" - -#: ../src/redshift.c:1139 -msgid "Trying next method...\n" -msgstr "" - -#: ../src/redshift.c:1144 -#, c-format -msgid "Using method `%s'.\n" -msgstr "" - -#: ../src/redshift.c:1151 -msgid "No more methods to try.\n" -msgstr "" - -#: ../src/redshift.c:1165 -msgid "Waiting for current location to become available...\n" -msgstr "" - -#. TRANSLATORS: Append degree symbol if -#. possible. -#: ../src/redshift.c:1206 -#, c-format -msgid "Solar elevation: %f\n" -msgstr "" - -#: ../src/redshift.c:1244 ../src/redshift.c:1272 ../src/redshift.c:1294 -msgid "Press ctrl-c to stop...\n" -msgstr "" - -#. TRANSLATORS: help output 1 -#. LAT is latitude, LON is longitude, -#. DAY is temperature at daytime, -#. NIGHT is temperature at night -#. no-wrap -#: ../src/options.c:159 -#, c-format -msgid "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n" -msgstr "" - -#. TRANSLATORS: help output 2 -#. no-wrap -#: ../src/options.c:165 -msgid "Set color temperature of display according to time of day.\n" -msgstr "" - -#. TRANSLATORS: help output 3 -#. no-wrap -#: ../src/options.c:171 -msgid "" -" -h\t\tDisplay this help message\n" -" -v\t\tVerbose output\n" -" -V\t\tShow program version\n" -msgstr "" - -#. TRANSLATORS: help output 4 -#. `list' must not be translated -#. no-wrap -#: ../src/options.c:179 -msgid "" -" -b DAY:NIGHT\tScreen brightness to apply (between 0.1 and 1.0)\n" -" -c FILE\tLoad settings from specified configuration file\n" -" -g R:G:B\tAdditional gamma correction to apply\n" -" -l LAT:LON\tYour current location\n" -" -l PROVIDER\tSelect provider for automatic location updates\n" -" \t\t(Type `list' to see available providers)\n" -" -m METHOD\tMethod to use to set color temperature\n" -" \t\t(Type `list' to see available methods)\n" -" -o\t\tOne shot mode (do not continuously adjust color temperature)\n" -" -O TEMP\tOne shot manual mode (set color temperature)\n" -" -p\t\tPrint mode (only print parameters and exit)\n" -" -P\t\tReset existing gamma ramps before applying new color effect\n" -" -x\t\tReset mode (remove adjustment from screen)\n" -" -r\t\tDisable fading between color temperatures\n" -" -t DAY:NIGHT\tColor temperature to set at daytime/night\n" -msgstr "" - -#. TRANSLATORS: help output 5 -#: ../src/options.c:201 -#, c-format -msgid "" -"The neutral temperature is %uK. Using this value will not change the color\n" -"temperature of the display. Setting the color temperature to a value higher\n" -"than this results in more blue light, and setting a lower value will result " -"in\n" -"more red light.\n" -msgstr "" - -#. TRANSLATORS: help output 6 -#: ../src/options.c:210 -#, c-format -msgid "" -"Default values:\n" -"\n" -" Daytime temperature: %uK\n" -" Night temperature: %uK\n" -msgstr "" - -#. TRANSLATORS: help output 7 -#: ../src/options.c:218 -#, c-format -msgid "Please report bugs to <%s>\n" -msgstr "" - -#: ../src/options.c:225 -msgid "Available adjustment methods:\n" -msgstr "" - -#: ../src/options.c:231 -msgid "Specify colon-separated options with `-m METHOD:OPTIONS'.\n" -msgstr "" - -#. TRANSLATORS: `help' must not be translated. -#: ../src/options.c:234 -msgid "Try `-m METHOD:help' for help.\n" -msgstr "" - -#: ../src/options.c:241 -msgid "Available location providers:\n" -msgstr "" - -#: ../src/options.c:247 -msgid "Specify colon-separated options with`-l PROVIDER:OPTIONS'.\n" -msgstr "" - -#. TRANSLATORS: `help' must not be translated. -#: ../src/options.c:250 -msgid "Try `-l PROVIDER:help' for help.\n" -msgstr "" - -#: ../src/options.c:356 -msgid "Malformed gamma argument.\n" -msgstr "" - -#: ../src/options.c:358 ../src/options.c:472 ../src/options.c:491 -msgid "Try `-h' for more information.\n" -msgstr "" - -#: ../src/options.c:407 ../src/options.c:610 -#, c-format -msgid "Unknown location provider `%s'.\n" -msgstr "" - -#. TRANSLATORS: This refers to the method -#. used to adjust colors e.g VidMode -#: ../src/options.c:439 ../src/options.c:597 -#, c-format -msgid "Unknown adjustment method `%s'.\n" -msgstr "" - -#: ../src/options.c:470 -msgid "Malformed temperature argument.\n" -msgstr "" - -#: ../src/options.c:561 ../src/options.c:575 ../src/options.c:586 -msgid "Malformed gamma setting.\n" -msgstr "" - -#: ../src/options.c:621 -#, c-format -msgid "Malformed dawn-time setting `%s'.\n" -msgstr "" - -#: ../src/options.c:632 -#, c-format -msgid "Malformed dusk-time setting `%s'.\n" -msgstr "" - -#: ../src/options.c:639 -#, c-format -msgid "Unknown configuration setting `%s'.\n" -msgstr "" - -#: ../src/config-ini.c:167 -msgid "Malformed section header in config file.\n" -msgstr "" - -#: ../src/config-ini.c:203 -msgid "Malformed assignment in config file.\n" -msgstr "" - -#: ../src/config-ini.c:214 -msgid "Assignment outside section in config file.\n" -msgstr "" - -#: ../src/gamma-drm.c:97 -#, c-format -msgid "Failed to open DRM device: %s\n" -msgstr "" - -#: ../src/gamma-drm.c:105 -#, c-format -msgid "Failed to get DRM mode resources\n" -msgstr "" - -#: ../src/gamma-drm.c:115 ../src/gamma-randr.c:384 -#, c-format -msgid "CRTC %d does not exist. " -msgstr "" - -#: ../src/gamma-drm.c:118 ../src/gamma-randr.c:387 -#, c-format -msgid "Valid CRTCs are [0-%d].\n" -msgstr "" - -#: ../src/gamma-drm.c:121 ../src/gamma-randr.c:390 -#, c-format -msgid "Only CRTC 0 exists.\n" -msgstr "" - -#: ../src/gamma-drm.c:159 -#, c-format -msgid "CRTC %i lost, skipping\n" -msgstr "" - -#: ../src/gamma-drm.c:165 -#, c-format -msgid "" -"Could not get gamma ramp size for CRTC %i\n" -"on graphics card %i, ignoring device.\n" -msgstr "" - -#: ../src/gamma-drm.c:178 -#, c-format -msgid "" -"DRM could not read gamma ramps on CRTC %i on\n" -"graphics card %i, ignoring device.\n" -msgstr "" - -#: ../src/gamma-drm.c:242 -msgid "Adjust gamma ramps with Direct Rendering Manager.\n" -msgstr "" - -#. TRANSLATORS: DRM help output -#. left column must not be translated -#: ../src/gamma-drm.c:247 -msgid "" -" card=N\tGraphics card to apply adjustments to\n" -" crtc=N\tCRTC to apply adjustments to\n" -msgstr "" - -#: ../src/gamma-drm.c:260 -#, c-format -msgid "CRTC must be a non-negative integer\n" -msgstr "" - -#: ../src/gamma-drm.c:264 ../src/gamma-randr.c:369 ../src/gamma-vidmode.c:161 -#: ../src/gamma-quartz.c:183 ../src/gamma-w32gdi.c:128 ../src/gamma-dummy.c:67 -#: ../src/location-geoclue2.c:408 ../src/location-corelocation.m:243 -#: ../src/location-manual.c:106 -#, c-format -msgid "Unknown method parameter: `%s'.\n" -msgstr "" - -#: ../src/gamma-randr.c:94 ../src/gamma-randr.c:153 ../src/gamma-randr.c:192 -#: ../src/gamma-randr.c:218 ../src/gamma-randr.c:275 ../src/gamma-randr.c:435 -#, c-format -msgid "`%s' returned error %d\n" -msgstr "" - -#: ../src/gamma-randr.c:103 -#, c-format -msgid "Unsupported RANDR version (%u.%u)\n" -msgstr "" - -#: ../src/gamma-randr.c:138 -#, c-format -msgid "Screen %i could not be found.\n" -msgstr "" - -#: ../src/gamma-randr.c:204 ../src/gamma-vidmode.c:96 ../src/gamma-quartz.c:114 -#, c-format -msgid "Gamma ramp size too small: %i\n" -msgstr "" - -#: ../src/gamma-randr.c:277 -#, c-format -msgid "Unable to restore CRTC %i\n" -msgstr "" - -#: ../src/gamma-randr.c:301 -msgid "Adjust gamma ramps with the X RANDR extension.\n" -msgstr "" - -#. TRANSLATORS: RANDR help output -#. left column must not be translated -#: ../src/gamma-randr.c:306 -msgid "" -" screen=N\t\tX screen to apply adjustments to\n" -" crtc=N\tList of comma separated CRTCs to apply adjustments to\n" -msgstr "" - -#: ../src/gamma-randr.c:328 -#, c-format -msgid "Unable to read screen number: `%s'.\n" -msgstr "" - -#: ../src/gamma-randr.c:364 ../src/gamma-vidmode.c:156 -#: ../src/gamma-quartz.c:178 ../src/gamma-w32gdi.c:123 -#, c-format -msgid "" -"Parameter `%s` is now always on; Use the `%s` command-line option to " -"disable.\n" -msgstr "" - -#: ../src/gamma-vidmode.c:61 ../src/gamma-vidmode.c:81 -#: ../src/gamma-vidmode.c:90 ../src/gamma-vidmode.c:117 -#: ../src/gamma-vidmode.c:180 ../src/gamma-vidmode.c:225 -#, c-format -msgid "X request failed: %s\n" -msgstr "" - -#: ../src/gamma-vidmode.c:140 -msgid "Adjust gamma ramps with the X VidMode extension.\n" -msgstr "" - -#. TRANSLATORS: VidMode help output -#. left column must not be translated -#: ../src/gamma-vidmode.c:145 -msgid " screen=N\t\tX screen to apply adjustments to\n" -msgstr "" - -#: ../src/gamma-quartz.c:140 ../src/gamma-w32gdi.c:91 -msgid "Unable to save current gamma ramp.\n" -msgstr "" - -#: ../src/gamma-quartz.c:170 -msgid "Adjust gamma ramps on macOS using Quartz.\n" -msgstr "" - -#: ../src/gamma-w32gdi.c:68 ../src/gamma-w32gdi.c:141 ../src/gamma-w32gdi.c:168 -msgid "Unable to open device context.\n" -msgstr "" - -#: ../src/gamma-w32gdi.c:75 -msgid "Display device does not support gamma ramps.\n" -msgstr "" - -#: ../src/gamma-w32gdi.c:115 -msgid "Adjust gamma ramps with the Windows GDI.\n" -msgstr "" - -#: ../src/gamma-w32gdi.c:153 -msgid "Unable to restore gamma ramps.\n" -msgstr "" - -#: ../src/gamma-w32gdi.c:211 -msgid "Unable to set gamma ramps.\n" -msgstr "" - -#: ../src/gamma-dummy.c:43 -msgid "" -"WARNING: Using dummy gamma method! Display will not be affected by this " -"gamma method.\n" -msgstr "" - -#: ../src/gamma-dummy.c:60 -msgid "" -"Does not affect the display but prints the color temperature to the " -"terminal.\n" -msgstr "" - -#: ../src/gamma-dummy.c:75 -#, c-format -msgid "Temperature: %i\n" -msgstr "" - -#: ../src/location-geoclue2.c:59 -#, c-format -msgid "" -"Access to the current location was denied by GeoClue!\n" -"Make sure that location services are enabled and that Redshift is permitted\n" -"to use location services. See https://github.com/jonls/redshift#faq for " -"more\n" -"information.\n" -msgstr "" - -#: ../src/location-geoclue2.c:107 -#, c-format -msgid "Unable to obtain location: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:150 -#, c-format -msgid "Unable to obtain GeoClue Manager: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:166 -#, c-format -msgid "Unable to obtain GeoClue client path: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:188 -#, c-format -msgid "Unable to obtain GeoClue Client: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:229 -#, c-format -msgid "Unable to set distance threshold: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:253 -#, c-format -msgid "Unable to start GeoClue client: %s.\n" -msgstr "" - -#: ../src/location-geoclue2.c:365 -msgid "Failed to start GeoClue2 provider!\n" -msgstr "" - -#: ../src/location-geoclue2.c:399 -msgid "Use the location as discovered by a GeoClue2 provider.\n" -msgstr "" - -#: ../src/location-corelocation.m:73 -msgid "Not authorized to obtain location from CoreLocation.\n" -msgstr "" - -#: ../src/location-corelocation.m:111 -#, c-format -msgid "Error obtaining location from CoreLocation: %s\n" -msgstr "" - -#: ../src/location-corelocation.m:120 -msgid "Waiting for authorization to obtain location...\n" -msgstr "" - -#: ../src/location-corelocation.m:122 -msgid "Request for location was not authorized!\n" -msgstr "" - -#: ../src/location-corelocation.m:203 -msgid "Failed to start CoreLocation provider!\n" -msgstr "" - -#: ../src/location-corelocation.m:235 -msgid "Use the location as discovered by the Corelocation provider.\n" -msgstr "" - -#: ../src/location-manual.c:59 -msgid "Latitude and longitude must be set.\n" -msgstr "" - -#: ../src/location-manual.c:75 -msgid "Specify location manually.\n" -msgstr "" - -#. TRANSLATORS: Manual location help output -#. left column must not be translated -#: ../src/location-manual.c:80 -msgid "" -" lat=N\t\tLatitude\n" -" lon=N\t\tLongitude\n" -msgstr "" - -#: ../src/location-manual.c:83 -msgid "" -"Both values are expected to be floating point numbers,\n" -"negative values representing west / south, respectively.\n" -msgstr "" - -#: ../src/location-manual.c:97 -msgid "Malformed argument.\n" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:78 -msgid "Suspend for" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:80 -msgid "30 minutes" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:81 -msgid "1 hour" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:82 -msgid "2 hours" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:91 -msgid "Autostart" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:103 ../src/redshift-gtk/statusicon.py:113 -msgid "Info" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:108 -msgid "Quit" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:146 -msgid "Close" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:300 -msgid "Status: {}" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:306 ../src/redshift-gtk/statusicon.py:324 -msgid "Color temperature" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:312 ../src/redshift-gtk/statusicon.py:325 -msgid "Period" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:318 -msgid "Location" -msgstr "" - -#: ../src/redshift-gtk/statusicon.py:349 -msgid "Please run `redshift -h` for help output." -msgstr "" diff --git a/redshift.conf.sample b/redshift.conf.sample deleted file mode 100644 index 882865be..00000000 --- a/redshift.conf.sample +++ /dev/null @@ -1,70 +0,0 @@ -; Global settings for redshift -[redshift] -; Set the day and night screen temperatures -temp-day=5700 -temp-night=3500 - -; Disable the smooth fade between temperatures when Redshift starts and stops. -; 0 will cause an immediate change between screen temperatures. -; 1 will gradually apply the new screen temperature over a couple of seconds. -fade=1 - -; Solar elevation thresholds. -; By default, Redshift will use the current elevation of the sun to determine -; whether it is daytime, night or in transition (dawn/dusk). When the sun is -; above the degrees specified with elevation-high it is considered daytime and -; below elevation-low it is considered night. -;elevation-high=3 -;elevation-low=-6 - -; Custom dawn/dusk intervals. -; Instead of using the solar elevation, the time intervals of dawn and dusk -; can be specified manually. The times must be specified as HH:MM in 24-hour -; format. -;dawn-time=6:00-7:45 -;dusk-time=18:35-20:15 - -; Set the screen brightness. Default is 1.0. -;brightness=0.9 -; It is also possible to use different settings for day and night -; since version 1.8. -;brightness-day=0.7 -;brightness-night=0.4 -; Set the screen gamma (for all colors, or each color channel -; individually) -gamma=0.8 -;gamma=0.8:0.7:0.8 -; This can also be set individually for day and night since -; version 1.10. -;gamma-day=0.8:0.7:0.8 -;gamma-night=0.6 - -; Set the location-provider: 'geoclue2', 'manual' -; type 'redshift -l list' to see possible values. -; The location provider settings are in a different section. -location-provider=manual - -; Set the adjustment-method: 'randr', 'vidmode' -; type 'redshift -m list' to see all possible values. -; 'randr' is the preferred method, 'vidmode' is an older API. -; but works in some cases when 'randr' does not. -; The adjustment method settings are in a different section. -adjustment-method=randr - -; Configuration of the location-provider: -; type 'redshift -l PROVIDER:help' to see the settings. -; ex: 'redshift -l manual:help' -; Keep in mind that longitudes west of Greenwich (e.g. the Americas) -; are negative numbers. -[manual] -lat=48.1 -lon=11.6 - -; Configuration of the adjustment-method -; type 'redshift -m METHOD:help' to see the settings. -; ex: 'redshift -m randr:help' -; In this example, randr is configured to adjust only screen 0. -; Note that the numbering starts from 0, so this is actually the first screen. -; If this option is not specified, Redshift will try to adjust _all_ screens. -[randr] -screen=0 diff --git a/src/Makefile.am b/src/Makefile.am index 8aa96ead..fac65fcf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,6 @@ bin_PROGRAMS = redshift redshift_SOURCES = \ colorramp.c colorramp.h \ - config-ini.c config-ini.h \ gamma-dummy.c gamma-dummy.h \ hooks.c hooks.h \ location-manual.c location-manual.h \ @@ -32,6 +31,15 @@ EXTRA_redshift_SOURCES = \ windows/appicon.rc \ windows/versioninfo.rc +if ENABLE_WINDOWS_RESOURCE +redshift_SOURCES += elektra/windows/redshift-conf.h elektra/windows/redshift-conf.c +else +redshift_SOURCES += elektra/redshift-conf.h elektra/redshift-conf.c +scriptsdir = $(prefix)/libexec +scripts_DATA = elektra/redshift-conf.mount.sh +endif + + AM_CFLAGS = redshift_LDADD = @LIBINTL@ EXTRA_DIST = windows/redshift.ico @@ -80,6 +88,12 @@ redshift_LDADD += \ $(GEOCLUE2_LIBS) $(GEOCLUE2_CFLAGS) endif +AM_CFLAGS += \ + $(ELEKTRA_CFLAGS) +redshift_LDADD += \ + $(ELEKTRA_LIBS) $(ELEKTRA_CFLAGS) + + # Build CoreLocation module as a separate convenience # library since it is using a separate compiler # (Objective C). @@ -99,6 +113,7 @@ endif # Windows resources if ENABLE_WINDOWS_RESOURCE redshift_SOURCES += windows/appicon.rc windows/versioninfo.rc + endif .rc.o: diff --git a/src/config-ini.c b/src/config-ini.c deleted file mode 100644 index 63c1f5e1..00000000 --- a/src/config-ini.c +++ /dev/null @@ -1,326 +0,0 @@ -/* config-ini.c -- INI config file parser - This file is part of Redshift. - - Redshift 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. - - Redshift 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 Redshift. If not, see . - - Copyright (c) 2010-2018 Jon Lund Steffensen -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WIN32 -# include -#endif - -#include "config-ini.h" - -#ifdef ENABLE_NLS -# include -# define _(s) gettext(s) -#else -# define _(s) s -#endif - -#define MAX_CONFIG_PATH 4096 -#define MAX_LINE_LENGTH 512 - - -static FILE * -open_config_file(const char *filepath) -{ - FILE *f = NULL; - - /* If a path is not specified (filepath is NULL) then - the configuration file is searched for in the directories - specified by the XDG Base Directory Specification - . - - If HOME is not set, getpwuid() is consulted for the home directory. On - windows platforms the %localappdata% is used in place of XDG_CONFIG_HOME. - */ - - if (filepath == NULL) { - FILE *f = NULL; - char cp[MAX_CONFIG_PATH]; - char *env; - - if (f == NULL && (env = getenv("XDG_CONFIG_HOME")) != NULL && - env[0] != '\0') { - snprintf(cp, sizeof(cp), - "%s/redshift/redshift.conf", env); - f = fopen(cp, "r"); - if (f == NULL) { - /* Fall back to formerly used path. */ - snprintf(cp, sizeof(cp), - "%s/redshift.conf", env); - f = fopen(cp, "r"); - } - } - -#ifdef _WIN32 - if (f == NULL && (env = getenv("localappdata")) != NULL && - env[0] != '\0') { - snprintf(cp, sizeof(cp), - "%s\\redshift.conf", env); - f = fopen(cp, "r"); - } -#endif - if (f == NULL && (env = getenv("HOME")) != NULL && - env[0] != '\0') { - snprintf(cp, sizeof(cp), - "%s/.config/redshift/redshift.conf", env); - f = fopen(cp, "r"); - if (f == NULL) { - /* Fall back to formerly used path. */ - snprintf(cp, sizeof(cp), - "%s/.config/redshift.conf", env); - f = fopen(cp, "r"); - } - } -#ifndef _WIN32 - - if (f == NULL) { - struct passwd *pwd = getpwuid(getuid()); - char *home = pwd->pw_dir; - snprintf(cp, sizeof(cp), - "%s/.config/redshift/redshift.conf", home); - f = fopen(cp, "r"); - if (f == NULL) { - /* Fall back to formerly used path. */ - snprintf(cp, sizeof(cp), - "%s/.config/redshift.conf", home); - f = fopen(cp, "r"); - } - } - - if (f == NULL && (env = getenv("XDG_CONFIG_DIRS")) != NULL && - env[0] != '\0') { - char *begin = env; - while (1) { - char *end = strchr(begin, ':'); - if (end == NULL) end = strchr(begin, '\0'); - - int len = end - begin; - if (len > 0) { - snprintf(cp, sizeof(cp), - "%.*s/redshift/redshift.conf", len, begin); - f = fopen(cp, "r"); - if (f != NULL) { - /* Fall back to formerly used path. */ - snprintf(cp, sizeof(cp), - "%.*s/redshift.conf", len, begin); - f = fopen(cp, "r"); - } - if (f != NULL) break; - } - - if (end[0] == '\0') break; - begin = end + 1; - } - } - - if (f == NULL) { - snprintf(cp, sizeof(cp), - "%s/redshift.conf", "/etc"); - f = fopen(cp, "r"); - } -#endif - - return f; - } else { - f = fopen(filepath, "r"); - if (f == NULL) { - perror("fopen"); - return NULL; - } - } - - return f; -} - -int -config_ini_init(config_ini_state_t *state, const char *filepath) -{ - config_ini_section_t *section = NULL; - state->sections = NULL; - - FILE *f = open_config_file(filepath); - if (f == NULL) { - /* Only a serious error if a file was explicitly requested. */ - if (filepath != NULL) return -1; - return 0; - } - - char line[MAX_LINE_LENGTH]; - char *s; - - while (1) { - /* Handle the file input linewise. */ - char *r = fgets(line, sizeof(line), f); - if (r == NULL) break; - - /* Strip leading blanks and trailing newline. */ - s = line + strspn(line, " \t"); - s[strcspn(s, "\r\n")] = '\0'; - - /* Skip comments and empty lines. */ - if (s[0] == ';' || s[0] == '#' || s[0] == '\0') continue; - - if (s[0] == '[') { - /* Read name of section. */ - const char *name = s+1; - char *end = strchr(s, ']'); - if (end == NULL || end[1] != '\0' || end == name) { - fputs(_("Malformed section header in config" - " file.\n"), stderr); - fclose(f); - config_ini_free(state); - return -1; - } - - *end = '\0'; - - /* Create section. */ - section = malloc(sizeof(config_ini_section_t)); - if (section == NULL) { - fclose(f); - config_ini_free(state); - return -1; - } - - /* Insert into section list. */ - section->name = NULL; - section->settings = NULL; - section->next = state->sections; - state->sections = section; - - /* Copy section name. */ - section->name = malloc(end - name + 1); - if (section->name == NULL) { - fclose(f); - config_ini_free(state); - return -1; - } - - memcpy(section->name, name, end - name + 1); - } else { - /* Split assignment at equals character. */ - char *end = strchr(s, '='); - if (end == NULL || end == s) { - fputs(_("Malformed assignment in config" - " file.\n"), stderr); - fclose(f); - config_ini_free(state); - return -1; - } - - *end = '\0'; - char *value = end + 1; - - if (section == NULL) { - fputs(_("Assignment outside section in config" - " file.\n"), stderr); - fclose(f); - config_ini_free(state); - return -1; - } - - /* Create section. */ - config_ini_setting_t *setting = - malloc(sizeof(config_ini_setting_t)); - if (setting == NULL) { - fclose(f); - config_ini_free(state); - return -1; - } - - /* Insert into section list. */ - setting->name = NULL; - setting->value = NULL; - setting->next = section->settings; - section->settings = setting; - - /* Copy name of setting. */ - setting->name = malloc(end - s + 1); - if (setting->name == NULL) { - fclose(f); - config_ini_free(state); - return -1; - } - - memcpy(setting->name, s, end - s + 1); - - /* Copy setting value. */ - size_t value_len = strlen(value) + 1; - setting->value = malloc(value_len); - if (setting->value == NULL) { - fclose(f); - config_ini_free(state); - return -1; - } - - memcpy(setting->value, value, value_len); - } - } - - fclose(f); - - return 0; -} - -void -config_ini_free(config_ini_state_t *state) -{ - config_ini_section_t *section = state->sections; - - while (section != NULL) { - config_ini_setting_t *setting = section->settings; - config_ini_section_t *section_prev = section; - - while (setting != NULL) { - config_ini_setting_t *setting_prev = setting; - free(setting->name); - free(setting->value); - setting = setting->next; - free(setting_prev); - } - - free(section->name); - section = section->next; - free(section_prev); - } -} - -config_ini_section_t * -config_ini_get_section(config_ini_state_t *state, const char *name) -{ - config_ini_section_t *section = state->sections; - while (section != NULL) { - if (strcasecmp(section->name, name) == 0) { - return section; - } - section = section->next; - } - - return NULL; -} diff --git a/src/config-ini.h b/src/config-ini.h deleted file mode 100644 index 5cdcc729..00000000 --- a/src/config-ini.h +++ /dev/null @@ -1,49 +0,0 @@ -/* config-ini.h -- INI config file parser header - This file is part of Redshift. - - Redshift 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. - - Redshift 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 Redshift. If not, see . - - Copyright (c) 2010 Jon Lund Steffensen -*/ - -#ifndef REDSHIFT_CONFIG_INI_H -#define REDSHIFT_CONFIG_INI_H - -typedef struct _config_ini_section config_ini_section_t; -typedef struct _config_ini_setting config_ini_setting_t; - -struct _config_ini_setting { - config_ini_setting_t *next; - char *name; - char *value; -}; - -struct _config_ini_section { - config_ini_section_t *next; - char *name; - config_ini_setting_t *settings; -}; - -typedef struct { - config_ini_section_t *sections; -} config_ini_state_t; - - -int config_ini_init(config_ini_state_t *state, const char *filepath); -void config_ini_free(config_ini_state_t *state); - -config_ini_section_t *config_ini_get_section(config_ini_state_t *state, - const char *name); - -#endif /* ! REDSHIFT_CONFIG_INI_H */ diff --git a/src/elektra/redshift-conf.c b/src/elektra/redshift-conf.c new file mode 100644 index 00000000..189e7a69 --- /dev/null +++ b/src/elektra/redshift-conf.c @@ -0,0 +1,756 @@ +// clang-format off + + +// clang-format on +/** + * @file + * + * This file was automatically generated using `kdb gen highlevel`. + * Any changes will be overwritten, when the file is regenerated. + * + * @copyright BSD Zero Clause License + * + * Copyright (c) Elektra Initiative (https://www.libelektra.org) + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "redshift-conf.h" + + + +#include +#include +#include + +#include +#include +#include +#include + +#include + +static KeySet * embeddedSpec (void) +{ + return ksNew (30, + keyNew ("/", KEY_META, "mountpoint", "redshift.ecf", KEY_END), + keyNew ("/adjustment/crtc", KEY_META, "default", "0", KEY_META, "description", "CRTC to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "crtc", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/adjustment/drm/card", KEY_META, "default", "0", KEY_META, "description", "Graphics card to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "drm-card", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/adjustment/method", KEY_META, "check/enum", "#7", KEY_META, "check/enum/#0", "drm", KEY_META, "check/enum/#1", "dummy", KEY_META, "check/enum/#2", "quartz", KEY_META, "check/enum/#3", "randr", KEY_META, "check/enum/#4", "vidmode", KEY_META, "check/enum/#5", "w32gdi", KEY_META, "check/enum/#6", "auto", KEY_META, "check/enum/#7", "list", KEY_META, "default", "auto", KEY_META, "description", "The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section \"Alternative Features\" in file DESIGN in root directory.", KEY_META, "example", "randr", KEY_META, "opt", "m", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "method", KEY_META, "type", "enum", KEY_END), + keyNew ("/adjustment/method/help", KEY_META, "default", "0", KEY_META, "description", "Prints the help of the adjustment methods.", KEY_META, "example", "1", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "help-methods", KEY_META, "type", "boolean", KEY_END), + keyNew ("/adjustment/screen", KEY_META, "default", "0", KEY_META, "description", "X screen to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "screen", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/brightness/day", KEY_META, "check/range", "0-1", KEY_META, "check/type", "float", KEY_META, "default", "1.0", KEY_META, "description", "The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness.", KEY_META, "example", "0.8", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "brightness-day", KEY_META, "type", "float", KEY_END), + keyNew ("/brightness/night", KEY_META, "check/range", "0-1", KEY_META, "check/type", "float", KEY_META, "default", "1.0", KEY_META, "description", "The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness.", KEY_META, "example", "0.8", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "brightness-night", KEY_META, "type", "float", KEY_END), + keyNew ("/fade/fast", KEY_META, "default", "0", KEY_META, "description", "Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant.", KEY_META, "example", "1", KEY_META, "opt", "f", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "fade-fast", KEY_META, "type", "boolean", KEY_END), + keyNew ("/gamma/day", KEY_META, "check/validation", "^([0-9]*[\\.,]\?[0-9]+)(:([0-9]*[\\.,]\?[0-9]+):([0-9]*[\\.,]\?[0-9]+))\?$", KEY_META, "check/validation/message", "The gamma value you provided is in an unsupported format. Supported formats are: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "default", "1.0:1.0:1.0", KEY_META, "description", "The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "example", "0.9", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "gamma-day", KEY_META, "type", "string", KEY_END), + keyNew ("/gamma/night", KEY_META, "check/validation", "^([0-9]*[\\.,]\?[0-9]+)(:([0-9]*[\\.,]\?[0-9]+):([0-9]*[\\.,]\?[0-9]+))\?$", KEY_META, "check/validation/message", "The gamma value you provided is in an unsupported format. Supported formats are: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "default", "1.0:1.0:1.0", KEY_META, "description", "The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "example", "0.9", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "gamma-night", KEY_META, "type", "string", KEY_END), + keyNew ("/gamma/preserve", KEY_META, "default", "1", KEY_META, "description", "Use to preserve existing gamma ramps before applying adjustments.", KEY_META, "example", "0", KEY_META, "opt", "P", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/help", KEY_META, "default", "0", KEY_META, "description", "Show program help.", KEY_META, "example", "1", KEY_META, "opt", "h", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/mode", KEY_META, "check/enum", "#4", KEY_META, "check/enum/#0", "continual", KEY_META, "check/enum/#1", "print", KEY_META, "check/enum/#2", "oneshot", KEY_META, "check/enum/#3", "reset", KEY_META, "check/enum/#4", "oneshotmanual", KEY_META, "default", "continual", KEY_META, "description", "The program mode. \"continual\" will constantly adjust the screen color temperature using the configured \"provider\". \"print\" will just print parameters and exit. \"oneshot\" will set temperature once using the configured \"provider\". \"reset\" will remove any color temperature adjustments then exit. \"oneshotmanual\" will not use any provider to determine if it\'s night or day and set the temperature specified by option \"temp/oneshotmanual\" immediately.", KEY_META, "example", "oneshot", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "mode", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider", KEY_META, "check/enum", "#1", KEY_META, "check/enum/#0", "time", KEY_META, "check/enum/#1", "location", KEY_META, "default", "location", KEY_META, "description", "The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user\'s location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn.", KEY_META, "example", "time", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "provider", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider/location", KEY_META, "check/enum", "#4", KEY_META, "check/enum/#0", "corelocation", KEY_META, "check/enum/#1", "geoclue2", KEY_META, "check/enum/#2", "manual", KEY_META, "check/enum/#3", "auto", KEY_META, "check/enum/#4", "list", KEY_META, "default", "auto", KEY_META, "description", "The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime.", KEY_META, "example", "geoclue2", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "location-provider", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider/location/elevation/high", KEY_META, "default", "3.0", KEY_META, "description", "By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.", KEY_META, "example", "3.5", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "elevation-high", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/elevation/low", KEY_META, "default", "-6.0", KEY_META, "description", "By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.", KEY_META, "example", "-5.0", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "elevation-low", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/help", KEY_META, "default", "0", KEY_META, "description", "Prints the help of the location providers.", KEY_META, "example", "1", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "help-providers", KEY_META, "type", "boolean", KEY_END), + keyNew ("/provider/location/manual/lat", KEY_META, "check/range", "-90.0-90.0", KEY_META, "check/type", "float", KEY_META, "default", "52.520008", KEY_META, "description", "The location latitude. Only applies to location provider \"manual\". Some locations (e.g. mainland USA) require negative values.", KEY_META, "example", "52.520008", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "lat", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/manual/lon", KEY_META, "check/range", "-180.0-180.0", KEY_META, "check/type", "float", KEY_META, "default", "13.404954", KEY_META, "description", "The location longitude. Only applies to location provider \"manual\". Some locations (e.g. parts of Africa) require negative values.", KEY_META, "example", "13.404954", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "lon", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/time/dawn/end", KEY_META, "check/date", "ISO8601", KEY_META, "check/date/format", "timeofday", KEY_META, "default", "06:30", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "07:30", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dawn-end", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dawn/start", KEY_META, "check/date", "ISO8601", KEY_META, "check/date/format", "timeofday", KEY_META, "default", "05:00", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "06:00", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dawn-start", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dusk/end", KEY_META, "check/date", "ISO8601", KEY_META, "check/date/format", "timeofday", KEY_META, "default", "20:30", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "21:30", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dusk-end", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dusk/start", KEY_META, "check/date", "ISO8601", KEY_META, "check/date/format", "timeofday", KEY_META, "default", "19:00", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "20:00", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dusk-start", KEY_META, "type", "string", KEY_END), + keyNew ("/temp/day", KEY_META, "check/range", "1000-25000", KEY_META, "check/type", "unsigned_short", KEY_META, "default", "6500", KEY_META, "description", "The color temperature the screen should have during daytime.", KEY_META, "example", "6500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-day", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/temp/night", KEY_META, "check/range", "1000-25000", KEY_META, "check/type", "unsigned_short", KEY_META, "default", "4500", KEY_META, "description", "The color temperature the screen should have during nighttime.", KEY_META, "example", "4500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-night", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/temp/oneshotmanual", KEY_META, "check/range", "1000-25000", KEY_META, "check/type", "unsigned_short", KEY_META, "default", "6500", KEY_META, "description", "The color temperature the screen should have when oneshotmanual mode is used.", KEY_META, "example", "6500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-oneshotmanual", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/verbose", KEY_META, "default", "0", KEY_META, "description", "Verbose output.", KEY_META, "example", "1", KEY_META, "opt", "v", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/version", KEY_META, "default", "0", KEY_META, "description", "Show program version.", KEY_META, "example", "1", KEY_META, "opt", "V", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + KS_END); +; +} + +static const char * helpFallback = "Usage: redshift [OPTION...]\n\nOPTIONS\n --help Print this help message\n , --crtc=ARG CRTC to apply adjustments to.\n , --drm-card=ARG Graphics card to apply adjustments to.\n -m ARG, --method=ARG The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section \"Alternative Features\" in file DESIGN in root directory.\n , --help-methods Prints the help of the adjustment methods.\n , --screen=ARG X screen to apply adjustments to.\n , --brightness-day=ARG The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness.\n , --brightness-night=ARG The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness.\n -f, --fade-fast Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant.\n , --gamma-day=ARG The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).\n , --gamma-night=ARG The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).\n -P Use to preserve existing gamma ramps before applying adjustments.\n -h Show program help.\n , --mode=ARG The program mode. \"continual\" will constantly adjust the screen color temperature using the configured \"provider\". \"print\" will just print parameters and exit. \"oneshot\" will set temperature once using the configured \"provider\". \"reset\" will remove any color temperature adjustments then exit. \"oneshotmanual\" will not use any provider to determine if it\'s night or day and set the temperature specified by option \"temp/oneshotmanual\" immediately.\n , --provider=ARG The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user\'s location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn.\n , --location-provider=ARG The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime.\n , --elevation-high=ARG By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.\n , --elevation-low=ARG By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.\n , --help-providers Prints the help of the location providers.\n , --lat=ARG The location latitude. Only applies to location provider \"manual\". Some locations (e.g. mainland USA) require negative values.\n , --lon=ARG The location longitude. Only applies to location provider \"manual\". Some locations (e.g. parts of Africa) require negative values.\n , --time-dawn-end=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dawn-start=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dusk-end=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dusk-start=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --temp-day=ARG The color temperature the screen should have during daytime.\n , --temp-night=ARG The color temperature the screen should have during nighttime.\n , --temp-oneshotmanual=ARG The color temperature the screen should have when oneshotmanual mode is used.\n -v Verbose output.\n -V Show program version.\n"; + +static int isHelpMode (int argc, const char * const * argv) +{ + for (int i = 0; i < argc; ++i) + { + if (strcmp (argv[i], "--help") == 0) + { + return 1; + } + } + + return 0; +} + + + +/** + * Initializes an instance of Elektra for the application '/sw/jonls/redshift/#0/current'. + * + * This can be invoked as many times as you want, however it is not a cheap operation, + * so you should try to reuse the Elektra handle as much as possible. + * + * @param elektra A reference to where the Elektra instance shall be stored. + * Has to be disposed of with elektraClose(). + * @param error A reference to an ElektraError pointer. Will be passed to elektraOpen(). + * + * @retval 0 on success, @p elektra will contain a new Elektra instance coming from elektraOpen(), + * @p error will be unchanged + * @retval -1 on error, @p elektra will be unchanged, @p error will be set + * @retval 1 help mode, '--help' was specified call printHelpMessage to display + * the help message. @p elektra will contain a new Elektra instance. It has to be passed + * to printHelpMessage. You also need to elektraClose() it. + * @p error will be unchanged + * + * @see elektraOpen + */// +int loadConfiguration (Elektra ** elektra, + int argc, const char * const * argv, const char * const * envp, + ElektraError ** error) +{ + KeySet * defaults = embeddedSpec (); + + + KeySet * contract = ksNew (4, + keyNew ("system:/elektra/contract/highlevel/check/spec/mounted", KEY_VALUE, "1", KEY_END), + keyNew ("system:/elektra/contract/highlevel/check/spec/token", KEY_VALUE, "b3d73b67ece57190da2094a91b17bcbf3a37fb09923ddbf60db79654722aab1f", KEY_END), + keyNew ("system:/elektra/contract/highlevel/helpmode/ignore/require", KEY_VALUE, "1", KEY_END), + keyNew ("system:/elektra/contract/mountglobal/gopts", KEY_END), + KS_END); +; + Key * parentKey = keyNew ("/sw/jonls/redshift/#0/current", KEY_END); + + elektraGOptsContract (contract, argc, argv, envp, parentKey, NULL); + + + keyDel (parentKey); + + Elektra * e = elektraOpen ("/sw/jonls/redshift/#0/current", defaults, contract, error); + + if (defaults != NULL) + { + ksDel (defaults); + } + + if (contract != NULL) + { + ksDel (contract); + } + + if (e == NULL) + { + *elektra = NULL; + if (isHelpMode (argc, argv)) + { + elektraErrorReset (error); + return 1; + } + + + return -1; + } + + *elektra = e; + return elektraHelpKey (e) != NULL && strcmp (keyString (elektraHelpKey (e)), "1") == 0 ? 1 : 0; +} + +/** + * Checks whether specload mode was invoked and if so, sends the specification over stdout + * in the format expected by specload. + * + * You MUST not output anything to stdout before invoking this function. Ideally invoking this + * is the first thing you do in your main()-function. + * + * This function will ONLY RETURN, if specload mode was NOT invoked. Otherwise it will call `exit()`. + * + * @param argc pass the value of argc from main + * @param argv pass the value of argv from main + */ +void exitForSpecload (int argc, const char * const * argv) +{ + if (argc != 2 || strcmp (argv[1], "--elektra-spec") != 0) + { + return; + } + + KeySet * spec = embeddedSpec (); + + Key * parentKey = keyNew ("spec:/sw/jonls/redshift/#0/current", KEY_META, "system:/elektra/quickdump/noparent", "", KEY_END); + + KeySet * specloadConf = ksNew (1, keyNew ("system:/sendspec", KEY_END), KS_END); + ElektraInvokeHandle * specload = elektraInvokeOpen ("specload", specloadConf, parentKey); + + int result = elektraInvoke2Args (specload, "sendspec", spec, parentKey); + + elektraInvokeClose (specload, parentKey); + keyDel (parentKey); + ksDel (specloadConf); + ksDel (spec); + + exit (result == ELEKTRA_PLUGIN_STATUS_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE); +} + + +/** + * Outputs the help message to stdout + * + * @param elektra The Elektra instance produced by loadConfiguration. + * @param usage If this is not NULL, it will be used instead of the default usage line. + * @param prefix If this is not NULL, it will be inserted between the usage line and the options list. + */// +void printHelpMessage (Elektra * elektra, const char * usage, const char * prefix) +{ + if (elektra == NULL) + { + printf ("%s", helpFallback); + return; + } + + Key * helpKey = elektraHelpKey (elektra); + if (helpKey == NULL) + { + return; + } + + char * help = elektraGetOptsHelpMessage (helpKey, usage, prefix); + printf ("%s", help); + elektraFree (help); +} + + + +// clang-format off + +// clang-format on + +// ------------------------- +// Enum conversion functions +// ------------------------- + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + + if (strcmp (string, "drm") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM; + return 1; + } + if (strcmp (string, "dummy") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY; + return 1; + } + if (strcmp (string, "quartz") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ; + return 1; + } + if (strcmp (string, "randr") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR; + return 1; + } + if (strcmp (string, "vidmode") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE; + return 1; + } + if (strcmp (string, "w32gdi") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI; + return 1; + } + if (strcmp (string, "auto") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO; + return 1; + } + if (strcmp (string, "list") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST; + return 1; + } + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + switch (value) + { + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM: + return elektraStrDup ("drm"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY: + return elektraStrDup ("dummy"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ: + return elektraStrDup ("quartz"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR: + return elektraStrDup ("randr"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE: + return elektraStrDup ("vidmode"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI: + return elektraStrDup ("w32gdi"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO: + return elektraStrDup ("auto"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST: + return elektraStrDup ("list"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + switch (value) + { + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM: + return "drm"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY: + return "dummy"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ: + return "quartz"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR: + return "randr"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE: + return "vidmode"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI: + return "w32gdi"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO: + return "auto"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST: + return "list"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumMode, EnumMode) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + + if (strcmp (string, "continual") == 0) + { + *variable = ELEKTRA_ENUM_MODE_CONTINUAL; + return 1; + } + if (strcmp (string, "print") == 0) + { + *variable = ELEKTRA_ENUM_MODE_PRINT; + return 1; + } + if (strcmp (string, "oneshot") == 0) + { + *variable = ELEKTRA_ENUM_MODE_ONESHOT; + return 1; + } + if (strcmp (string, "reset") == 0) + { + *variable = ELEKTRA_ENUM_MODE_RESET; + return 1; + } + if (strcmp (string, "oneshotmanual") == 0) + { + *variable = ELEKTRA_ENUM_MODE_ONESHOTMANUAL; + return 1; + } + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumMode, EnumMode) +{ + switch (value) + { + case ELEKTRA_ENUM_MODE_CONTINUAL: + return elektraStrDup ("continual"); + case ELEKTRA_ENUM_MODE_PRINT: + return elektraStrDup ("print"); + case ELEKTRA_ENUM_MODE_ONESHOT: + return elektraStrDup ("oneshot"); + case ELEKTRA_ENUM_MODE_RESET: + return elektraStrDup ("reset"); + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: + return elektraStrDup ("oneshotmanual"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumMode, EnumMode) +{ + switch (value) + { + case ELEKTRA_ENUM_MODE_CONTINUAL: + return "continual"; + case ELEKTRA_ENUM_MODE_PRINT: + return "print"; + case ELEKTRA_ENUM_MODE_ONESHOT: + return "oneshot"; + case ELEKTRA_ENUM_MODE_RESET: + return "reset"; + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: + return "oneshotmanual"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + switch (string[0]) +{ +case 'l': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION; +return 1; +case 't': +*variable = ELEKTRA_ENUM_PROVIDER_TIME; +return 1; +} + + + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_TIME: + return elektraStrDup ("time"); + case ELEKTRA_ENUM_PROVIDER_LOCATION: + return elektraStrDup ("location"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_TIME: + return "time"; + case ELEKTRA_ENUM_PROVIDER_LOCATION: + return "location"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + switch (string[0]) +{ +case 'a': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO; +return 1; +case 'c': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION; +return 1; +case 'g': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2; +return 1; +case 'l': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_LIST; +return 1; +case 'm': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL; +return 1; +} + + + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION: + return elektraStrDup ("corelocation"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2: + return elektraStrDup ("geoclue2"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL: + return elektraStrDup ("manual"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO: + return elektraStrDup ("auto"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_LIST: + return elektraStrDup ("list"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION: + return "corelocation"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2: + return "geoclue2"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL: + return "manual"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO: + return "auto"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_LIST: + return "list"; + } + + // should be unreachable + return ""; +} + +// ------------------------- +// Enum accessor functions +// ------------------------- + +ELEKTRA_GET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + ElektraEnumAdjustmentMethod result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumAdjustmentMethod) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumAdjustmentMethod) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + ElektraEnumAdjustmentMethod result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumAdjustmentMethod) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumAdjustmentMethod) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + char * string = ELEKTRA_TO_STRING (EnumAdjustmentMethod) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + char * string = ELEKTRA_TO_STRING (EnumAdjustmentMethod) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumMode, EnumMode) +{ + ElektraEnumMode result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumMode) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumMode) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode) +{ + ElektraEnumMode result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumMode) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumMode) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumMode, EnumMode) +{ + char * string = ELEKTRA_TO_STRING (EnumMode) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode) +{ + char * string = ELEKTRA_TO_STRING (EnumMode) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + ElektraEnumProvider result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProvider) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProvider) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + ElektraEnumProvider result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProvider) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProvider) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + char * string = ELEKTRA_TO_STRING (EnumProvider) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + char * string = ELEKTRA_TO_STRING (EnumProvider) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + ElektraEnumProviderLocation result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProviderLocation) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProviderLocation) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + ElektraEnumProviderLocation result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProviderLocation) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProviderLocation) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + char * string = ELEKTRA_TO_STRING (EnumProviderLocation) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + char * string = ELEKTRA_TO_STRING (EnumProviderLocation) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + + +// clang-format off + +// clang-format on + +// ------------------------- +// Union accessor functions +// ------------------------- + + + + +// clang-format off + +// clang-format on + +// ------------------------- +// Struct accessor functions +// ------------------------- + + + diff --git a/src/elektra/redshift-conf.h b/src/elektra/redshift-conf.h new file mode 100644 index 00000000..aea81ddd --- /dev/null +++ b/src/elektra/redshift-conf.h @@ -0,0 +1,1507 @@ +// clang-format off + + +// clang-format on +/** + * @file + * + * This file was automatically generated using `kdb gen highlevel`. + * Any changes will be overwritten, when the file is regenerated. + * + * @copyright BSD Zero Clause License + * + * Copyright (c) Elektra Initiative (https://www.libelektra.org) + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef REDSHIFT_CONF_H +#define REDSHIFT_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include + + + + + +// clang-format off + +// clang-format on + +typedef enum +{ + ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM = 0, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY = 1, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ = 2, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR = 3, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE = 4, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI = 5, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO = 6, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST = 7, +} ElektraEnumAdjustmentMethod; + +typedef enum +{ + ELEKTRA_ENUM_MODE_CONTINUAL = 0, + ELEKTRA_ENUM_MODE_PRINT = 1, + ELEKTRA_ENUM_MODE_ONESHOT = 2, + ELEKTRA_ENUM_MODE_RESET = 3, + ELEKTRA_ENUM_MODE_ONESHOTMANUAL = 4, +} ElektraEnumMode; + +typedef enum +{ + ELEKTRA_ENUM_PROVIDER_TIME = 0, + ELEKTRA_ENUM_PROVIDER_LOCATION = 1, +} ElektraEnumProvider; + +typedef enum +{ + ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION = 0, + ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2 = 1, + ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL = 2, + ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO = 3, + ELEKTRA_ENUM_PROVIDER_LOCATION_LIST = 4, +} ElektraEnumProviderLocation; + + +#define ELEKTRA_TO_CONST_STRING(typeName) ELEKTRA_CONCAT (ELEKTRA_CONCAT (elektra, typeName), ToConstString) +#define ELEKTRA_TO_CONST_STRING_SIGNATURE(cType, typeName) const char * ELEKTRA_TO_CONST_STRING (typeName) (cType value) + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); + +ELEKTRA_GET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_SET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumMode, EnumMode); + +ELEKTRA_GET_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_SET_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider); + +ELEKTRA_GET_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_SET_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); + +ELEKTRA_GET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_SET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); + + + +// clang-format off + +// clang-format on + +#define ELEKTRA_UNION_FREE(typeName) ELEKTRA_CONCAT (elektraFree, typeName) +#define ELEKTRA_UNION_FREE_SIGNATURE(cType, typeName, discrType) void ELEKTRA_UNION_FREE (typeName) (cType * ptr, discrType discriminator) + +#define ELEKTRA_UNION_GET_SIGNATURE(cType, typeName, discrType) \ + cType ELEKTRA_GET (typeName) (Elektra * elektra, const char * keyname, discrType discriminator) +#define ELEKTRA_UNION_GET_ARRAY_ELEMENT_SIGNATURE(cType, typeName, discrType) \ + cType ELEKTRA_GET_ARRAY_ELEMENT (typeName) (Elektra * elektra, const char * keyname, kdb_long_long_t index, discrType discriminator) +#define ELEKTRA_UNION_SET_SIGNATURE(cType, typeName, discrType) \ + void ELEKTRA_SET (typeName) (Elektra * elektra, const char * keyname, cType value, discrType discriminator, ElektraError ** error) +#define ELEKTRA_UNION_SET_ARRAY_ELEMENT_SIGNATURE(cType, typeName, discrType) \ + void ELEKTRA_SET_ARRAY_ELEMENT (typeName) (Elektra * elektra, const char * keyname, kdb_long_long_t index, cType value, \ + discrType discriminator, ElektraError ** error) + + + + + + +// clang-format off + +// clang-format on + +#define ELEKTRA_STRUCT_FREE(typeName) ELEKTRA_CONCAT (elektraFree, typeName) +#define ELEKTRA_STRUCT_FREE_SIGNATURE(cType, typeName) void ELEKTRA_STRUCT_FREE (typeName) (cType * ptr) + + + + + + +// clang-format off + +// clang-format on + +// clang-format off + +/** +* Tag name for 'adjustment/crtc' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_CRTC AdjustmentCrtc + +/** +* Tag name for 'adjustment/drm/card' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_DRM_CARD AdjustmentDrmCard + +/** +* Tag name for 'adjustment/method' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_METHOD AdjustmentMethod + +/** +* Tag name for 'adjustment/method/help' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP AdjustmentMethodHelp + +/** +* Tag name for 'adjustment/screen' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_SCREEN AdjustmentScreen + +/** +* Tag name for 'brightness/day' +* +*/// +#define ELEKTRA_TAG_BRIGHTNESS_DAY BrightnessDay + +/** +* Tag name for 'brightness/night' +* +*/// +#define ELEKTRA_TAG_BRIGHTNESS_NIGHT BrightnessNight + +/** +* Tag name for 'fade/fast' +* +*/// +#define ELEKTRA_TAG_FADE_FAST FadeFast + +/** +* Tag name for 'gamma/day' +* +*/// +#define ELEKTRA_TAG_GAMMA_DAY GammaDay + +/** +* Tag name for 'gamma/night' +* +*/// +#define ELEKTRA_TAG_GAMMA_NIGHT GammaNight + +/** +* Tag name for 'gamma/preserve' +* +*/// +#define ELEKTRA_TAG_GAMMA_PRESERVE GammaPreserve + +/** +* Tag name for 'help' +* +*/// +#define ELEKTRA_TAG_HELP Help + +/** +* Tag name for 'mode' +* +*/// +#define ELEKTRA_TAG_MODE Mode + +/** +* Tag name for 'provider' +* +*/// +#define ELEKTRA_TAG_PROVIDER Provider + +/** +* Tag name for 'provider/location' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION ProviderLocation + +/** +* Tag name for 'provider/location/elevation/high' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH ProviderLocationElevationHigh + +/** +* Tag name for 'provider/location/elevation/low' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW ProviderLocationElevationLow + +/** +* Tag name for 'provider/location/help' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_HELP ProviderLocationHelp + +/** +* Tag name for 'provider/location/manual/lat' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT ProviderLocationManualLat + +/** +* Tag name for 'provider/location/manual/lon' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON ProviderLocationManualLon + +/** +* Tag name for 'provider/time/dawn/end' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DAWN_END ProviderTimeDawnEnd + +/** +* Tag name for 'provider/time/dawn/start' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DAWN_START ProviderTimeDawnStart + +/** +* Tag name for 'provider/time/dusk/end' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DUSK_END ProviderTimeDuskEnd + +/** +* Tag name for 'provider/time/dusk/start' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DUSK_START ProviderTimeDuskStart + +/** +* Tag name for 'temp/day' +* +*/// +#define ELEKTRA_TAG_TEMP_DAY TempDay + +/** +* Tag name for 'temp/night' +* +*/// +#define ELEKTRA_TAG_TEMP_NIGHT TempNight + +/** +* Tag name for 'temp/oneshotmanual' +* +*/// +#define ELEKTRA_TAG_TEMP_ONESHOTMANUAL TempOneshotmanual + +/** +* Tag name for 'verbose' +* +*/// +#define ELEKTRA_TAG_VERBOSE Verbose + +/** +* Tag name for 'version' +* +*/// +#define ELEKTRA_TAG_VERSION Version +// clang-format on + + +// clang-format off + +// clang-format on + +// local helper macros to determine the length of a 64 bit integer +#define elektra_len19(x) ((x) < 10000000000000000000ULL ? 19 : 20) +#define elektra_len18(x) ((x) < 1000000000000000000ULL ? 18 : elektra_len19 (x)) +#define elektra_len17(x) ((x) < 100000000000000000ULL ? 17 : elektra_len18 (x)) +#define elektra_len16(x) ((x) < 10000000000000000ULL ? 16 : elektra_len17 (x)) +#define elektra_len15(x) ((x) < 1000000000000000ULL ? 15 : elektra_len16 (x)) +#define elektra_len14(x) ((x) < 100000000000000ULL ? 14 : elektra_len15 (x)) +#define elektra_len13(x) ((x) < 10000000000000ULL ? 13 : elektra_len14 (x)) +#define elektra_len12(x) ((x) < 1000000000000ULL ? 12 : elektra_len13 (x)) +#define elektra_len11(x) ((x) < 100000000000ULL ? 11 : elektra_len12 (x)) +#define elektra_len10(x) ((x) < 10000000000ULL ? 10 : elektra_len11 (x)) +#define elektra_len09(x) ((x) < 1000000000ULL ? 9 : elektra_len10 (x)) +#define elektra_len08(x) ((x) < 100000000ULL ? 8 : elektra_len09 (x)) +#define elektra_len07(x) ((x) < 10000000ULL ? 7 : elektra_len08 (x)) +#define elektra_len06(x) ((x) < 1000000ULL ? 6 : elektra_len07 (x)) +#define elektra_len05(x) ((x) < 100000ULL ? 5 : elektra_len06 (x)) +#define elektra_len04(x) ((x) < 10000ULL ? 4 : elektra_len05 (x)) +#define elektra_len03(x) ((x) < 1000ULL ? 3 : elektra_len04 (x)) +#define elektra_len02(x) ((x) < 100ULL ? 2 : elektra_len03 (x)) +#define elektra_len01(x) ((x) < 10ULL ? 1 : elektra_len02 (x)) +#define elektra_len00(x) ((x) < 0ULL ? 0 : elektra_len01 (x)) +#define elektra_len(x) elektra_len00 (x) + +#define ELEKTRA_SIZE(tagName) ELEKTRA_CONCAT (elektraSize, tagName) + + + + +/** + * Get the value of key 'adjustment/crtc' (tag #ELEKTRA_TAG_ADJUSTMENT_CRTC). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/crtc'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_CRTC) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/crtc"); +} + + +/** + * Set the value of key 'adjustment/crtc' (tag #ELEKTRA_TAG_ADJUSTMENT_CRTC). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/crtc'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_CRTC) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/crtc", value, error); +} + + + + +/** + * Get the value of key 'adjustment/drm/card' (tag #ELEKTRA_TAG_ADJUSTMENT_DRM_CARD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/drm/card'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_DRM_CARD) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/drm/card"); +} + + +/** + * Set the value of key 'adjustment/drm/card' (tag #ELEKTRA_TAG_ADJUSTMENT_DRM_CARD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/drm/card'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_DRM_CARD) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/drm/card", value, error); +} + + + + +/** + * Get the value of key 'adjustment/method' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/method'. + + */// +static inline ElektraEnumAdjustmentMethod ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_METHOD) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumAdjustmentMethod) (elektra, "adjustment/method"); +} + + +/** + * Set the value of key 'adjustment/method' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/method'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_METHOD) (Elektra * elektra, + ElektraEnumAdjustmentMethod value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumAdjustmentMethod) (elektra, "adjustment/method", value, error); +} + + + + +/** + * Get the value of key 'adjustment/method/help' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/method/help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "adjustment/method/help"); +} + + +/** + * Set the value of key 'adjustment/method/help' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/method/help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "adjustment/method/help", value, error); +} + + + + +/** + * Get the value of key 'adjustment/screen' (tag #ELEKTRA_TAG_ADJUSTMENT_SCREEN). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/screen'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_SCREEN) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/screen"); +} + + +/** + * Set the value of key 'adjustment/screen' (tag #ELEKTRA_TAG_ADJUSTMENT_SCREEN). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/screen'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_SCREEN) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/screen", value, error); +} + + + + +/** + * Get the value of key 'brightness/day' (tag #ELEKTRA_TAG_BRIGHTNESS_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'brightness/day'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_BRIGHTNESS_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "brightness/day"); +} + + +/** + * Set the value of key 'brightness/day' (tag #ELEKTRA_TAG_BRIGHTNESS_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'brightness/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_BRIGHTNESS_DAY) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "brightness/day", value, error); +} + + + + +/** + * Get the value of key 'brightness/night' (tag #ELEKTRA_TAG_BRIGHTNESS_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'brightness/night'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_BRIGHTNESS_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "brightness/night"); +} + + +/** + * Set the value of key 'brightness/night' (tag #ELEKTRA_TAG_BRIGHTNESS_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'brightness/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_BRIGHTNESS_NIGHT) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "brightness/night", value, error); +} + + + + +/** + * Get the value of key 'fade/fast' (tag #ELEKTRA_TAG_FADE_FAST). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'fade/fast'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_FADE_FAST) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "fade/fast"); +} + + +/** + * Set the value of key 'fade/fast' (tag #ELEKTRA_TAG_FADE_FAST). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'fade/fast'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_FADE_FAST) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "fade/fast", value, error); +} + + + + +/** + * Get the value of key 'gamma/day' (tag #ELEKTRA_TAG_GAMMA_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/day'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_GAMMA_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "gamma/day"); +} + + +/** + * Set the value of key 'gamma/day' (tag #ELEKTRA_TAG_GAMMA_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_DAY) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "gamma/day", value, error); +} + + + + +/** + * Get the value of key 'gamma/night' (tag #ELEKTRA_TAG_GAMMA_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/night'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_GAMMA_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "gamma/night"); +} + + +/** + * Set the value of key 'gamma/night' (tag #ELEKTRA_TAG_GAMMA_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_NIGHT) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "gamma/night", value, error); +} + + + + +/** + * Get the value of key 'gamma/preserve' (tag #ELEKTRA_TAG_GAMMA_PRESERVE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/preserve'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_GAMMA_PRESERVE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "gamma/preserve"); +} + + +/** + * Set the value of key 'gamma/preserve' (tag #ELEKTRA_TAG_GAMMA_PRESERVE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/preserve'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_PRESERVE) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "gamma/preserve", value, error); +} + + + + +/** + * Get the value of key 'help' (tag #ELEKTRA_TAG_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "help"); +} + + +/** + * Set the value of key 'help' (tag #ELEKTRA_TAG_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "help", value, error); +} + + + + +/** + * Get the value of key 'mode' (tag #ELEKTRA_TAG_MODE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'mode'. + + */// +static inline ElektraEnumMode ELEKTRA_GET (ELEKTRA_TAG_MODE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumMode) (elektra, "mode"); +} + + +/** + * Set the value of key 'mode' (tag #ELEKTRA_TAG_MODE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'mode'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_MODE) (Elektra * elektra, + ElektraEnumMode value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumMode) (elektra, "mode", value, error); +} + + + + +/** + * Get the value of key 'provider' (tag #ELEKTRA_TAG_PROVIDER). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider'. + + */// +static inline ElektraEnumProvider ELEKTRA_GET (ELEKTRA_TAG_PROVIDER) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumProvider) (elektra, "provider"); +} + + +/** + * Set the value of key 'provider' (tag #ELEKTRA_TAG_PROVIDER). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER) (Elektra * elektra, + ElektraEnumProvider value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumProvider) (elektra, "provider", value, error); +} + + + + +/** + * Get the value of key 'provider/location' (tag #ELEKTRA_TAG_PROVIDER_LOCATION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location'. + + */// +static inline ElektraEnumProviderLocation ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumProviderLocation) (elektra, "provider/location"); +} + + +/** + * Set the value of key 'provider/location' (tag #ELEKTRA_TAG_PROVIDER_LOCATION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION) (Elektra * elektra, + ElektraEnumProviderLocation value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumProviderLocation) (elektra, "provider/location", value, error); +} + + + + +/** + * Get the value of key 'provider/location/elevation/high' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/elevation/high'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/elevation/high"); +} + + +/** + * Set the value of key 'provider/location/elevation/high' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/elevation/high'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/elevation/high", value, error); +} + + + + +/** + * Get the value of key 'provider/location/elevation/low' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/elevation/low'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/elevation/low"); +} + + +/** + * Set the value of key 'provider/location/elevation/low' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/elevation/low'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/elevation/low", value, error); +} + + + + +/** + * Get the value of key 'provider/location/help' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "provider/location/help"); +} + + +/** + * Set the value of key 'provider/location/help' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "provider/location/help", value, error); +} + + + + +/** + * Get the value of key 'provider/location/manual/lat' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/manual/lat'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/manual/lat"); +} + + +/** + * Set the value of key 'provider/location/manual/lat' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/manual/lat'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/manual/lat", value, error); +} + + + + +/** + * Get the value of key 'provider/location/manual/lon' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/manual/lon'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/manual/lon"); +} + + +/** + * Set the value of key 'provider/location/manual/lon' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/manual/lon'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/manual/lon", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dawn/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dawn/end'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_END) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dawn/end"); +} + + +/** + * Set the value of key 'provider/time/dawn/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dawn/end'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_END) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dawn/end", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dawn/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dawn/start'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_START) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dawn/start"); +} + + +/** + * Set the value of key 'provider/time/dawn/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dawn/start'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_START) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dawn/start", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dusk/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dusk/end'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_END) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dusk/end"); +} + + +/** + * Set the value of key 'provider/time/dusk/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dusk/end'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_END) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dusk/end", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dusk/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dusk/start'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_START) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dusk/start"); +} + + +/** + * Set the value of key 'provider/time/dusk/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dusk/start'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_START) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dusk/start", value, error); +} + + + + +/** + * Get the value of key 'temp/day' (tag #ELEKTRA_TAG_TEMP_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/day'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/day"); +} + + +/** + * Set the value of key 'temp/day' (tag #ELEKTRA_TAG_TEMP_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_DAY) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/day", value, error); +} + + + + +/** + * Get the value of key 'temp/night' (tag #ELEKTRA_TAG_TEMP_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/night'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/night"); +} + + +/** + * Set the value of key 'temp/night' (tag #ELEKTRA_TAG_TEMP_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_NIGHT) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/night", value, error); +} + + + + +/** + * Get the value of key 'temp/oneshotmanual' (tag #ELEKTRA_TAG_TEMP_ONESHOTMANUAL). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/oneshotmanual'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_ONESHOTMANUAL) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/oneshotmanual"); +} + + +/** + * Set the value of key 'temp/oneshotmanual' (tag #ELEKTRA_TAG_TEMP_ONESHOTMANUAL). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/oneshotmanual'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_ONESHOTMANUAL) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/oneshotmanual", value, error); +} + + + + +/** + * Get the value of key 'verbose' (tag #ELEKTRA_TAG_VERBOSE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'verbose'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_VERBOSE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "verbose"); +} + + +/** + * Set the value of key 'verbose' (tag #ELEKTRA_TAG_VERBOSE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'verbose'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_VERBOSE) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "verbose", value, error); +} + + + + +/** + * Get the value of key 'version' (tag #ELEKTRA_TAG_VERSION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'version'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_VERSION) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "version"); +} + + +/** + * Set the value of key 'version' (tag #ELEKTRA_TAG_VERSION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'version'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_VERSION) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "version", value, error); +} + + +#undef elektra_len19 +#undef elektra_len18 +#undef elektra_len17 +#undef elektra_len16 +#undef elektra_len15 +#undef elektra_len14 +#undef elektra_len13 +#undef elektra_len12 +#undef elektra_len11 +#undef elektra_len10 +#undef elektra_len09 +#undef elektra_len08 +#undef elektra_len07 +#undef elektra_len06 +#undef elektra_len05 +#undef elektra_len04 +#undef elektra_len03 +#undef elektra_len02 +#undef elektra_len01 +#undef elektra_len00 +#undef elektra_len + + +int loadConfiguration (Elektra ** elektra, + int argc, const char * const * argv, const char * const * envp, + + ElektraError ** error); +void printHelpMessage (Elektra * elektra, const char * usage, const char * prefix); +void exitForSpecload (int argc, const char * const * argv); + + + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The tag to look up. + * + * @return The value stored at the given key. + * The lifetime of returned pointers is documented in the ELEKTRA_GET(*) functions above. + */// +#define elektraGet(elektra, tag) ELEKTRA_GET (tag) (elektra) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The tag to look up. + * @param ... Variable arguments depending on the given tag. + * + * @return The value stored at the given key. + * The lifetime of returned pointers is documented in the ELEKTRA_GET(*) functions above. + */// +#define elektraGetV(elektra, tag, ...) ELEKTRA_GET (tag) (elektra, __VA_ARGS__) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param result Points to the struct into which results will be stored. + * The lifetime of pointers in this struct is documented in the ELEKTRA_GET(*) functions above. + * @param tag The tag to look up. + */// +#define elektraFillStruct(elektra, result, tag) ELEKTRA_GET (tag) (elektra, result) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param result Points to the struct into which results will be stored. + * The lifetime of pointers in this struct is documented in the ELEKTRA_GET(*) functions above. + * @param tag The tag to look up. + * @param ... Variable arguments depending on the given tag. + */// +#define elektraFillStructV(elektra, result, tag, ...) ELEKTRA_GET (tag) (elektra, result, __VA_ARGS__) + + +/** + * @param elektra The elektra instance initialized with the loadConfiguration(). + * @param tag The tag to write to. + * @param value The new value. + * @param error Pass a reference to an ElektraError pointer. + */// +#define elektraSet(elektra, tag, value, error) ELEKTRA_SET (tag) (elektra, value, error) + + +/** + * @param elektra The elektra instance initialized with the loadConfiguration(). + * @param tag The tag to write to. + * @param value The new value. + * @param error Pass a reference to an ElektraError pointer. + * @param ... Variable arguments depending on the given tag. + */// +#define elektraSetV(elektra, tag, value, error, ...) ELEKTRA_SET (tag) (elektra, value, __VA_ARGS__, error) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The array tag to look up. + * + * @return The size of the array below the given key. + */// +#define elektraSize(elektra, tag) ELEKTRA_SIZE (tag) (elektra) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The array tag to look up. + * @param ... Variable arguments depending on the given tag. + * + * @return The size of the array below the given key. + */// +#define elektraSizeV(elektra, tag, ...) ELEKTRA_SIZE (tag) (elektra, __VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif // REDSHIFT_CONF_H diff --git a/src/elektra/redshift-conf.mount.sh b/src/elektra/redshift-conf.mount.sh new file mode 100644 index 00000000..944710bb --- /dev/null +++ b/src/elektra/redshift-conf.mount.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ -z "$APP_PATH" ]; then + # TODO: set APP_PATH to the installed path of your application + APP_PATH='/usr/local/bin/redshift' +fi + +if ! [ -f "$APP_PATH" ]; then + echo "ERROR: APP_PATH points to non-existent file" 1>&2 + exit 1 +fi + +error_other_mp() { + echo "ERROR: another mountpoint already exists on spec:/sw/jonls/redshift/#0/current. Please umount first." 1>&2 + exit 1 +} + +if kdb mount -13 | grep -Fxq 'spec:/sw/jonls/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'redshift.overlay.spec.eqd on spec:/sw/jonls/redshift/#0/current with name spec:/sw/jonls/redshift/#0/current'; then + error_other_mp + fi + + MP=$(echo "spec:/sw/jonls/redshift/#0/current" | sed 's:\\:\\\\:g' | sed 's:/:\\/:g') + if [ -n "$(kdb get "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/file")" ]; then + error_other_mp + fi + if [ "$(kdb get "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/app")" != "$APP_PATH" ]; then + error_other_mp + fi + if [ -n "$(kdb ls "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/app/args")" ]; then + error_other_mp + fi +else + sudo kdb mount -R noresolver "redshift.overlay.spec.eqd" "spec:/sw/jonls/redshift/#0/current" specload "app=$APP_PATH" +fi + +if kdb mount -13 | grep -Fxq '/sw/jonls/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'redshift.ecf on /sw/jonls/redshift/#0/current with name /sw/jonls/redshift/#0/current'; then + echo "ERROR: another mountpoint already exists on /sw/jonls/redshift/#0/current. Please umount first." 1>&2 + exit 1 + fi +else + sudo kdb spec-mount '/sw/jonls/redshift/#0/current' +fi diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni new file mode 100644 index 00000000..aeed5be5 --- /dev/null +++ b/src/elektra/redshift.ni @@ -0,0 +1,316 @@ +; Elektra specification file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) +; +; IMPORTANT: Make sure to execute `kdb gen` after changes to this file! +; See section "Updating the Elektra specification file" in CONTRIBUTING.md for details. +; +; A specification file describes: +; 1. which configuration settings an application supports, +; 2. their defaults and +; 3. their associated CLI options. +; It also "(...) defines how the configuration settings should be validated" +; (source: https://www.libelektra.org/tutorials/validate-configuration) +; +; For details on specification files see https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) + +; Redshift uses no environment variables. +; Note: When renaming enum values, make sure to also update any code that uses them. +; (e.g. the string values of enum [provider/location] are used in options.c). + +[] +mountpoint = redshift.ecf + +[mode] +type = enum +check/enum = #4 +check/enum/#0 = continual +check/enum/#1 = print +check/enum/#2 = oneshot +check/enum/#3 = reset +check/enum/#4 = oneshotmanual +description = The program mode. "continual" will constantly adjust the screen color temperature using the configured "provider". "print" will just print parameters and exit. "oneshot" will set temperature once using the configured "provider". "reset" will remove any color temperature adjustments then exit. "oneshotmanual" will not use any provider to determine if it's night or day and set the temperature specified by option "temp/oneshotmanual" immediately. +default = continual +example = oneshot +opt/long = mode +opt/arg = required + +[verbose] +type = boolean +description = Verbose output. +default = 0 +example = 1 +opt = v +opt/arg = none + +[version] +type = boolean +description = Show program version. +default = 0 +example = 1 +opt = V +opt/arg = none + +; HL API by default only prints help, when long CLI option "--help" is given. For redshift we also want "-h" to work. +[help] +type = boolean +description = Show program help. +default = 0 +example = 1 +opt = h +opt/arg = none + +[temp/day] +type = unsigned_short +description = The color temperature the screen should have during daytime. +default = 6500 +example = 6500 +check/type = unsigned_short +check/range = 1000-25000 +opt/long = temp-day +opt/arg = required + +[temp/night] +type = unsigned_short +description = The color temperature the screen should have during nighttime. +default = 4500 +example = 4500 +check/type = unsigned_short +check/range = 1000-25000 +opt/long = temp-night +opt/arg = required + +[temp/oneshotmanual] +type = unsigned_short +description = The color temperature the screen should have when oneshotmanual mode is used. +default = 6500 +example = 6500 +check/type = unsigned_short +check/range = 1000-25000 +opt/long = temp-oneshotmanual +opt/arg = required + +[fade/fast] +type = boolean +description = Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant. +default = 0 +example = 1 +opt = f +opt/long = fade-fast +opt/arg = none + +[brightness/day] +type = float +description = The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness. +default = 1.0 +example = 0.8 +check/type = float +check/range = 0-1 +opt/long = brightness-day +opt/arg = required + +[brightness/night] +type = float +description = The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness. +default = 1.0 +example = 0.8 +check/type = float +check/range = 0-1 +opt/long = brightness-night +opt/arg = required + +[gamma/day] +type = string +description = The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +default = 1.0:1.0:1.0 +example = 0.9 +; Regex ensures format "float" or "float:float:float". Adapted from https://www.regular-expressions.info/floatingpoint.html +check/validation = ^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ +check/validation/message = The gamma value you provided is in an unsupported format. Supported formats are: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +opt/long = gamma-day +opt/arg = required + +[gamma/night] +type = string +description = The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +default = 1.0:1.0:1.0 +example = 0.9 +; Regex ensures format "float" or "float:float:float". Adapted from https://www.regular-expressions.info/floatingpoint.html +check/validation = ^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ +check/validation/message = The gamma value you provided is in an unsupported format. Supported formats are: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +opt/long = gamma-night +opt/arg = required + +[gamma/preserve] +type = boolean +description = Use to preserve existing gamma ramps before applying adjustments. +default = 1 +example = 0 +opt = P +opt/arg = none + +[adjustment/method] +type = enum +check/enum = #7 +check/enum/#0 = drm +check/enum/#1 = dummy +check/enum/#2 = quartz +check/enum/#3 = randr +check/enum/#4 = vidmode +check/enum/#5 = w32gdi +check/enum/#6 = auto +check/enum/#7 = list +description = The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section "Alternative Features" in file DESIGN in root directory. +default = auto +example = randr +; default = w32gdi - For Windows the default is the only supported method 'w32gdi' +; default = randr - For Linux the default is 'randr' +; default = quartz - For macOS the default is 'quartz' +opt = m +opt/long = method +opt/arg = required + +[adjustment/method/help] +type = boolean +description = Prints the help of the adjustment methods. +default = 0 +example = 1 +opt/long = help-methods +opt/arg = none + +[provider] +type = enum +check/enum = #1 +check/enum/#0 = time +check/enum/#1 = location +description = The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user's location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn. +default = location +example = time +opt/long = provider +opt/arg = required + +[provider/time/dawn/start] +type = string +check/date = ISO8601 +check/date/format = timeofday +description = Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +default = 05:00 +example = 06:00 +opt/long = time-dawn-start +opt/arg = required + +[provider/time/dawn/end] +type = string +check/date = ISO8601 +check/date/format = timeofday +description = Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +default = 06:30 +example = 07:30 +opt/long = time-dawn-end +opt/arg = required + +[provider/time/dusk/start] +type = string +check/date = ISO8601 +check/date/format = timeofday +description = Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +default = 19:00 +example = 20:00 +opt/long = time-dusk-start +opt/arg = required + +[provider/time/dusk/end] +type = string +check/date = ISO8601 +check/date/format = timeofday +description = Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +default = 20:30 +example = 21:30 +opt/long = time-dusk-end +opt/arg = required + +[provider/location] +type = enum +check/enum = #4 +check/enum/#0 = corelocation +check/enum/#1 = geoclue2 +check/enum/#2 = manual +check/enum/#3 = auto +check/enum/#4 = list +description = The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime. +default = auto +example = geoclue2 +opt/long = location-provider +opt/arg = required + +[provider/location/help] +type = boolean +description = Prints the help of the location providers. +default = 0 +example = 1 +opt/long = help-providers +opt/arg = none + +[provider/location/elevation/high] +type = float +description = By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers. +default = 3.0 +example = 3.5 +opt/long = elevation-high +opt/arg = required + +[provider/location/elevation/low] +type = float +description = By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers. +default = -6.0 +example = -5.0 +opt/long = elevation-low +opt/arg = required + +[provider/location/manual/lat] +type = float +description = The location latitude. Only applies to location provider "manual". Some locations (e.g. mainland USA) require negative values. +check/type = float +check/range = -90.0-90.0 +; Latitude of Berlin: +default = 52.520008 +example = 52.520008 +opt/long = lat +opt/arg = required + +[provider/location/manual/lon] +type = float +description = The location longitude. Only applies to location provider "manual". Some locations (e.g. parts of Africa) require negative values. +check/type = float +check/range = -180.0-180.0 +; Longitude of berlin: +default = 13.404954 +example = 13.404954 +opt/long = lon +opt/arg = required + +; Note: other location providers have no config parameters/cli arguments + +[adjustment/crtc] +type = unsigned_short +description = CRTC to apply adjustments to. +default = 0 +example = 1 +opt/long = crtc +opt/arg = required + +[adjustment/screen] +type = unsigned_short +description = X screen to apply adjustments to. +default = 0 +example = 1 +opt/long = screen +opt/arg = required + +[adjustment/drm/card] +type = unsigned_short +description = Graphics card to apply adjustments to. +default = 0 +example = 1 +opt/long = drm-card +opt/arg = required + +; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. diff --git a/src/elektra/windows/redshift-conf.c b/src/elektra/windows/redshift-conf.c new file mode 100644 index 00000000..ef01ac3c --- /dev/null +++ b/src/elektra/windows/redshift-conf.c @@ -0,0 +1,754 @@ +// clang-format off + + +// clang-format on +/** + * @file + * + * This file was automatically generated using `kdb gen highlevel`. + * Any changes will be overwritten, when the file is regenerated. + * + * @copyright BSD Zero Clause License + * + * Copyright (c) Elektra Initiative (https://www.libelektra.org) + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "redshift-conf.h" + + + +#include +#include +#include + +#include +#include +#include +#include + +#include + +static KeySet * embeddedSpec (void) +{ + return ksNew (30, + keyNew ("/", KEY_META, "mountpoint", "redshift.ecf", KEY_END), + keyNew ("/adjustment/crtc", KEY_META, "default", "0", KEY_META, "description", "CRTC to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "crtc", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/adjustment/drm/card", KEY_META, "default", "0", KEY_META, "description", "Graphics card to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "drm-card", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/adjustment/method", KEY_META, "check/enum", "#7", KEY_META, "check/enum/#0", "drm", KEY_META, "check/enum/#1", "dummy", KEY_META, "check/enum/#2", "quartz", KEY_META, "check/enum/#3", "randr", KEY_META, "check/enum/#4", "vidmode", KEY_META, "check/enum/#5", "w32gdi", KEY_META, "check/enum/#6", "auto", KEY_META, "check/enum/#7", "list", KEY_META, "default", "auto", KEY_META, "description", "The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section \"Alternative Features\" in file DESIGN in root directory.", KEY_META, "example", "randr", KEY_META, "opt", "m", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "method", KEY_META, "type", "enum", KEY_END), + keyNew ("/adjustment/method/help", KEY_META, "default", "0", KEY_META, "description", "Prints the help of the adjustment methods.", KEY_META, "example", "1", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "help-methods", KEY_META, "type", "boolean", KEY_END), + keyNew ("/adjustment/screen", KEY_META, "default", "0", KEY_META, "description", "X screen to apply adjustments to.", KEY_META, "example", "1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "screen", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/brightness/day", KEY_META, "default", "1.0", KEY_META, "description", "The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness.", KEY_META, "example", "0.8", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "brightness-day", KEY_META, "type", "float", KEY_END), + keyNew ("/brightness/night", KEY_META, "default", "1.0", KEY_META, "description", "The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness.", KEY_META, "example", "0.8", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "brightness-night", KEY_META, "type", "float", KEY_END), + keyNew ("/fade/fast", KEY_META, "default", "0", KEY_META, "description", "Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant.", KEY_META, "example", "1", KEY_META, "opt", "f", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "fade-fast", KEY_META, "type", "boolean", KEY_END), + keyNew ("/gamma/day", KEY_META, "default", "1.0:1.0:1.0", KEY_META, "description", "The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "example", "0.9", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "gamma-day", KEY_META, "type", "string", KEY_END), + keyNew ("/gamma/night", KEY_META, "default", "1.0:1.0:1.0", KEY_META, "description", "The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).", KEY_META, "example", "0.9", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "gamma-night", KEY_META, "type", "string", KEY_END), + keyNew ("/gamma/preserve", KEY_META, "default", "1", KEY_META, "description", "Use to preserve existing gamma ramps before applying adjustments.", KEY_META, "example", "0", KEY_META, "opt", "P", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/help", KEY_META, "default", "0", KEY_META, "description", "Show program help.", KEY_META, "example", "1", KEY_META, "opt", "h", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/mode", KEY_META, "check/enum", "#4", KEY_META, "check/enum/#0", "continual", KEY_META, "check/enum/#1", "print", KEY_META, "check/enum/#2", "oneshot", KEY_META, "check/enum/#3", "reset", KEY_META, "check/enum/#4", "oneshotmanual", KEY_META, "default", "continual", KEY_META, "description", "The program mode. \"continual\" will constantly adjust the screen color temperature using the configured \"provider\". \"print\" will just print parameters and exit. \"oneshot\" will set temperature once using the configured \"provider\". \"reset\" will remove any color temperature adjustments then exit. \"oneshotmanual\" will not use any provider to determine if it\'s night or day and set the temperature specified by option \"temp/oneshotmanual\" immediately.", KEY_META, "example", "oneshot", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "mode", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider", KEY_META, "check/enum", "#1", KEY_META, "check/enum/#0", "time", KEY_META, "check/enum/#1", "location", KEY_META, "default", "location", KEY_META, "description", "The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user\'s location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn.", KEY_META, "example", "time", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "provider", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider/location", KEY_META, "check/enum", "#4", KEY_META, "check/enum/#0", "corelocation", KEY_META, "check/enum/#1", "geoclue2", KEY_META, "check/enum/#2", "manual", KEY_META, "check/enum/#3", "auto", KEY_META, "check/enum/#4", "list", KEY_META, "default", "auto", KEY_META, "description", "The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime.", KEY_META, "example", "geoclue2", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "location-provider", KEY_META, "type", "enum", KEY_END), + keyNew ("/provider/location/elevation/high", KEY_META, "default", "3.0", KEY_META, "description", "By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.", KEY_META, "example", "3.5", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "elevation-high", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/elevation/low", KEY_META, "default", "-6.0", KEY_META, "description", "By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.", KEY_META, "example", "-5.0", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "elevation-low", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/help", KEY_META, "default", "0", KEY_META, "description", "Prints the help of the location providers.", KEY_META, "example", "1", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "help-providers", KEY_META, "type", "boolean", KEY_END), + keyNew ("/provider/location/manual/lat", KEY_META, "default", "52.520008", KEY_META, "description", "The location latitude. Only applies to location provider \"manual\". Some locations (e.g. mainland USA) require negative values.", KEY_META, "example", "52.520008", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "lat", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/location/manual/lon", KEY_META, "default", "13.404954", KEY_META, "description", "The location longitude. Only applies to location provider \"manual\". Some locations (e.g. parts of Africa) require negative values.", KEY_META, "example", "13.404954", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "lon", KEY_META, "type", "float", KEY_END), + keyNew ("/provider/time/dawn/end", KEY_META, "default", "06:30", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "07:30", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dawn-end", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dawn/start", KEY_META, "default", "05:00", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "06:00", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dawn-start", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dusk/end", KEY_META, "default", "20:30", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "21:30", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dusk-end", KEY_META, "type", "string", KEY_END), + keyNew ("/provider/time/dusk/start", KEY_META, "default", "19:00", KEY_META, "description", "Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).", KEY_META, "example", "20:00", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "time-dusk-start", KEY_META, "type", "string", KEY_END), + keyNew ("/temp/day", KEY_META, "default", "6500", KEY_META, "description", "The color temperature the screen should have during daytime.", KEY_META, "example", "6500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-day", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/temp/night", KEY_META, "default", "4500", KEY_META, "description", "The color temperature the screen should have during nighttime.", KEY_META, "example", "4500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-night", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/temp/oneshotmanual", KEY_META, "default", "6500", KEY_META, "description", "The color temperature the screen should have when oneshotmanual mode is used.", KEY_META, "example", "6500", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "temp-oneshotmanual", KEY_META, "type", "unsigned_short", KEY_END), + keyNew ("/verbose", KEY_META, "default", "0", KEY_META, "description", "Verbose output.", KEY_META, "example", "1", KEY_META, "opt", "v", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + keyNew ("/version", KEY_META, "default", "0", KEY_META, "description", "Show program version.", KEY_META, "example", "1", KEY_META, "opt", "V", KEY_META, "opt/arg", "none", KEY_META, "type", "boolean", KEY_END), + KS_END); +; +} + +static const char * helpFallback = "Usage: redshift [OPTION...]\n\nOPTIONS\n --help Print this help message\n , --crtc=ARG CRTC to apply adjustments to.\n , --drm-card=ARG Graphics card to apply adjustments to.\n -m ARG, --method=ARG The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section \"Alternative Features\" in file DESIGN in root directory.\n , --help-methods Prints the help of the adjustment methods.\n , --screen=ARG X screen to apply adjustments to.\n , --brightness-day=ARG The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness.\n , --brightness-night=ARG The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness.\n -f, --fade-fast Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant.\n , --gamma-day=ARG The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).\n , --gamma-night=ARG The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9).\n -P Use to preserve existing gamma ramps before applying adjustments.\n -h Show program help.\n , --mode=ARG The program mode. \"continual\" will constantly adjust the screen color temperature using the configured \"provider\". \"print\" will just print parameters and exit. \"oneshot\" will set temperature once using the configured \"provider\". \"reset\" will remove any color temperature adjustments then exit. \"oneshotmanual\" will not use any provider to determine if it\'s night or day and set the temperature specified by option \"temp/oneshotmanual\" immediately.\n , --provider=ARG The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user\'s location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn.\n , --location-provider=ARG The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime.\n , --elevation-high=ARG By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.\n , --elevation-low=ARG By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers.\n , --help-providers Prints the help of the location providers.\n , --lat=ARG The location latitude. Only applies to location provider \"manual\". Some locations (e.g. mainland USA) require negative values.\n , --lon=ARG The location longitude. Only applies to location provider \"manual\". Some locations (e.g. parts of Africa) require negative values.\n , --time-dawn-end=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dawn-start=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dusk-end=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --time-dusk-start=ARG Instead of using the solar elevation at the user\'s location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals).\n , --temp-day=ARG The color temperature the screen should have during daytime.\n , --temp-night=ARG The color temperature the screen should have during nighttime.\n , --temp-oneshotmanual=ARG The color temperature the screen should have when oneshotmanual mode is used.\n -v Verbose output.\n -V Show program version.\n"; + +static int isHelpMode (int argc, const char * const * argv) +{ + for (int i = 0; i < argc; ++i) + { + if (strcmp (argv[i], "--help") == 0) + { + return 1; + } + } + + return 0; +} + + + +/** + * Initializes an instance of Elektra for the application '/sw/jonls/redshift/#0/current'. + * + * This can be invoked as many times as you want, however it is not a cheap operation, + * so you should try to reuse the Elektra handle as much as possible. + * + * @param elektra A reference to where the Elektra instance shall be stored. + * Has to be disposed of with elektraClose(). + * @param error A reference to an ElektraError pointer. Will be passed to elektraOpen(). + * + * @retval 0 on success, @p elektra will contain a new Elektra instance coming from elektraOpen(), + * @p error will be unchanged + * @retval -1 on error, @p elektra will be unchanged, @p error will be set + * @retval 1 help mode, '--help' was specified call printHelpMessage to display + * the help message. @p elektra will contain a new Elektra instance. It has to be passed + * to printHelpMessage. You also need to elektraClose() it. + * @p error will be unchanged + * + * @see elektraOpen + */// +int loadConfiguration (Elektra ** elektra, + int argc, const char * const * argv, const char * const * envp, + ElektraError ** error) +{ + KeySet * defaults = embeddedSpec (); + + + KeySet * contract = ksNew (2, + keyNew ("system:/elektra/contract/highlevel/helpmode/ignore/require", KEY_VALUE, "1", KEY_END), + keyNew ("system:/elektra/contract/mountglobal/gopts", KEY_END), + KS_END); +; + Key * parentKey = keyNew ("/sw/jonls/redshift/#0/current", KEY_END); + + elektraGOptsContract (contract, argc, argv, envp, parentKey, NULL); + + + keyDel (parentKey); + + Elektra * e = elektraOpen ("/sw/jonls/redshift/#0/current", defaults, contract, error); + + if (defaults != NULL) + { + ksDel (defaults); + } + + if (contract != NULL) + { + ksDel (contract); + } + + if (e == NULL) + { + *elektra = NULL; + if (isHelpMode (argc, argv)) + { + elektraErrorReset (error); + return 1; + } + + + return -1; + } + + *elektra = e; + return elektraHelpKey (e) != NULL && strcmp (keyString (elektraHelpKey (e)), "1") == 0 ? 1 : 0; +} + +/** + * Checks whether specload mode was invoked and if so, sends the specification over stdout + * in the format expected by specload. + * + * You MUST not output anything to stdout before invoking this function. Ideally invoking this + * is the first thing you do in your main()-function. + * + * This function will ONLY RETURN, if specload mode was NOT invoked. Otherwise it will call `exit()`. + * + * @param argc pass the value of argc from main + * @param argv pass the value of argv from main + */ +void exitForSpecload (int argc, const char * const * argv) +{ + if (argc != 2 || strcmp (argv[1], "--elektra-spec") != 0) + { + return; + } + + KeySet * spec = embeddedSpec (); + + Key * parentKey = keyNew ("spec:/sw/jonls/redshift/#0/current", KEY_META, "system:/elektra/quickdump/noparent", "", KEY_END); + + KeySet * specloadConf = ksNew (1, keyNew ("system:/sendspec", KEY_END), KS_END); + ElektraInvokeHandle * specload = elektraInvokeOpen ("specload", specloadConf, parentKey); + + int result = elektraInvoke2Args (specload, "sendspec", spec, parentKey); + + elektraInvokeClose (specload, parentKey); + keyDel (parentKey); + ksDel (specloadConf); + ksDel (spec); + + exit (result == ELEKTRA_PLUGIN_STATUS_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE); +} + + +/** + * Outputs the help message to stdout + * + * @param elektra The Elektra instance produced by loadConfiguration. + * @param usage If this is not NULL, it will be used instead of the default usage line. + * @param prefix If this is not NULL, it will be inserted between the usage line and the options list. + */// +void printHelpMessage (Elektra * elektra, const char * usage, const char * prefix) +{ + if (elektra == NULL) + { + printf ("%s", helpFallback); + return; + } + + Key * helpKey = elektraHelpKey (elektra); + if (helpKey == NULL) + { + return; + } + + char * help = elektraGetOptsHelpMessage (helpKey, usage, prefix); + printf ("%s", help); + elektraFree (help); +} + + + +// clang-format off + +// clang-format on + +// ------------------------- +// Enum conversion functions +// ------------------------- + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + + if (strcmp (string, "drm") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM; + return 1; + } + if (strcmp (string, "dummy") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY; + return 1; + } + if (strcmp (string, "quartz") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ; + return 1; + } + if (strcmp (string, "randr") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR; + return 1; + } + if (strcmp (string, "vidmode") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE; + return 1; + } + if (strcmp (string, "w32gdi") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI; + return 1; + } + if (strcmp (string, "auto") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO; + return 1; + } + if (strcmp (string, "list") == 0) + { + *variable = ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST; + return 1; + } + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + switch (value) + { + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM: + return elektraStrDup ("drm"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY: + return elektraStrDup ("dummy"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ: + return elektraStrDup ("quartz"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR: + return elektraStrDup ("randr"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE: + return elektraStrDup ("vidmode"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI: + return elektraStrDup ("w32gdi"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO: + return elektraStrDup ("auto"); + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST: + return elektraStrDup ("list"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + switch (value) + { + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM: + return "drm"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY: + return "dummy"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ: + return "quartz"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR: + return "randr"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE: + return "vidmode"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI: + return "w32gdi"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO: + return "auto"; + case ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST: + return "list"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumMode, EnumMode) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + + if (strcmp (string, "continual") == 0) + { + *variable = ELEKTRA_ENUM_MODE_CONTINUAL; + return 1; + } + if (strcmp (string, "print") == 0) + { + *variable = ELEKTRA_ENUM_MODE_PRINT; + return 1; + } + if (strcmp (string, "oneshot") == 0) + { + *variable = ELEKTRA_ENUM_MODE_ONESHOT; + return 1; + } + if (strcmp (string, "reset") == 0) + { + *variable = ELEKTRA_ENUM_MODE_RESET; + return 1; + } + if (strcmp (string, "oneshotmanual") == 0) + { + *variable = ELEKTRA_ENUM_MODE_ONESHOTMANUAL; + return 1; + } + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumMode, EnumMode) +{ + switch (value) + { + case ELEKTRA_ENUM_MODE_CONTINUAL: + return elektraStrDup ("continual"); + case ELEKTRA_ENUM_MODE_PRINT: + return elektraStrDup ("print"); + case ELEKTRA_ENUM_MODE_ONESHOT: + return elektraStrDup ("oneshot"); + case ELEKTRA_ENUM_MODE_RESET: + return elektraStrDup ("reset"); + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: + return elektraStrDup ("oneshotmanual"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumMode, EnumMode) +{ + switch (value) + { + case ELEKTRA_ENUM_MODE_CONTINUAL: + return "continual"; + case ELEKTRA_ENUM_MODE_PRINT: + return "print"; + case ELEKTRA_ENUM_MODE_ONESHOT: + return "oneshot"; + case ELEKTRA_ENUM_MODE_RESET: + return "reset"; + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: + return "oneshotmanual"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + switch (string[0]) +{ +case 'l': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION; +return 1; +case 't': +*variable = ELEKTRA_ENUM_PROVIDER_TIME; +return 1; +} + + + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_TIME: + return elektraStrDup ("time"); + case ELEKTRA_ENUM_PROVIDER_LOCATION: + return elektraStrDup ("location"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_TIME: + return "time"; + case ELEKTRA_ENUM_PROVIDER_LOCATION: + return "location"; + } + + // should be unreachable + return ""; +} +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + const char * string; + if (!elektraKeyToString (key, &string) || strlen (string) == 0) + { + return 0; + } + + switch (string[0]) +{ +case 'a': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO; +return 1; +case 'c': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION; +return 1; +case 'g': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2; +return 1; +case 'l': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_LIST; +return 1; +case 'm': +*variable = ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL; +return 1; +} + + + + return 0; +} + +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION: + return elektraStrDup ("corelocation"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2: + return elektraStrDup ("geoclue2"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL: + return elektraStrDup ("manual"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO: + return elektraStrDup ("auto"); + case ELEKTRA_ENUM_PROVIDER_LOCATION_LIST: + return elektraStrDup ("list"); + } + + // should be unreachable + return elektraStrDup (""); +} + +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + switch (value) + { + case ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION: + return "corelocation"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2: + return "geoclue2"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL: + return "manual"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO: + return "auto"; + case ELEKTRA_ENUM_PROVIDER_LOCATION_LIST: + return "list"; + } + + // should be unreachable + return ""; +} + +// ------------------------- +// Enum accessor functions +// ------------------------- + +ELEKTRA_GET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + ElektraEnumAdjustmentMethod result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumAdjustmentMethod) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumAdjustmentMethod) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + ElektraEnumAdjustmentMethod result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumAdjustmentMethod) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumAdjustmentMethod) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + char * string = ELEKTRA_TO_STRING (EnumAdjustmentMethod) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod) +{ + char * string = ELEKTRA_TO_STRING (EnumAdjustmentMethod) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumMode, EnumMode) +{ + ElektraEnumMode result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumMode) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumMode) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode) +{ + ElektraEnumMode result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumMode) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumMode) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumMode, EnumMode) +{ + char * string = ELEKTRA_TO_STRING (EnumMode) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode) +{ + char * string = ELEKTRA_TO_STRING (EnumMode) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + ElektraEnumProvider result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProvider) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProvider) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + ElektraEnumProvider result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProvider) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProvider) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + char * string = ELEKTRA_TO_STRING (EnumProvider) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider) +{ + char * string = ELEKTRA_TO_STRING (EnumProvider) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} +ELEKTRA_GET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + ElektraEnumProviderLocation result; + const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProviderLocation) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProviderLocation) 0; + } + return result; +} + +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + ElektraEnumProviderLocation result; + const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE_ENUM); + if (!ELEKTRA_KEY_TO (EnumProviderLocation) (key, &result)) + { + elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE_ENUM, keyname, keyString (key))); + return (ElektraEnumProviderLocation) 0; + } + return result; +} + +ELEKTRA_SET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + char * string = ELEKTRA_TO_STRING (EnumProviderLocation) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawString (elektra, keyname, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation) +{ + char * string = ELEKTRA_TO_STRING (EnumProviderLocation) (value); + if (string == 0) + { + *error = elektraErrorConversionToString (KDB_TYPE_ENUM, keyname); + return; + } + elektraSetRawStringArrayElement (elektra, keyname, index, string, KDB_TYPE_ENUM, error); + elektraFree (string); +} + + +// clang-format off + +// clang-format on + +// ------------------------- +// Union accessor functions +// ------------------------- + + + + +// clang-format off + +// clang-format on + +// ------------------------- +// Struct accessor functions +// ------------------------- + + + diff --git a/src/elektra/windows/redshift-conf.h b/src/elektra/windows/redshift-conf.h new file mode 100644 index 00000000..aea81ddd --- /dev/null +++ b/src/elektra/windows/redshift-conf.h @@ -0,0 +1,1507 @@ +// clang-format off + + +// clang-format on +/** + * @file + * + * This file was automatically generated using `kdb gen highlevel`. + * Any changes will be overwritten, when the file is regenerated. + * + * @copyright BSD Zero Clause License + * + * Copyright (c) Elektra Initiative (https://www.libelektra.org) + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef REDSHIFT_CONF_H +#define REDSHIFT_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include + + + + + +// clang-format off + +// clang-format on + +typedef enum +{ + ELEKTRA_ENUM_ADJUSTMENT_METHOD_DRM = 0, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_DUMMY = 1, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_QUARTZ = 2, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_RANDR = 3, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_VIDMODE = 4, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_W32GDI = 5, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO = 6, + ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST = 7, +} ElektraEnumAdjustmentMethod; + +typedef enum +{ + ELEKTRA_ENUM_MODE_CONTINUAL = 0, + ELEKTRA_ENUM_MODE_PRINT = 1, + ELEKTRA_ENUM_MODE_ONESHOT = 2, + ELEKTRA_ENUM_MODE_RESET = 3, + ELEKTRA_ENUM_MODE_ONESHOTMANUAL = 4, +} ElektraEnumMode; + +typedef enum +{ + ELEKTRA_ENUM_PROVIDER_TIME = 0, + ELEKTRA_ENUM_PROVIDER_LOCATION = 1, +} ElektraEnumProvider; + +typedef enum +{ + ELEKTRA_ENUM_PROVIDER_LOCATION_CORELOCATION = 0, + ELEKTRA_ENUM_PROVIDER_LOCATION_GEOCLUE2 = 1, + ELEKTRA_ENUM_PROVIDER_LOCATION_MANUAL = 2, + ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO = 3, + ELEKTRA_ENUM_PROVIDER_LOCATION_LIST = 4, +} ElektraEnumProviderLocation; + + +#define ELEKTRA_TO_CONST_STRING(typeName) ELEKTRA_CONCAT (ELEKTRA_CONCAT (elektra, typeName), ToConstString) +#define ELEKTRA_TO_CONST_STRING_SIGNATURE(cType, typeName) const char * ELEKTRA_TO_CONST_STRING (typeName) (cType value) + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); + +ELEKTRA_GET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_SET_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumAdjustmentMethod, EnumAdjustmentMethod); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumMode, EnumMode); + +ELEKTRA_GET_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_SET_SIGNATURE (ElektraEnumMode, EnumMode); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumMode, EnumMode); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProvider, EnumProvider); + +ELEKTRA_GET_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_SET_SIGNATURE (ElektraEnumProvider, EnumProvider); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProvider, EnumProvider); + +ELEKTRA_KEY_TO_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_TO_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_TO_CONST_STRING_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); + +ELEKTRA_GET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_GET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_SET_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); +ELEKTRA_SET_ARRAY_ELEMENT_SIGNATURE (ElektraEnumProviderLocation, EnumProviderLocation); + + + +// clang-format off + +// clang-format on + +#define ELEKTRA_UNION_FREE(typeName) ELEKTRA_CONCAT (elektraFree, typeName) +#define ELEKTRA_UNION_FREE_SIGNATURE(cType, typeName, discrType) void ELEKTRA_UNION_FREE (typeName) (cType * ptr, discrType discriminator) + +#define ELEKTRA_UNION_GET_SIGNATURE(cType, typeName, discrType) \ + cType ELEKTRA_GET (typeName) (Elektra * elektra, const char * keyname, discrType discriminator) +#define ELEKTRA_UNION_GET_ARRAY_ELEMENT_SIGNATURE(cType, typeName, discrType) \ + cType ELEKTRA_GET_ARRAY_ELEMENT (typeName) (Elektra * elektra, const char * keyname, kdb_long_long_t index, discrType discriminator) +#define ELEKTRA_UNION_SET_SIGNATURE(cType, typeName, discrType) \ + void ELEKTRA_SET (typeName) (Elektra * elektra, const char * keyname, cType value, discrType discriminator, ElektraError ** error) +#define ELEKTRA_UNION_SET_ARRAY_ELEMENT_SIGNATURE(cType, typeName, discrType) \ + void ELEKTRA_SET_ARRAY_ELEMENT (typeName) (Elektra * elektra, const char * keyname, kdb_long_long_t index, cType value, \ + discrType discriminator, ElektraError ** error) + + + + + + +// clang-format off + +// clang-format on + +#define ELEKTRA_STRUCT_FREE(typeName) ELEKTRA_CONCAT (elektraFree, typeName) +#define ELEKTRA_STRUCT_FREE_SIGNATURE(cType, typeName) void ELEKTRA_STRUCT_FREE (typeName) (cType * ptr) + + + + + + +// clang-format off + +// clang-format on + +// clang-format off + +/** +* Tag name for 'adjustment/crtc' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_CRTC AdjustmentCrtc + +/** +* Tag name for 'adjustment/drm/card' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_DRM_CARD AdjustmentDrmCard + +/** +* Tag name for 'adjustment/method' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_METHOD AdjustmentMethod + +/** +* Tag name for 'adjustment/method/help' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP AdjustmentMethodHelp + +/** +* Tag name for 'adjustment/screen' +* +*/// +#define ELEKTRA_TAG_ADJUSTMENT_SCREEN AdjustmentScreen + +/** +* Tag name for 'brightness/day' +* +*/// +#define ELEKTRA_TAG_BRIGHTNESS_DAY BrightnessDay + +/** +* Tag name for 'brightness/night' +* +*/// +#define ELEKTRA_TAG_BRIGHTNESS_NIGHT BrightnessNight + +/** +* Tag name for 'fade/fast' +* +*/// +#define ELEKTRA_TAG_FADE_FAST FadeFast + +/** +* Tag name for 'gamma/day' +* +*/// +#define ELEKTRA_TAG_GAMMA_DAY GammaDay + +/** +* Tag name for 'gamma/night' +* +*/// +#define ELEKTRA_TAG_GAMMA_NIGHT GammaNight + +/** +* Tag name for 'gamma/preserve' +* +*/// +#define ELEKTRA_TAG_GAMMA_PRESERVE GammaPreserve + +/** +* Tag name for 'help' +* +*/// +#define ELEKTRA_TAG_HELP Help + +/** +* Tag name for 'mode' +* +*/// +#define ELEKTRA_TAG_MODE Mode + +/** +* Tag name for 'provider' +* +*/// +#define ELEKTRA_TAG_PROVIDER Provider + +/** +* Tag name for 'provider/location' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION ProviderLocation + +/** +* Tag name for 'provider/location/elevation/high' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH ProviderLocationElevationHigh + +/** +* Tag name for 'provider/location/elevation/low' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW ProviderLocationElevationLow + +/** +* Tag name for 'provider/location/help' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_HELP ProviderLocationHelp + +/** +* Tag name for 'provider/location/manual/lat' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT ProviderLocationManualLat + +/** +* Tag name for 'provider/location/manual/lon' +* +*/// +#define ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON ProviderLocationManualLon + +/** +* Tag name for 'provider/time/dawn/end' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DAWN_END ProviderTimeDawnEnd + +/** +* Tag name for 'provider/time/dawn/start' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DAWN_START ProviderTimeDawnStart + +/** +* Tag name for 'provider/time/dusk/end' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DUSK_END ProviderTimeDuskEnd + +/** +* Tag name for 'provider/time/dusk/start' +* +*/// +#define ELEKTRA_TAG_PROVIDER_TIME_DUSK_START ProviderTimeDuskStart + +/** +* Tag name for 'temp/day' +* +*/// +#define ELEKTRA_TAG_TEMP_DAY TempDay + +/** +* Tag name for 'temp/night' +* +*/// +#define ELEKTRA_TAG_TEMP_NIGHT TempNight + +/** +* Tag name for 'temp/oneshotmanual' +* +*/// +#define ELEKTRA_TAG_TEMP_ONESHOTMANUAL TempOneshotmanual + +/** +* Tag name for 'verbose' +* +*/// +#define ELEKTRA_TAG_VERBOSE Verbose + +/** +* Tag name for 'version' +* +*/// +#define ELEKTRA_TAG_VERSION Version +// clang-format on + + +// clang-format off + +// clang-format on + +// local helper macros to determine the length of a 64 bit integer +#define elektra_len19(x) ((x) < 10000000000000000000ULL ? 19 : 20) +#define elektra_len18(x) ((x) < 1000000000000000000ULL ? 18 : elektra_len19 (x)) +#define elektra_len17(x) ((x) < 100000000000000000ULL ? 17 : elektra_len18 (x)) +#define elektra_len16(x) ((x) < 10000000000000000ULL ? 16 : elektra_len17 (x)) +#define elektra_len15(x) ((x) < 1000000000000000ULL ? 15 : elektra_len16 (x)) +#define elektra_len14(x) ((x) < 100000000000000ULL ? 14 : elektra_len15 (x)) +#define elektra_len13(x) ((x) < 10000000000000ULL ? 13 : elektra_len14 (x)) +#define elektra_len12(x) ((x) < 1000000000000ULL ? 12 : elektra_len13 (x)) +#define elektra_len11(x) ((x) < 100000000000ULL ? 11 : elektra_len12 (x)) +#define elektra_len10(x) ((x) < 10000000000ULL ? 10 : elektra_len11 (x)) +#define elektra_len09(x) ((x) < 1000000000ULL ? 9 : elektra_len10 (x)) +#define elektra_len08(x) ((x) < 100000000ULL ? 8 : elektra_len09 (x)) +#define elektra_len07(x) ((x) < 10000000ULL ? 7 : elektra_len08 (x)) +#define elektra_len06(x) ((x) < 1000000ULL ? 6 : elektra_len07 (x)) +#define elektra_len05(x) ((x) < 100000ULL ? 5 : elektra_len06 (x)) +#define elektra_len04(x) ((x) < 10000ULL ? 4 : elektra_len05 (x)) +#define elektra_len03(x) ((x) < 1000ULL ? 3 : elektra_len04 (x)) +#define elektra_len02(x) ((x) < 100ULL ? 2 : elektra_len03 (x)) +#define elektra_len01(x) ((x) < 10ULL ? 1 : elektra_len02 (x)) +#define elektra_len00(x) ((x) < 0ULL ? 0 : elektra_len01 (x)) +#define elektra_len(x) elektra_len00 (x) + +#define ELEKTRA_SIZE(tagName) ELEKTRA_CONCAT (elektraSize, tagName) + + + + +/** + * Get the value of key 'adjustment/crtc' (tag #ELEKTRA_TAG_ADJUSTMENT_CRTC). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/crtc'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_CRTC) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/crtc"); +} + + +/** + * Set the value of key 'adjustment/crtc' (tag #ELEKTRA_TAG_ADJUSTMENT_CRTC). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/crtc'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_CRTC) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/crtc", value, error); +} + + + + +/** + * Get the value of key 'adjustment/drm/card' (tag #ELEKTRA_TAG_ADJUSTMENT_DRM_CARD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/drm/card'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_DRM_CARD) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/drm/card"); +} + + +/** + * Set the value of key 'adjustment/drm/card' (tag #ELEKTRA_TAG_ADJUSTMENT_DRM_CARD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/drm/card'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_DRM_CARD) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/drm/card", value, error); +} + + + + +/** + * Get the value of key 'adjustment/method' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/method'. + + */// +static inline ElektraEnumAdjustmentMethod ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_METHOD) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumAdjustmentMethod) (elektra, "adjustment/method"); +} + + +/** + * Set the value of key 'adjustment/method' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/method'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_METHOD) (Elektra * elektra, + ElektraEnumAdjustmentMethod value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumAdjustmentMethod) (elektra, "adjustment/method", value, error); +} + + + + +/** + * Get the value of key 'adjustment/method/help' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/method/help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "adjustment/method/help"); +} + + +/** + * Set the value of key 'adjustment/method/help' (tag #ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/method/help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_METHOD_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "adjustment/method/help", value, error); +} + + + + +/** + * Get the value of key 'adjustment/screen' (tag #ELEKTRA_TAG_ADJUSTMENT_SCREEN). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'adjustment/screen'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_ADJUSTMENT_SCREEN) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "adjustment/screen"); +} + + +/** + * Set the value of key 'adjustment/screen' (tag #ELEKTRA_TAG_ADJUSTMENT_SCREEN). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'adjustment/screen'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_ADJUSTMENT_SCREEN) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "adjustment/screen", value, error); +} + + + + +/** + * Get the value of key 'brightness/day' (tag #ELEKTRA_TAG_BRIGHTNESS_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'brightness/day'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_BRIGHTNESS_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "brightness/day"); +} + + +/** + * Set the value of key 'brightness/day' (tag #ELEKTRA_TAG_BRIGHTNESS_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'brightness/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_BRIGHTNESS_DAY) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "brightness/day", value, error); +} + + + + +/** + * Get the value of key 'brightness/night' (tag #ELEKTRA_TAG_BRIGHTNESS_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'brightness/night'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_BRIGHTNESS_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "brightness/night"); +} + + +/** + * Set the value of key 'brightness/night' (tag #ELEKTRA_TAG_BRIGHTNESS_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'brightness/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_BRIGHTNESS_NIGHT) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "brightness/night", value, error); +} + + + + +/** + * Get the value of key 'fade/fast' (tag #ELEKTRA_TAG_FADE_FAST). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'fade/fast'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_FADE_FAST) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "fade/fast"); +} + + +/** + * Set the value of key 'fade/fast' (tag #ELEKTRA_TAG_FADE_FAST). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'fade/fast'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_FADE_FAST) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "fade/fast", value, error); +} + + + + +/** + * Get the value of key 'gamma/day' (tag #ELEKTRA_TAG_GAMMA_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/day'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_GAMMA_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "gamma/day"); +} + + +/** + * Set the value of key 'gamma/day' (tag #ELEKTRA_TAG_GAMMA_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_DAY) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "gamma/day", value, error); +} + + + + +/** + * Get the value of key 'gamma/night' (tag #ELEKTRA_TAG_GAMMA_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/night'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_GAMMA_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "gamma/night"); +} + + +/** + * Set the value of key 'gamma/night' (tag #ELEKTRA_TAG_GAMMA_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_NIGHT) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "gamma/night", value, error); +} + + + + +/** + * Get the value of key 'gamma/preserve' (tag #ELEKTRA_TAG_GAMMA_PRESERVE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'gamma/preserve'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_GAMMA_PRESERVE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "gamma/preserve"); +} + + +/** + * Set the value of key 'gamma/preserve' (tag #ELEKTRA_TAG_GAMMA_PRESERVE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'gamma/preserve'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GAMMA_PRESERVE) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "gamma/preserve", value, error); +} + + + + +/** + * Get the value of key 'help' (tag #ELEKTRA_TAG_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "help"); +} + + +/** + * Set the value of key 'help' (tag #ELEKTRA_TAG_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "help", value, error); +} + + + + +/** + * Get the value of key 'mode' (tag #ELEKTRA_TAG_MODE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'mode'. + + */// +static inline ElektraEnumMode ELEKTRA_GET (ELEKTRA_TAG_MODE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumMode) (elektra, "mode"); +} + + +/** + * Set the value of key 'mode' (tag #ELEKTRA_TAG_MODE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'mode'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_MODE) (Elektra * elektra, + ElektraEnumMode value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumMode) (elektra, "mode", value, error); +} + + + + +/** + * Get the value of key 'provider' (tag #ELEKTRA_TAG_PROVIDER). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider'. + + */// +static inline ElektraEnumProvider ELEKTRA_GET (ELEKTRA_TAG_PROVIDER) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumProvider) (elektra, "provider"); +} + + +/** + * Set the value of key 'provider' (tag #ELEKTRA_TAG_PROVIDER). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER) (Elektra * elektra, + ElektraEnumProvider value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumProvider) (elektra, "provider", value, error); +} + + + + +/** + * Get the value of key 'provider/location' (tag #ELEKTRA_TAG_PROVIDER_LOCATION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location'. + + */// +static inline ElektraEnumProviderLocation ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION) (Elektra * elektra ) +{ + + return ELEKTRA_GET (EnumProviderLocation) (elektra, "provider/location"); +} + + +/** + * Set the value of key 'provider/location' (tag #ELEKTRA_TAG_PROVIDER_LOCATION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION) (Elektra * elektra, + ElektraEnumProviderLocation value, ElektraError ** error) +{ + + ELEKTRA_SET (EnumProviderLocation) (elektra, "provider/location", value, error); +} + + + + +/** + * Get the value of key 'provider/location/elevation/high' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/elevation/high'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/elevation/high"); +} + + +/** + * Set the value of key 'provider/location/elevation/high' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/elevation/high'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_HIGH) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/elevation/high", value, error); +} + + + + +/** + * Get the value of key 'provider/location/elevation/low' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/elevation/low'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/elevation/low"); +} + + +/** + * Set the value of key 'provider/location/elevation/low' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/elevation/low'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_ELEVATION_LOW) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/elevation/low", value, error); +} + + + + +/** + * Get the value of key 'provider/location/help' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/help'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_HELP) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "provider/location/help"); +} + + +/** + * Set the value of key 'provider/location/help' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_HELP). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/help'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_HELP) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "provider/location/help", value, error); +} + + + + +/** + * Get the value of key 'provider/location/manual/lat' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/manual/lat'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/manual/lat"); +} + + +/** + * Set the value of key 'provider/location/manual/lat' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/manual/lat'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LAT) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/manual/lat", value, error); +} + + + + +/** + * Get the value of key 'provider/location/manual/lon' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/location/manual/lon'. + + */// +static inline kdb_float_t ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Float) (elektra, "provider/location/manual/lon"); +} + + +/** + * Set the value of key 'provider/location/manual/lon' (tag #ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/location/manual/lon'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_LOCATION_MANUAL_LON) (Elektra * elektra, + kdb_float_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Float) (elektra, "provider/location/manual/lon", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dawn/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dawn/end'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_END) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dawn/end"); +} + + +/** + * Set the value of key 'provider/time/dawn/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dawn/end'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_END) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dawn/end", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dawn/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dawn/start'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_START) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dawn/start"); +} + + +/** + * Set the value of key 'provider/time/dawn/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DAWN_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dawn/start'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DAWN_START) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dawn/start", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dusk/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dusk/end'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_END) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dusk/end"); +} + + +/** + * Set the value of key 'provider/time/dusk/end' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_END). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dusk/end'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_END) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dusk/end", value, error); +} + + + + +/** + * Get the value of key 'provider/time/dusk/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'provider/time/dusk/start'. + * The returned pointer may become invalid, if the internal state of @p elektra + * is modified. All calls to elektraSet* modify this state. + */// +static inline const char * ELEKTRA_GET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_START) (Elektra * elektra ) +{ + + return ELEKTRA_GET (String) (elektra, "provider/time/dusk/start"); +} + + +/** + * Set the value of key 'provider/time/dusk/start' (tag #ELEKTRA_TAG_PROVIDER_TIME_DUSK_START). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'provider/time/dusk/start'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_PROVIDER_TIME_DUSK_START) (Elektra * elektra, + const char * value, ElektraError ** error) +{ + + ELEKTRA_SET (String) (elektra, "provider/time/dusk/start", value, error); +} + + + + +/** + * Get the value of key 'temp/day' (tag #ELEKTRA_TAG_TEMP_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/day'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_DAY) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/day"); +} + + +/** + * Set the value of key 'temp/day' (tag #ELEKTRA_TAG_TEMP_DAY). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/day'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_DAY) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/day", value, error); +} + + + + +/** + * Get the value of key 'temp/night' (tag #ELEKTRA_TAG_TEMP_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/night'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_NIGHT) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/night"); +} + + +/** + * Set the value of key 'temp/night' (tag #ELEKTRA_TAG_TEMP_NIGHT). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/night'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_NIGHT) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/night", value, error); +} + + + + +/** + * Get the value of key 'temp/oneshotmanual' (tag #ELEKTRA_TAG_TEMP_ONESHOTMANUAL). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'temp/oneshotmanual'. + + */// +static inline kdb_unsigned_short_t ELEKTRA_GET (ELEKTRA_TAG_TEMP_ONESHOTMANUAL) (Elektra * elektra ) +{ + + return ELEKTRA_GET (UnsignedShort) (elektra, "temp/oneshotmanual"); +} + + +/** + * Set the value of key 'temp/oneshotmanual' (tag #ELEKTRA_TAG_TEMP_ONESHOTMANUAL). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'temp/oneshotmanual'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_TEMP_ONESHOTMANUAL) (Elektra * elektra, + kdb_unsigned_short_t value, ElektraError ** error) +{ + + ELEKTRA_SET (UnsignedShort) (elektra, "temp/oneshotmanual", value, error); +} + + + + +/** + * Get the value of key 'verbose' (tag #ELEKTRA_TAG_VERBOSE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'verbose'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_VERBOSE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "verbose"); +} + + +/** + * Set the value of key 'verbose' (tag #ELEKTRA_TAG_VERBOSE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'verbose'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_VERBOSE) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "verbose", value, error); +} + + + + +/** + * Get the value of key 'version' (tag #ELEKTRA_TAG_VERSION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'version'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_VERSION) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "version"); +} + + +/** + * Set the value of key 'version' (tag #ELEKTRA_TAG_VERSION). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'version'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_VERSION) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "version", value, error); +} + + +#undef elektra_len19 +#undef elektra_len18 +#undef elektra_len17 +#undef elektra_len16 +#undef elektra_len15 +#undef elektra_len14 +#undef elektra_len13 +#undef elektra_len12 +#undef elektra_len11 +#undef elektra_len10 +#undef elektra_len09 +#undef elektra_len08 +#undef elektra_len07 +#undef elektra_len06 +#undef elektra_len05 +#undef elektra_len04 +#undef elektra_len03 +#undef elektra_len02 +#undef elektra_len01 +#undef elektra_len00 +#undef elektra_len + + +int loadConfiguration (Elektra ** elektra, + int argc, const char * const * argv, const char * const * envp, + + ElektraError ** error); +void printHelpMessage (Elektra * elektra, const char * usage, const char * prefix); +void exitForSpecload (int argc, const char * const * argv); + + + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The tag to look up. + * + * @return The value stored at the given key. + * The lifetime of returned pointers is documented in the ELEKTRA_GET(*) functions above. + */// +#define elektraGet(elektra, tag) ELEKTRA_GET (tag) (elektra) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The tag to look up. + * @param ... Variable arguments depending on the given tag. + * + * @return The value stored at the given key. + * The lifetime of returned pointers is documented in the ELEKTRA_GET(*) functions above. + */// +#define elektraGetV(elektra, tag, ...) ELEKTRA_GET (tag) (elektra, __VA_ARGS__) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param result Points to the struct into which results will be stored. + * The lifetime of pointers in this struct is documented in the ELEKTRA_GET(*) functions above. + * @param tag The tag to look up. + */// +#define elektraFillStruct(elektra, result, tag) ELEKTRA_GET (tag) (elektra, result) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param result Points to the struct into which results will be stored. + * The lifetime of pointers in this struct is documented in the ELEKTRA_GET(*) functions above. + * @param tag The tag to look up. + * @param ... Variable arguments depending on the given tag. + */// +#define elektraFillStructV(elektra, result, tag, ...) ELEKTRA_GET (tag) (elektra, result, __VA_ARGS__) + + +/** + * @param elektra The elektra instance initialized with the loadConfiguration(). + * @param tag The tag to write to. + * @param value The new value. + * @param error Pass a reference to an ElektraError pointer. + */// +#define elektraSet(elektra, tag, value, error) ELEKTRA_SET (tag) (elektra, value, error) + + +/** + * @param elektra The elektra instance initialized with the loadConfiguration(). + * @param tag The tag to write to. + * @param value The new value. + * @param error Pass a reference to an ElektraError pointer. + * @param ... Variable arguments depending on the given tag. + */// +#define elektraSetV(elektra, tag, value, error, ...) ELEKTRA_SET (tag) (elektra, value, __VA_ARGS__, error) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The array tag to look up. + * + * @return The size of the array below the given key. + */// +#define elektraSize(elektra, tag) ELEKTRA_SIZE (tag) (elektra) + + +/** + * @param elektra The elektra instance initialized with loadConfiguration(). + * @param tag The array tag to look up. + * @param ... Variable arguments depending on the given tag. + * + * @return The size of the array below the given key. + */// +#define elektraSizeV(elektra, tag, ...) ELEKTRA_SIZE (tag) (elektra, __VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif // REDSHIFT_CONF_H diff --git a/src/elektra/windows/redshift-conf.mount.sh b/src/elektra/windows/redshift-conf.mount.sh new file mode 100644 index 00000000..944710bb --- /dev/null +++ b/src/elektra/windows/redshift-conf.mount.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ -z "$APP_PATH" ]; then + # TODO: set APP_PATH to the installed path of your application + APP_PATH='/usr/local/bin/redshift' +fi + +if ! [ -f "$APP_PATH" ]; then + echo "ERROR: APP_PATH points to non-existent file" 1>&2 + exit 1 +fi + +error_other_mp() { + echo "ERROR: another mountpoint already exists on spec:/sw/jonls/redshift/#0/current. Please umount first." 1>&2 + exit 1 +} + +if kdb mount -13 | grep -Fxq 'spec:/sw/jonls/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'redshift.overlay.spec.eqd on spec:/sw/jonls/redshift/#0/current with name spec:/sw/jonls/redshift/#0/current'; then + error_other_mp + fi + + MP=$(echo "spec:/sw/jonls/redshift/#0/current" | sed 's:\\:\\\\:g' | sed 's:/:\\/:g') + if [ -n "$(kdb get "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/file")" ]; then + error_other_mp + fi + if [ "$(kdb get "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/app")" != "$APP_PATH" ]; then + error_other_mp + fi + if [ -n "$(kdb ls "system:/elektra/mountpoints/$MP/getplugins/#5#specload#specload#/config/app/args")" ]; then + error_other_mp + fi +else + sudo kdb mount -R noresolver "redshift.overlay.spec.eqd" "spec:/sw/jonls/redshift/#0/current" specload "app=$APP_PATH" +fi + +if kdb mount -13 | grep -Fxq '/sw/jonls/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'redshift.ecf on /sw/jonls/redshift/#0/current with name /sw/jonls/redshift/#0/current'; then + echo "ERROR: another mountpoint already exists on /sw/jonls/redshift/#0/current. Please umount first." 1>&2 + exit 1 + fi +else + sudo kdb spec-mount '/sw/jonls/redshift/#0/current' +fi diff --git a/src/elektra/windows/redshift-win.dump b/src/elektra/windows/redshift-win.dump new file mode 100644 index 00000000..6c4ddac6 --- /dev/null +++ b/src/elektra/windows/redshift-win.dump @@ -0,0 +1,695 @@ +kdbOpen 2 +$key string 0 0 + + +$meta 10 12 +mountpoint +redshift.ecf +$key string 15 0 +adjustment/crtc + +$meta 7 1 +default +0 +$meta 11 29 +description +CRTC to apply adjustments to. +$meta 7 1 +example +1 +$meta 7 8 +opt/arg +required +$meta 8 4 +opt/long +crtc +$meta 4 14 +type +unsigned_short +$key string 19 0 +adjustment/drm/card + +$meta 7 1 +default +0 +$meta 11 38 +description +Graphics card to apply adjustments to. +$meta 7 1 +example +1 +$meta 7 8 +opt/arg +required +$meta 8 8 +opt/long +drm-card +$meta 4 14 +type +unsigned_short +$key string 17 0 +adjustment/method + +$meta 10 2 +check/enum +#7 +$meta 13 3 +check/enum/#0 +drm +$meta 13 5 +check/enum/#1 +dummy +$meta 13 6 +check/enum/#2 +quartz +$meta 13 5 +check/enum/#3 +randr +$meta 13 7 +check/enum/#4 +vidmode +$meta 13 6 +check/enum/#5 +w32gdi +$meta 13 4 +check/enum/#6 +auto +$meta 13 4 +check/enum/#7 +list +$meta 7 4 +default +auto +$meta 11 221 +description +The method used to adjust screen color temperature. By default, one of the supported methods on the current OS will be chosen automatically. For details see section "Alternative Features" in file DESIGN in root directory. +$meta 7 5 +example +randr +$meta 3 1 +opt +m +$meta 7 8 +opt/arg +required +$meta 8 6 +opt/long +method +$meta 4 4 +type +enum +$key string 22 0 +adjustment/method/help + +$meta 7 1 +default +0 +$meta 11 42 +description +Prints the help of the adjustment methods. +$meta 7 1 +example +1 +$meta 7 4 +opt/arg +none +$meta 8 12 +opt/long +help-methods +$meta 4 7 +type +boolean +$key string 17 0 +adjustment/screen + +$meta 7 1 +default +0 +$meta 11 33 +description +X screen to apply adjustments to. +$meta 7 1 +example +1 +$meta 7 8 +opt/arg +required +$meta 8 6 +opt/long +screen +$meta 4 14 +type +unsigned_short +$key string 14 0 +brightness/day + +$meta 7 3 +default +1.0 +$meta 11 124 +description +The screen brightness during daytime. If both day and night brightness are set, these will overrule the value of brightness. +$meta 7 3 +example +0.8 +$meta 7 8 +opt/arg +required +$meta 8 14 +opt/long +brightness-day +$meta 4 5 +type +float +$key string 16 0 +brightness/night + +$meta 7 3 +default +1.0 +$meta 11 126 +description +The screen brightness during nighttime. If both day and night brightness are set, these will overrule the value of brightness. +$meta 7 3 +example +0.8 +$meta 7 8 +opt/arg +required +$meta 8 16 +opt/long +brightness-night +$meta 4 5 +type +float +$key string 9 0 +fade/fast + +$meta 7 1 +default +0 +$meta 11 131 +description +Enable fast fades between color temperatures (e.g. from daytime to nighttime). When disabled, fades will be slow and more pleasant. +$meta 7 1 +example +1 +$meta 3 1 +opt +f +$meta 7 4 +opt/arg +none +$meta 8 9 +opt/long +fade-fast +$meta 4 7 +type +boolean +$key string 9 0 +gamma/day + +$meta 7 11 +default +1.0:1.0:1.0 +$meta 11 208 +description +The screen gamma during daytime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +$meta 7 3 +example +0.9 +$meta 7 8 +opt/arg +required +$meta 8 9 +opt/long +gamma-day +$meta 4 6 +type +string +$key string 11 0 +gamma/night + +$meta 7 11 +default +1.0:1.0:1.0 +$meta 11 210 +description +The screen gamma during nighttime. Supported formats: 1. One value, that will be used for red, green and blue (e.g. 0.9). 2. Three colon-separated values for red, green and blue respectively (e.g. 0.9:0.9:0.9). +$meta 7 3 +example +0.9 +$meta 7 8 +opt/arg +required +$meta 8 11 +opt/long +gamma-night +$meta 4 6 +type +string +$key string 14 0 +gamma/preserve + +$meta 7 1 +default +1 +$meta 11 65 +description +Use to preserve existing gamma ramps before applying adjustments. +$meta 7 1 +example +0 +$meta 3 1 +opt +P +$meta 7 4 +opt/arg +none +$meta 4 7 +type +boolean +$key string 4 0 +help + +$meta 7 1 +default +0 +$meta 11 18 +description +Show program help. +$meta 7 1 +example +1 +$meta 3 1 +opt +h +$meta 7 4 +opt/arg +none +$meta 4 7 +type +boolean +$key string 4 0 +mode + +$meta 10 2 +check/enum +#4 +$meta 13 9 +check/enum/#0 +continual +$meta 13 5 +check/enum/#1 +print +$meta 13 7 +check/enum/#2 +oneshot +$meta 13 5 +check/enum/#3 +reset +$meta 13 13 +check/enum/#4 +oneshotmanual +$meta 7 9 +default +continual +$meta 11 447 +description +The program mode. "continual" will constantly adjust the screen color temperature using the configured "provider". "print" will just print parameters and exit. "oneshot" will set temperature once using the configured "provider". "reset" will remove any color temperature adjustments then exit. "oneshotmanual" will not use any provider to determine if it's night or day and set the temperature specified by option "temp/oneshotmanual" immediately. +$meta 7 7 +example +oneshot +$meta 7 8 +opt/arg +required +$meta 8 4 +opt/long +mode +$meta 4 4 +type +enum +$key string 8 0 +provider + +$meta 10 2 +check/enum +#1 +$meta 13 4 +check/enum/#0 +time +$meta 13 8 +check/enum/#1 +location +$meta 7 8 +default +location +$meta 11 313 +description +The provider used to decide at what times of day redshift should be enabled/disabled. Currently two options are supported: 1. location - determines the user's location and enable/disable redshift depending on the solar elevation. 2. time: Ignore user location and enable redshift if time is between dusk and dawn. +$meta 7 4 +example +time +$meta 7 8 +opt/arg +required +$meta 8 8 +opt/long +provider +$meta 4 4 +type +enum +$key string 17 0 +provider/location + +$meta 10 2 +check/enum +#4 +$meta 13 12 +check/enum/#0 +corelocation +$meta 13 8 +check/enum/#1 +geoclue2 +$meta 13 6 +check/enum/#2 +manual +$meta 13 4 +check/enum/#3 +auto +$meta 13 4 +check/enum/#4 +list +$meta 7 4 +default +auto +$meta 11 213 +description +The location provider to be used. By default, one of the supported location providers on the current OS will be chosen automatically. The provider is used to establish whether it is currently daytime or nighttime. +$meta 7 8 +example +geoclue2 +$meta 7 8 +opt/arg +required +$meta 8 17 +opt/long +location-provider +$meta 4 4 +type +enum +$key string 32 0 +provider/location/elevation/high + +$meta 7 3 +default +3.0 +$meta 11 414 +description +By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers. +$meta 7 3 +example +3.5 +$meta 7 8 +opt/arg +required +$meta 8 14 +opt/long +elevation-high +$meta 4 5 +type +float +$key string 31 0 +provider/location/elevation/low + +$meta 7 4 +default +-6.0 +$meta 11 414 +description +By default, Redshift will use the current elevation of the sun to determine whether it is daytime, night or in transition (dawn/dusk). When the sun is above the degrees specified with the elevation-high key it is considered daytime and below the elevation-low key it is considered night (source: https://github.com/jonls/redshift/wiki/Configuration-file#solar-elevation-thresholds). Affects all location providers. +$meta 7 4 +example +-5.0 +$meta 7 8 +opt/arg +required +$meta 8 13 +opt/long +elevation-low +$meta 4 5 +type +float +$key string 22 0 +provider/location/help + +$meta 7 1 +default +0 +$meta 11 42 +description +Prints the help of the location providers. +$meta 7 1 +example +1 +$meta 7 4 +opt/arg +none +$meta 8 14 +opt/long +help-providers +$meta 4 7 +type +boolean +$key string 28 0 +provider/location/manual/lat + +$meta 7 9 +default +52.520008 +$meta 11 126 +description +The location latitude. Only applies to location provider "manual". Some locations (e.g. mainland USA) require negative values. +$meta 7 9 +example +52.520008 +$meta 7 8 +opt/arg +required +$meta 8 3 +opt/long +lat +$meta 4 5 +type +float +$key string 28 0 +provider/location/manual/lon + +$meta 7 9 +default +13.404954 +$meta 11 130 +description +The location longitude. Only applies to location provider "manual". Some locations (e.g. parts of Africa) require negative values. +$meta 7 9 +example +13.404954 +$meta 7 8 +opt/arg +required +$meta 8 3 +opt/long +lon +$meta 4 5 +type +float +$key string 22 0 +provider/time/dawn/end + +$meta 7 5 +default +06:30 +$meta 11 217 +description +Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +$meta 7 5 +example +07:30 +$meta 7 8 +opt/arg +required +$meta 8 13 +opt/long +time-dawn-end +$meta 4 6 +type +string +$key string 24 0 +provider/time/dawn/start + +$meta 7 5 +default +05:00 +$meta 11 217 +description +Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +$meta 7 5 +example +06:00 +$meta 7 8 +opt/arg +required +$meta 8 15 +opt/long +time-dawn-start +$meta 4 6 +type +string +$key string 22 0 +provider/time/dusk/end + +$meta 7 5 +default +20:30 +$meta 11 217 +description +Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +$meta 7 5 +example +21:30 +$meta 7 8 +opt/arg +required +$meta 8 13 +opt/long +time-dusk-end +$meta 4 6 +type +string +$key string 24 0 +provider/time/dusk/start + +$meta 7 5 +default +19:00 +$meta 11 217 +description +Instead of using the solar elevation at the user's location, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +$meta 7 5 +example +20:00 +$meta 7 8 +opt/arg +required +$meta 8 15 +opt/long +time-dusk-start +$meta 4 6 +type +string +$key string 8 0 +temp/day + +$meta 7 4 +default +6500 +$meta 11 60 +description +The color temperature the screen should have during daytime. +$meta 7 4 +example +6500 +$meta 7 8 +opt/arg +required +$meta 8 8 +opt/long +temp-day +$meta 4 14 +type +unsigned_short +$key string 10 0 +temp/night + +$meta 7 4 +default +4500 +$meta 11 62 +description +The color temperature the screen should have during nighttime. +$meta 7 4 +example +4500 +$meta 7 8 +opt/arg +required +$meta 8 10 +opt/long +temp-night +$meta 4 14 +type +unsigned_short +$key string 18 0 +temp/oneshotmanual + +$meta 7 4 +default +6500 +$meta 11 77 +description +The color temperature the screen should have when oneshotmanual mode is used. +$meta 7 4 +example +6500 +$meta 7 8 +opt/arg +required +$meta 8 18 +opt/long +temp-oneshotmanual +$meta 4 14 +type +unsigned_short +$key string 7 0 +verbose + +$meta 7 1 +default +0 +$meta 11 15 +description +Verbose output. +$meta 7 1 +example +1 +$meta 3 1 +opt +v +$meta 7 4 +opt/arg +none +$meta 4 7 +type +boolean +$key string 7 0 +version + +$meta 7 1 +default +0 +$meta 11 21 +description +Show program version. +$meta 7 1 +example +1 +$meta 3 1 +opt +V +$meta 7 4 +opt/arg +none +$meta 4 7 +type +boolean +$end diff --git a/src/gamma-drm.c b/src/gamma-drm.c index 04d4f2c0..fcf9dcb6 100644 --- a/src/gamma-drm.c +++ b/src/gamma-drm.c @@ -254,21 +254,13 @@ drm_print_help(FILE *f) } static int -drm_set_option(drm_state_t *state, const char *key, const char *value) +drm_set_option(drm_state_t *state, const char *key, const unsigned short value) { if (strcasecmp(key, "card") == 0) { - state->card_num = atoi(value); + state->card_num = value; } else if (strcasecmp(key, "crtc") == 0) { - state->crtc_num = atoi(value); - if (state->crtc_num < 0) { - fprintf(stderr, _("CRTC must be a non-negative integer\n")); - return -1; - } - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; - } - + state->crtc_num = value; + } return 0; } @@ -324,7 +316,7 @@ drm_set_temperature( const gamma_method_t drm_gamma_method = { - "drm", 0, + "drm", 1, (gamma_method_init_func *)drm_init, (gamma_method_start_func *)drm_start, (gamma_method_free_func *)drm_free, diff --git a/src/gamma-dummy.c b/src/gamma-dummy.c index 1730743b..937dd88c 100644 --- a/src/gamma-dummy.c +++ b/src/gamma-dummy.c @@ -66,10 +66,9 @@ gamma_dummy_print_help(FILE *f) } static int -gamma_dummy_set_option(void *state, const char *key, const char *value) +gamma_dummy_set_option(void *state, const char *key, const unsigned short value) { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; + return 0; } static int @@ -82,7 +81,7 @@ gamma_dummy_set_temperature( const gamma_method_t dummy_gamma_method = { - "dummy", 0, + "dummy", 1, (gamma_method_init_func *)gamma_dummy_init, (gamma_method_start_func *)gamma_dummy_start, (gamma_method_free_func *)gamma_dummy_free, diff --git a/src/gamma-quartz.c b/src/gamma-quartz.c index adbf8230..4725e97b 100644 --- a/src/gamma-quartz.c +++ b/src/gamma-quartz.c @@ -172,18 +172,14 @@ quartz_print_help(FILE *f) } static int -quartz_set_option(quartz_state_t *state, const char *key, const char *value) +quartz_set_option(quartz_state_t *state, const char *key, const unsigned short value) { if (strcasecmp(key, "preserve") == 0) { - fprintf(stderr, _("Parameter `%s` is now always on; " - " Use the `%s` command-line option" - " to disable.\n"), - key, "-P"); - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; - } - + fprintf(stderr, _("Parameter `%s` is now always on; " + " Use the `%s` command-line option" + " to disable.\n"), + key, "-P"); + } return 0; } diff --git a/src/gamma-randr.c b/src/gamma-randr.c index 388f322f..ec8d23d4 100644 --- a/src/gamma-randr.c +++ b/src/gamma-randr.c @@ -315,63 +315,14 @@ randr_print_help(FILE *f) } static int -randr_set_option(randr_state_t *state, const char *key, const char *value) +randr_set_option(randr_state_t *state, const char *key, const unsigned short value) { if (strcasecmp(key, "screen") == 0) { - state->screen_num = atoi(value); + state->screen_num = value; } else if (strcasecmp(key, "crtc") == 0) { - char *tail; - - /* Check how many crtcs are configured */ - const char *local_value = value; - while (1) { - errno = 0; - int parsed = strtol(local_value, &tail, 0); - if (parsed == 0 && (errno != 0 || - tail == local_value)) { - fprintf(stderr, _("Unable to read screen" - " number: `%s'.\n"), value); - return -1; - } else { - state->crtc_num_count += 1; - } - local_value = tail; - - if (*local_value == ',') { - local_value += 1; - } else if (*local_value == '\0') { - break; - } - } - - /* Configure all given crtcs */ + state->crtc_num_count = 1; state->crtc_num = calloc(state->crtc_num_count, sizeof(int)); - local_value = value; - for (int i = 0; i < state->crtc_num_count; i++) { - errno = 0; - int parsed = strtol(local_value, &tail, 0); - if (parsed == 0 && (errno != 0 || - tail == local_value)) { - return -1; - } else { - state->crtc_num[i] = parsed; - } - local_value = tail; - - if (*local_value == ',') { - local_value += 1; - } else if (*local_value == '\0') { - break; - } - } - } else if (strcasecmp(key, "preserve") == 0) { - fprintf(stderr, _("Parameter `%s` is now always on; " - " Use the `%s` command-line option" - " to disable.\n"), - key, "-P"); - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; + state->crtc_num[0] = value; } return 0; diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c index e604c3b3..29536aef 100644 --- a/src/gamma-vidmode.c +++ b/src/gamma-vidmode.c @@ -152,18 +152,15 @@ vidmode_print_help(FILE *f) } static int -vidmode_set_option(vidmode_state_t *state, const char *key, const char *value) +vidmode_set_option(vidmode_state_t *state, const char *key, const unsigned short value) { if (strcasecmp(key, "screen") == 0) { - state->screen_num = atoi(value); + state->screen_num = value; } else if (strcasecmp(key, "preserve") == 0) { fprintf(stderr, _("Parameter `%s` is now always on; " " Use the `%s` command-line option" " to disable.\n"), key, "-P"); - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; } return 0; diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c index 730cd0cb..f2b6c089 100644 --- a/src/gamma-w32gdi.c +++ b/src/gamma-w32gdi.c @@ -121,16 +121,13 @@ w32gdi_print_help(FILE *f) } static int -w32gdi_set_option(w32gdi_state_t *state, const char *key, const char *value) +w32gdi_set_option(w32gdi_state_t *state, const char *key, const char value) { if (strcasecmp(key, "preserve") == 0) { fprintf(stderr, _("Parameter `%s` is now always on; " " Use the `%s` command-line option" " to disable.\n"), key, "-P"); - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; } return 0; diff --git a/src/location-corelocation.m b/src/location-corelocation.m index 10d7acdf..e0213334 100644 --- a/src/location-corelocation.m +++ b/src/location-corelocation.m @@ -253,10 +253,9 @@ - (void)main static int location_corelocation_set_option( - location_corelocation_state_t *state, const char *key, const char *value) + location_corelocation_state_t *state, const char *key, const float *value) { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; + return 0; } static int diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c index 06015c50..c2e45336 100644 --- a/src/location-geoclue2.c +++ b/src/location-geoclue2.c @@ -407,10 +407,9 @@ location_geoclue2_print_help(FILE *f) static int location_geoclue2_set_option(location_geoclue2_state_t *state, - const char *key, const char *value) + const char *key, const float *value) { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; + return 0; } static int diff --git a/src/location-manual.c b/src/location-manual.c index db3a8a93..0001c89d 100644 --- a/src/location-manual.c +++ b/src/location-manual.c @@ -91,25 +91,13 @@ location_manual_print_help(FILE *f) static int location_manual_set_option(location_manual_state_t *state, const char *key, - const char *value) + const float *value) { - /* Parse float value */ - char *end; - errno = 0; - float v = strtof(value, &end); - if (errno != 0 || *end != '\0') { - fputs(_("Malformed argument.\n"), stderr); - return -1; - } - if (strcasecmp(key, "lat") == 0) { - state->loc.lat = v; + state->loc.lat = *value; } else if (strcasecmp(key, "lon") == 0) { - state->loc.lon = v; - } else { - fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); - return -1; - } + state->loc.lon = *value; + } return 0; } diff --git a/src/options.c b/src/options.c index 33bf623a..ea8ba5c2 100644 --- a/src/options.c +++ b/src/options.c @@ -35,40 +35,14 @@ #endif #include "redshift.h" -#include "config-ini.h" #include "options.h" #include "solar.h" -/* Angular elevation of the sun at which the color temperature - transition period starts and ends (in degress). - Transition during twilight, and while the sun is lower than - 3.0 degrees above the horizon. */ -#define TRANSITION_LOW SOLAR_CIVIL_TWILIGHT_ELEV -#define TRANSITION_HIGH 3.0 - -/* Default values for parameters. */ -#define DEFAULT_DAY_TEMP 6500 -#define DEFAULT_NIGHT_TEMP 4500 -#define DEFAULT_BRIGHTNESS 1.0 -#define DEFAULT_GAMMA 1.0 - - -/* A brightness string contains either one floating point value, - or two values separated by a colon. */ -static void -parse_brightness_string( - const char *str, float *bright_day, float *bright_night) -{ - char *s = strchr(str, ':'); - if (s == NULL) { - /* Same value for day and night. */ - *bright_day = *bright_night = atof(str); - } else { - *(s++) = '\0'; - *bright_day = atof(str); - *bright_night = atof(s); - } -} +#ifdef WINDOWS_BUILD +#include "elektra/windows/redshift-conf.h" +#else +#include "elektra/redshift-conf.h" +#endif /* A gamma string contains either one floating point value, or three values separated by colon. */ @@ -119,135 +93,42 @@ parse_transition_time(const char *str, const char **end) return minutes * 60 + hours * 3600; } -/* Parse transition range string e.g. "04:50-6:20". Returns negative on - failure, otherwise zero. Parsed start and end times are returned as seconds - since midnight. */ -static int -parse_transition_range(const char *str, time_range_t *range) -{ - const char *next = NULL; - int start_time = parse_transition_time(str, &next); - if (start_time < 0) return -1; - - int end_time; - if (next[0] == '\0') { - end_time = start_time; - } else if (next[0] == '-') { - next += 1; - const char *end = NULL; - end_time = parse_transition_time(next, &end); - if (end_time < 0 || end[0] != '\0') return -1; - } else { - return -1; - } - - range->start = start_time; - range->end = end_time; - - return 0; -} - -/* Print help text. */ -static void -print_help(const char *program_name) -{ - /* TRANSLATORS: help output 1 - LAT is latitude, LON is longitude, - DAY is temperature at daytime, - NIGHT is temperature at night - no-wrap */ - printf(_("Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n"), - program_name); - fputs("\n", stdout); - - /* TRANSLATORS: help output 2 - no-wrap */ - fputs(_("Set color temperature of display" - " according to time of day.\n"), stdout); - fputs("\n", stdout); - - /* TRANSLATORS: help output 3 - no-wrap */ - fputs(_(" -h\t\tDisplay this help message\n" - " -v\t\tVerbose output\n" - " -V\t\tShow program version\n"), stdout); - fputs("\n", stdout); - - /* TRANSLATORS: help output 4 - `list' must not be translated - no-wrap */ - fputs(_(" -b DAY:NIGHT\tScreen brightness to apply (between 0.1 and 1.0)\n" - " -c FILE\tLoad settings from specified configuration file\n" - " -g R:G:B\tAdditional gamma correction to apply\n" - " -l LAT:LON\tYour current location\n" - " -l PROVIDER\tSelect provider for automatic" - " location updates\n" - " \t\t(Type `list' to see available providers)\n" - " -m METHOD\tMethod to use to set color temperature\n" - " \t\t(Type `list' to see available methods)\n" - " -o\t\tOne shot mode (do not continuously adjust" - " color temperature)\n" - " -O TEMP\tOne shot manual mode (set color temperature)\n" - " -p\t\tPrint mode (only print parameters and exit)\n" - " -P\t\tReset existing gamma ramps before applying new" - " color effect\n" - " -x\t\tReset mode (remove adjustment from screen)\n" - " -r\t\tDisable fading between color temperatures\n" - " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"), - stdout); - fputs("\n", stdout); - - /* TRANSLATORS: help output 5 */ - printf(_("The neutral temperature is %uK. Using this value will not change " - "the color\ntemperature of the display. Setting the color temperature " - "to a value higher\nthan this results in more blue light, and setting " - "a lower value will result in\nmore red light.\n"), - NEUTRAL_TEMP); - - fputs("\n", stdout); - - /* TRANSLATORS: help output 6 */ - printf(_("Default values:\n\n" - " Daytime temperature: %uK\n" - " Night temperature: %uK\n"), - DEFAULT_DAY_TEMP, DEFAULT_NIGHT_TEMP); - - fputs("\n", stdout); - - /* TRANSLATORS: help output 7 */ - printf(_("Please report bugs to <%s>\n"), PACKAGE_BUGREPORT); -} - /* Print list of adjustment methods. */ static void print_method_list(const gamma_method_t *gamma_methods) { - fputs(_("Available adjustment methods:\n"), stdout); + if (gamma_methods[0].name == NULL) { + printf("This build of redshift contains no adjustment methods that work on your system!"); + return; + } + + fputs(_("Available adjustment methods in this build of redshift:\n"), stdout); for (int i = 0; gamma_methods[i].name != NULL; i++) { printf(" %s\n", gamma_methods[i].name); } fputs("\n", stdout); - fputs(_("Specify colon-separated options with" - " `-m METHOD:OPTIONS'.\n"), stdout); - /* TRANSLATORS: `help' must not be translated. */ - fputs(_("Try `-m METHOD:help' for help.\n"), stdout); + /* TRANSLATORS: `help-adjustment-methods' must not be translated. */ + fputs(_("Try `--help` and `--help-methods' for help about the methods.\n"), stdout); } /* Print list of location providers. */ static void print_provider_list(const location_provider_t location_providers[]) { - fputs(_("Available location providers:\n"), stdout); + if (location_providers[0].name == NULL) { + printf("This build of redshift contains no adjustment methods that work on your system!"); + return; + } + + fputs(_("Available location providers in this build of redshift:\n"), stdout); for (int i = 0; location_providers[i].name != NULL; i++) { printf(" %s\n", location_providers[i].name); } fputs("\n", stdout); - fputs(_("Specify colon-separated options with" - "`-l PROVIDER:OPTIONS'.\n"), stdout); - /* TRANSLATORS: `help' must not be translated. */ - fputs(_("Try `-l PROVIDER:help' for help.\n"), stdout); + /* TRANSLATORS: `help-location-providers' must not be translated. */ + fputs(_("Try `--help` and `--help-providers' for help about the providers.\n"), stdout); } /* Return the gamma method with the given name. */ @@ -283,6 +164,191 @@ find_location_provider( return provider; } +/** + * + * Load options from Elektra, store them in the passed options struct and configure the gamma_methods and location_providers supported in this build.. + * + * @param options A pointer to the options struct where values should be stored. + * @param elektra A pointer to the elektra instance. + * @param gamma_methods A pointer to the gamma_methods supported in this build of redshift.. + * @param location_providers A pointer to the location_providers. supported in this build of redshift. + * @return 0 if loading was successful, -1 on error + */ +int +options_load_from_elektra( + options_t *options, + Elektra *elektra, + const gamma_method_t *gamma_methods, + const location_provider_t *location_providers) { + /** + * Before using Elektra, there were two sources for configuration: CLI options and config file. + * From redshift's point of view there is only one source now, namely Elektra. + */ + // BEGIN Block: Options from parse_command_line_option and parse_config_file_option + + // Help (with short option "-h") + if(elektraGetHelp(elektra)) { + printHelpMessage(NULL, NULL, NULL); + return -1; + } + + // Version + if (elektraGetVersion(elektra)) { + printf("%s\n", PACKAGE_STRING); + return -1; + } + + // Verbose + options->verbose = elektraGetVerbose(elektra); + + // Programm mode + options->mode = elektraGetMode(elektra); + if(options->mode == ELEKTRA_ENUM_MODE_ONESHOTMANUAL) { + options->temp_set = elektraGetTempOneshotmanual(elektra); + } + + // Brightness + *(&options->scheme.day.brightness) = elektraGetBrightnessDay(elektra); + *(&options->scheme.night.brightness) = elektraGetBrightnessNight(elektra); + + // Gamma + const char *gammaDayString = elektraGetGammaDay(elektra); + parse_gamma_string(gammaDayString, *(&options->scheme.day.gamma)); + const char *gammaNightString = elektraGetGammaNight(elektra); + parse_gamma_string(gammaNightString, *(&options->scheme.night.gamma)); + + // Location and adjustment help + if (elektraGetAdjustmentMethodHelp(elektra)) { + for (int i = 0; gamma_methods[i].name != NULL; i++) { + const gamma_method_t *m = &gamma_methods[i]; + printf(_("Help section for method `%s':\n"), m->name); + printf(_("=============================\n")); + m->print_help(stdout); + printf(_("=============================\n\n")); + } + return -1; + } + + if (elektraGetProviderLocationHelp(elektra)) { + for (int i = 0; location_providers[i].name != NULL; i++) { + const location_provider_t *p = &location_providers[i]; + printf(_("Help section for provider `%s':\n"), p->name); + printf(_("=============================\n")); + p->print_help(stdout); + printf(_("=============================\n\n")); + } + return -1; + } + + // Location provider + ElektraEnumProviderLocation locationProvider = elektraGetProviderLocation(elektra); + if (locationProvider == ELEKTRA_ENUM_PROVIDER_LOCATION_LIST) { + // In list mode, print list of supported location providers. + print_provider_list(location_providers); + return -1; + } + else if (locationProvider == ELEKTRA_ENUM_PROVIDER_LOCATION_AUTO) { + // In auto mode, a supported provider will be chosen in redshift.c:main(...) + options->provider = NULL; + } + else { + // Otherwise, try to find the provider by name. + const char *locationProviderName = elektraEnumProviderLocationToConstString( + elektraGetProviderLocation(elektra) + ); + const location_provider_t *provider = find_location_provider(location_providers, locationProviderName); + if(provider == NULL) { + // User picked a locationProvider provider which is not supported in this build. + fprintf(stderr, _("The chosen location provider \"%s\" is not supported in this build of redshift.\n"), locationProviderName); + return -1; + } + else { + options->provider = provider; + } + } + // Set lat and lon. Will only be used if the manual provider is chosen + const float lat = elektraGetProviderLocationManualLat(elektra); + options->provider_manual_arg_lat = lat; + const float lon = elektraGetProviderLocationManualLon(elektra); + options->provider_manual_arg_lon = lon; + + // Adjustment method + ElektraEnumAdjustmentMethod adjustmentMethod = elektraGetAdjustmentMethod(elektra); + if (adjustmentMethod == ELEKTRA_ENUM_ADJUSTMENT_METHOD_LIST) { + // In list mode, print list of supported adjustment methods. + print_method_list(gamma_methods); + return -1; + } else if (adjustmentMethod == ELEKTRA_ENUM_ADJUSTMENT_METHOD_AUTO) { + // In auto mode, a supported method will be chosen in redshift.c:main(...) + options->method = NULL; + } else { + // Otherwise, try to find the method by name. + const char * adjustmentMethodName = elektraEnumAdjustmentMethodToConstString( + elektraGetAdjustmentMethod(elektra) + ); + const gamma_method_t *method = find_gamma_method(gamma_methods, adjustmentMethodName); + if (method == NULL) { + // User picked a method which is not supported in this build. + fprintf(stderr, _("The chosen adjustment method \"%s\" is not supported in this build of redshift.\n"), adjustmentMethodName); + return -1; + } + else { + options->method = method; + } + } + + options->method_crtc = elektraGetAdjustmentCrtc(elektra); + options->method_screen = elektraGetAdjustmentScreen(elektra); + options->method_drm_card = elektraGetAdjustmentDrmCard(elektra); + + + // Preserve gamma + options->preserve_gamma = elektraGetGammaPreserve(elektra); + + // Fade + options->use_fade = !elektraGetFadeFast(elektra); + + // Temperature + options->scheme.day.temperature = elektraGetTempDay(elektra); + options->scheme.night.temperature = elektraGetTempNight(elektra); + + // END Block + + // BEGIN Block: From parse_config_file_option (if not already handled above) + + // Elevation + options->scheme.high = elektraGetProviderLocationElevationHigh(elektra); + options->scheme.low = elektraGetProviderLocationElevationLow(elektra); + + // Time + options->scheme.use_time = elektraGetProvider(elektra) == ELEKTRA_ENUM_PROVIDER_TIME; + + if(options->scheme.use_time) { + const char* dawnStartString = elektraGetProviderTimeDawnStart(elektra); + const char* dawnEndString = elektraGetProviderTimeDawnEnd(elektra); + const char* duskStartString = elektraGetProviderTimeDuskStart(elektra); + const char* duskEndString = elektraGetProviderTimeDuskEnd(elektra); + options->scheme.dawn.start = parse_transition_time(dawnStartString, NULL); + options->scheme.dawn.end = parse_transition_time(dawnEndString, NULL); + options->scheme.dusk.start = parse_transition_time(duskStartString, NULL); + options->scheme.dusk.end = parse_transition_time(duskEndString, NULL); + + // Validation from redshift.c:main(...) + if (options->scheme.dawn.start > options->scheme.dawn.end || + options->scheme.dawn.end > options->scheme.dusk.start || + options->scheme.dusk.start > options->scheme.dusk.end) { + fputs(_("Invalid dawn/dusk time configuration!\n"), + stderr); + return -1; + } + } + // END Block + + + + return 0; +} + /* Initialize options struct. */ void @@ -290,10 +356,6 @@ options_init(options_t *options) { options->config_filepath = NULL; - /* Default elevation values. */ - options->scheme.high = TRANSITION_HIGH; - options->scheme.low = TRANSITION_LOW; - /* Settings for day, night and transition period. Initialized to indicate that the values are not set yet. */ options->scheme.use_time = 0; @@ -314,366 +376,14 @@ options_init(options_t *options) options->temp_set = -1; options->method = NULL; - options->method_args = NULL; + options->method_crtc = -1; + options->method_screen = -1; + options->method_drm_card = -1; options->provider = NULL; - options->provider_args = NULL; options->use_fade = -1; options->preserve_gamma = 1; - options->mode = PROGRAM_MODE_CONTINUAL; + options->mode = ELEKTRA_ENUM_MODE_CONTINUAL; options->verbose = 0; } - -/* Parse a single option from the command-line. */ -static int -parse_command_line_option( - const char option, char *value, options_t *options, - const char *program_name, const gamma_method_t *gamma_methods, - const location_provider_t *location_providers) -{ - int r; - char *s; - - switch (option) { - case 'b': - parse_brightness_string( - value, &options->scheme.day.brightness, - &options->scheme.night.brightness); - break; - case 'c': - free(options->config_filepath); - options->config_filepath = strdup(value); - break; - case 'g': - r = parse_gamma_string(value, options->scheme.day.gamma); - if (r < 0) { - fputs(_("Malformed gamma argument.\n"), stderr); - fputs(_("Try `-h' for more information.\n"), stderr); - return -1; - } - - /* Set night gamma to the same value as day gamma. - To set these to distinct values use the config - file. */ - memcpy(options->scheme.night.gamma, - options->scheme.day.gamma, - sizeof(options->scheme.night.gamma)); - break; - case 'h': - print_help(program_name); - exit(EXIT_SUCCESS); - break; - case 'l': - /* Print list of providers if argument is `list' */ - if (strcasecmp(value, "list") == 0) { - print_provider_list(location_providers); - exit(EXIT_SUCCESS); - } - - char *provider_name = NULL; - - /* Don't save the result of strtof(); we simply want - to know if value can be parsed as a float. */ - errno = 0; - char *end; - strtof(value, &end); - if (errno == 0 && *end == ':') { - /* Use instead as arguments to `manual'. */ - provider_name = "manual"; - options->provider_args = value; - } else { - /* Split off provider arguments. */ - s = strchr(value, ':'); - if (s != NULL) { - *(s++) = '\0'; - options->provider_args = s; - } - - provider_name = value; - } - - /* Lookup provider from name. */ - options->provider = find_location_provider( - location_providers, provider_name); - if (options->provider == NULL) { - fprintf(stderr, _("Unknown location provider `%s'.\n"), - provider_name); - return -1; - } - - /* Print provider help if arg is `help'. */ - if (options->provider_args != NULL && - strcasecmp(options->provider_args, "help") == 0) { - options->provider->print_help(stdout); - exit(EXIT_SUCCESS); - } - break; - case 'm': - /* Print list of methods if argument is `list' */ - if (strcasecmp(value, "list") == 0) { - print_method_list(gamma_methods); - exit(EXIT_SUCCESS); - } - - /* Split off method arguments. */ - s = strchr(value, ':'); - if (s != NULL) { - *(s++) = '\0'; - options->method_args = s; - } - - /* Find adjustment method by name. */ - options->method = find_gamma_method(gamma_methods, value); - if (options->method == NULL) { - /* TRANSLATORS: This refers to the method - used to adjust colors e.g VidMode */ - fprintf(stderr, _("Unknown adjustment method `%s'.\n"), - value); - return -1; - } - - /* Print method help if arg is `help'. */ - if (options->method_args != NULL && - strcasecmp(options->method_args, "help") == 0) { - options->method->print_help(stdout); - exit(EXIT_SUCCESS); - } - break; - case 'o': - options->mode = PROGRAM_MODE_ONE_SHOT; - break; - case 'O': - options->mode = PROGRAM_MODE_MANUAL; - options->temp_set = atoi(value); - break; - case 'p': - options->mode = PROGRAM_MODE_PRINT; - break; - case 'P': - options->preserve_gamma = 0; - break; - case 'r': - options->use_fade = 0; - break; - case 't': - s = strchr(value, ':'); - if (s == NULL) { - fputs(_("Malformed temperature argument.\n"), stderr); - fputs(_("Try `-h' for more information.\n"), stderr); - return -1; - } - *(s++) = '\0'; - options->scheme.day.temperature = atoi(value); - options->scheme.night.temperature = atoi(s); - break; - case 'v': - options->verbose = 1; - break; - case 'V': - printf("%s\n", PACKAGE_STRING); - exit(EXIT_SUCCESS); - break; - case 'x': - options->mode = PROGRAM_MODE_RESET; - break; - case '?': - fputs(_("Try `-h' for more information.\n"), stderr); - return -1; - break; - } - - return 0; -} - -/* Parse command line arguments. */ -void -options_parse_args( - options_t *options, int argc, char *argv[], - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers) -{ - const char* program_name = argv[0]; - int opt; - while ((opt = getopt(argc, argv, "b:c:g:hl:m:oO:pPrt:vVx")) != -1) { - char option = opt; - int r = parse_command_line_option( - option, optarg, options, program_name, gamma_methods, - location_providers); - if (r < 0) exit(EXIT_FAILURE); - } -} - -/* Parse a single key-value pair from the configuration file. */ -static int -parse_config_file_option( - const char *key, const char *value, options_t *options, - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers) -{ - if (strcasecmp(key, "temp-day") == 0) { - if (options->scheme.day.temperature < 0) { - options->scheme.day.temperature = atoi(value); - } - } else if (strcasecmp(key, "temp-night") == 0) { - if (options->scheme.night.temperature < 0) { - options->scheme.night.temperature = atoi(value); - } - } else if (strcasecmp(key, "transition") == 0 || - strcasecmp(key, "fade") == 0) { - /* "fade" is preferred, "transition" is - deprecated as the setting key. */ - if (options->use_fade < 0) { - options->use_fade = !!atoi(value); - } - } else if (strcasecmp(key, "brightness") == 0) { - if (isnan(options->scheme.day.brightness)) { - options->scheme.day.brightness = atof(value); - } - if (isnan(options->scheme.night.brightness)) { - options->scheme.night.brightness = atof(value); - } - } else if (strcasecmp(key, "brightness-day") == 0) { - if (isnan(options->scheme.day.brightness)) { - options->scheme.day.brightness = atof(value); - } - } else if (strcasecmp(key, "brightness-night") == 0) { - if (isnan(options->scheme.night.brightness)) { - options->scheme.night.brightness = atof(value); - } - } else if (strcasecmp(key, "elevation-high") == 0) { - options->scheme.high = atof(value); - } else if (strcasecmp(key, "elevation-low") == 0) { - options->scheme.low = atof(value); - } else if (strcasecmp(key, "gamma") == 0) { - if (isnan(options->scheme.day.gamma[0])) { - int r = parse_gamma_string( - value, options->scheme.day.gamma); - if (r < 0) { - fputs(_("Malformed gamma setting.\n"), stderr); - return -1; - } - memcpy(options->scheme.night.gamma, - options->scheme.day.gamma, - sizeof(options->scheme.night.gamma)); - } - } else if (strcasecmp(key, "gamma-day") == 0) { - if (isnan(options->scheme.day.gamma[0])) { - int r = parse_gamma_string( - value, options->scheme.day.gamma); - if (r < 0) { - fputs(_("Malformed gamma setting.\n"), stderr); - return -1; - } - } - } else if (strcasecmp(key, "gamma-night") == 0) { - if (isnan(options->scheme.night.gamma[0])) { - int r = parse_gamma_string( - value, options->scheme.night.gamma); - if (r < 0) { - fputs(_("Malformed gamma setting.\n"), stderr); - return -1; - } - } - } else if (strcasecmp(key, "adjustment-method") == 0) { - if (options->method == NULL) { - options->method = find_gamma_method( - gamma_methods, value); - if (options->method == NULL) { - fprintf(stderr, _("Unknown adjustment" - " method `%s'.\n"), value); - return -1; - } - } - } else if (strcasecmp(key, "location-provider") == 0) { - if (options->provider == NULL) { - options->provider = find_location_provider( - location_providers, value); - if (options->provider == NULL) { - fprintf(stderr, _("Unknown location" - " provider `%s'.\n"), value); - return -1; - } - } - } else if (strcasecmp(key, "dawn-time") == 0) { - if (options->scheme.dawn.start < 0) { - int r = parse_transition_range( - value, &options->scheme.dawn); - if (r < 0) { - fprintf(stderr, _("Malformed dawn-time" - " setting `%s'.\n"), value); - return -1; - } - } - } else if (strcasecmp(key, "dusk-time") == 0) { - if (options->scheme.dusk.start < 0) { - int r = parse_transition_range( - value, &options->scheme.dusk); - if (r < 0) { - fprintf(stderr, _("Malformed dusk-time" - " setting `%s'.\n"), value); - return -1; - } - } - } else { - fprintf(stderr, _("Unknown configuration setting `%s'.\n"), - key); - } - - return 0; -} - -/* Parse options defined in the config file. */ -void -options_parse_config_file( - options_t *options, config_ini_state_t *config_state, - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers) -{ - /* Read global config settings. */ - config_ini_section_t *section = config_ini_get_section( - config_state, "redshift"); - if (section == NULL) return; - - config_ini_setting_t *setting = section->settings; - while (setting != NULL) { - int r = parse_config_file_option( - setting->name, setting->value, options, - gamma_methods, location_providers); - if (r < 0) exit(EXIT_FAILURE); - - setting = setting->next; - } -} - -/* Replace unspecified options with default values. */ -void -options_set_defaults(options_t *options) -{ - if (options->scheme.day.temperature < 0) { - options->scheme.day.temperature = DEFAULT_DAY_TEMP; - } - if (options->scheme.night.temperature < 0) { - options->scheme.night.temperature = DEFAULT_NIGHT_TEMP; - } - - if (isnan(options->scheme.day.brightness)) { - options->scheme.day.brightness = DEFAULT_BRIGHTNESS; - } - if (isnan(options->scheme.night.brightness)) { - options->scheme.night.brightness = DEFAULT_BRIGHTNESS; - } - - if (isnan(options->scheme.day.gamma[0])) { - options->scheme.day.gamma[0] = DEFAULT_GAMMA; - options->scheme.day.gamma[1] = DEFAULT_GAMMA; - options->scheme.day.gamma[2] = DEFAULT_GAMMA; - } - if (isnan(options->scheme.night.gamma[0])) { - options->scheme.night.gamma[0] = DEFAULT_GAMMA; - options->scheme.night.gamma[1] = DEFAULT_GAMMA; - options->scheme.night.gamma[2] = DEFAULT_GAMMA; - } - - if (options->use_fade < 0) options->use_fade = 1; -} diff --git a/src/options.h b/src/options.h index 9993a07f..765e47e5 100644 --- a/src/options.h +++ b/src/options.h @@ -21,13 +21,18 @@ #define REDSHIFT_OPTIONS_H #include "redshift.h" +#ifdef WINDOWS_BUILD +#include "elektra/windows/redshift-conf.h" +#else +#include "elektra/redshift-conf.h" +#endif typedef struct { /* Path to config file */ char *config_filepath; transition_scheme_t scheme; - program_mode_t mode; + ElektraEnumMode mode; int verbose; /* Temperature to set in manual mode. */ @@ -39,25 +44,25 @@ typedef struct { /* Selected gamma method. */ const gamma_method_t *method; - /* Arguments for gamma method. */ - char *method_args; + /* Options for adjustment methods */ + unsigned short method_crtc; + unsigned short method_screen; + unsigned short method_drm_card; /* Selected location provider. */ const location_provider_t *provider; - /* Arguments for location provider. */ - char *provider_args; + /* Lat, lon for location provider. */ + float provider_manual_arg_lat; + float provider_manual_arg_lon; } options_t; +int +options_load_from_elektra( + options_t *options, + Elektra *elektra, + const gamma_method_t *gamma_methods, + const location_provider_t *location_providers); void options_init(options_t *options); -void options_parse_args( - options_t *options, int argc, char *argv[], - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers); -void options_parse_config_file( - options_t *options, config_ini_state_t *config_state, - const gamma_method_t *gamma_methods, - const location_provider_t *location_providers); -void options_set_defaults(options_t *options); #endif /* ! REDSHIFT_OPTIONS_H */ diff --git a/src/redshift.c b/src/redshift.c index d2ba577c..846758ee 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -60,13 +60,18 @@ int poll(struct pollfd *fds, int nfds, int timeout) { abort(); return -1; } #endif #include "redshift.h" -#include "config-ini.h" #include "solar.h" #include "systemtime.h" #include "hooks.h" #include "signals.h" #include "options.h" +#ifdef WINDOWS_BUILD +#include "elektra/windows/redshift-conf.h" +#else +#include "elektra/redshift-conf.h" +#endif + /* pause() is not defined on windows platform but is not needed either. Use a noop macro instead. */ #ifdef __WIN32__ @@ -110,15 +115,15 @@ int poll(struct pollfd *fds, int nfds, int timeout) { abort(); return -1; } #define CLAMP(lo,mid,up) (((lo) > (mid)) ? (lo) : (((mid) < (up)) ? (mid) : (up))) -/* Bounds for parameters. */ +/* Bounds for parameters. + * 1. LAT, LON is required to check location returned by location providers. + * 2. GAMMA is required to check gamma string returned by Elektra. + * All other parameters are checked by Elektra. + * */ #define MIN_LAT -90.0 #define MAX_LAT 90.0 #define MIN_LON -180.0 #define MAX_LON 180.0 -#define MIN_TEMP 1000 -#define MAX_TEMP 25000 -#define MIN_BRIGHTNESS 0.1 -#define MAX_BRIGHTNESS 1.0 #define MIN_GAMMA 0.1 #define MAX_GAMMA 10.0 @@ -241,21 +246,8 @@ print_period(period_t period, double transition) static void print_location(const location_t *location) { - /* TRANSLATORS: Abbreviation for `north' */ - const char *north = _("N"); - /* TRANSLATORS: Abbreviation for `south' */ - const char *south = _("S"); - /* TRANSLATORS: Abbreviation for `east' */ - const char *east = _("E"); - /* TRANSLATORS: Abbreviation for `west' */ - const char *west = _("W"); - - /* TRANSLATORS: Append degree symbols after %f if possible. - The string following each number is an abreviation for - north, source, east or west (N, S, E, W). */ - printf(_("Location: %.2f %s, %.2f %s\n"), - fabs(location->lat), location->lat >= 0.f ? north : south, - fabs(location->lon), location->lon >= 0.f ? east : west); + /* TRANSLATORS: Append degree symbols after %f if possible.*/ + printf(_("Location is now available! Latitude: %.2f, longitude: %.2f\n"), location->lat, location->lon); } /* Interpolate color setting structs given alpha. */ @@ -320,89 +312,35 @@ color_setting_reset(color_setting_t *color) static int provider_try_start(const location_provider_t *provider, - location_state_t **state, config_ini_state_t *config, - char *args) + location_state_t **state, options_t *options_state) { int r; r = provider->init(state); if (r < 0) { - fprintf(stderr, _("Initialization of %s failed.\n"), + fprintf(stderr, _("Initialization of location provider %s failed.\n"), provider->name); return -1; } - /* Set provider options from config file. */ - config_ini_section_t *section = - config_ini_get_section(config, provider->name); - if (section != NULL) { - config_ini_setting_t *setting = section->settings; - while (setting != NULL) { - r = provider->set_option(*state, setting->name, - setting->value); - if (r < 0) { - provider->free(*state); - fprintf(stderr, _("Failed to set %s" - " option.\n"), - provider->name); - /* TRANSLATORS: `help' must not be - translated. */ - fprintf(stderr, _("Try `-l %s:help' for more" - " information.\n"), - provider->name); - return -1; - } - setting = setting->next; - } - } - - /* Set provider options from command line. */ - const char *manual_keys[] = { "lat", "lon" }; - int i = 0; - while (args != NULL) { - char *next_arg = strchr(args, ':'); - if (next_arg != NULL) *(next_arg++) = '\0'; - - const char *key = args; - char *value = strchr(args, '='); - if (value == NULL) { - /* The options for the "manual" method can be set - without keys on the command line for convencience - and for backwards compatability. We add the proper - keys here before calling set_option(). */ - if (strcmp(provider->name, "manual") == 0 && - i < sizeof(manual_keys)/sizeof(manual_keys[0])) { - key = manual_keys[i]; - value = args; - } else { - fprintf(stderr, _("Failed to parse option `%s'.\n"), - args); - return -1; - } - } else { - *(value++) = '\0'; - } - - r = provider->set_option(*state, key, value); - if (r < 0) { - provider->free(*state); - fprintf(stderr, _("Failed to set %s option.\n"), - provider->name); - /* TRANSLATORS: `help' must not be translated. */ - fprintf(stderr, _("Try `-l %s:help' for more" - " information.\n"), provider->name); - return -1; - } - - args = next_arg; - i += 1; - } - - /* Start provider. */ + if (strcmp(provider->name, "manual") == 0) { + int r1 = provider->set_option(*state, "lat", &options_state->provider_manual_arg_lat); + int r2 = provider->set_option(*state, "lon", &options_state->provider_manual_arg_lon); + if (r1 < 0 || r2 < 0) { + provider->free(*state); + fprintf(stderr, _("Failed to set %s option.\n"), + provider->name); + /* TRANSLATORS: `help' and `--help-providers' must not be translated. */ + fprintf(stderr, _("Try `--help' and `--help-providers' for more" + " information.\n")); + return -1; + } + } + /* Start provider. */ r = provider->start(*state); if (r < 0) { provider->free(*state); - fprintf(stderr, _("Failed to start provider %s.\n"), + fprintf(stderr, _("Failed to start location provider %s.\n"), provider->name); return -1; } @@ -412,69 +350,31 @@ provider_try_start(const location_provider_t *provider, static int method_try_start(const gamma_method_t *method, - gamma_state_t **state, config_ini_state_t *config, char *args) + gamma_state_t **state, options_t *options) { int r; r = method->init(state); if (r < 0) { - fprintf(stderr, _("Initialization of %s failed.\n"), + fprintf(stderr, _("Initialization of adjustment method %s failed.\n"), method->name); return -1; } - /* Set method options from config file. */ - config_ini_section_t *section = - config_ini_get_section(config, method->name); - if (section != NULL) { - config_ini_setting_t *setting = section->settings; - while (setting != NULL) { - r = method->set_option( - *state, setting->name, setting->value); - if (r < 0) { - method->free(*state); - fprintf(stderr, _("Failed to set %s" - " option.\n"), - method->name); - /* TRANSLATORS: `help' must not be - translated. */ - fprintf(stderr, _("Try `-m %s:help' for more" - " information.\n"), - method->name); - return -1; - } - setting = setting->next; - } - } - - /* Set method options from command line. */ - while (args != NULL) { - char *next_arg = strchr(args, ':'); - if (next_arg != NULL) *(next_arg++) = '\0'; - - const char *key = args; - char *value = strchr(args, '='); - if (value == NULL) { - fprintf(stderr, _("Failed to parse option `%s'.\n"), - args); - return -1; - } else { - *(value++) = '\0'; - } - - r = method->set_option(*state, key, value); - if (r < 0) { - method->free(*state); - fprintf(stderr, _("Failed to set %s option.\n"), - method->name); - /* TRANSLATORS: `help' must not be translated. */ - fprintf(stderr, _("Try -m %s:help' for more" - " information.\n"), method->name); - return -1; - } - - args = next_arg; - } + int r1 = method->set_option(*state, "crtc", options->method_crtc); + int r2 = method->set_option(*state, "screen", options->method_screen); + int r3 = method->set_option(*state, "card", options->method_drm_card); + if (r1 < 0 || r2 < 0 || r3 < 0) { + method->free(*state); + fprintf(stderr, _("Failed to set %s" + " option.\n"), + method->name); + /* TRANSLATORS: `help' and `--help-methods' must not be + translated. */ + fprintf(stderr, _("Try `--help' or `--help-methods' for more" + " information.\n")); + return -1; + } /* Start method. */ r = method->start(*state); @@ -638,7 +538,7 @@ run_continual_mode(const location_provider_t *provider, int need_location = !scheme->use_time; if (need_location) { fputs(_("Waiting for initial location" - " to become available...\n"), stderr); + " to become available...\n"), stdout); /* Get initial location from provider */ r = provider_get_location(provider, location_state, -1, &loc); @@ -890,11 +790,43 @@ run_continual_mode(const location_provider_t *provider, } -int -main(int argc, char *argv[]) +static void onFatalError (ElektraError * error) +{ + fprintf (stderr, "Accessing redshift's configuration failed: \n%s\n", elektraErrorDescription (error)); + elektraErrorReset (&error); + exit (EXIT_FAILURE); +} + + +int main(int argc, const char * const *argv, const char * const *envp) { int r; + exitForSpecload (argc, argv); + ElektraError * error = NULL; + Elektra * elektra = NULL; + int rc = loadConfiguration (&elektra, argc, argv, envp, &error); + + if (rc == -1) + { + fprintf (stderr, "Opening redshift's configuration failed: \n%s\n", elektraErrorDescription (error)); + elektraErrorReset (&error); + exit (EXIT_FAILURE); + } + + if (rc == 1) + { + // help mode - application was called with '-h' or '--help' + // for more information see "Command line options" below + printHelpMessage (elektra, NULL, NULL); + elektraClose (elektra); + exit (EXIT_SUCCESS); + } + // register error handler + elektraFatalErrorHandler (elektra, onFatalError); + // loadConfiguration succeeded, proceed with program + + #ifdef ENABLE_NLS /* Init locale */ setlocale(LC_CTYPE, ""); @@ -907,9 +839,6 @@ main(int argc, char *argv[]) /* List of gamma methods. */ const gamma_method_t gamma_methods[] = { -#ifdef ENABLE_DRM - drm_gamma_method, -#endif #ifdef ENABLE_RANDR randr_gamma_method, #endif @@ -921,6 +850,9 @@ main(int argc, char *argv[]) #endif #ifdef ENABLE_WINGDI w32gdi_gamma_method, +#endif +#ifdef ENABLE_DRM + drm_gamma_method, #endif dummy_gamma_method, { NULL } @@ -946,81 +878,51 @@ main(int argc, char *argv[]) options_t options; options_init(&options); - options_parse_args( - &options, argc, argv, gamma_methods, location_providers); - - /* Load settings from config file. */ - config_ini_state_t config_state; - r = config_ini_init(&config_state, options.config_filepath); - if (r < 0) { - fputs("Unable to load config file.\n", stderr); - exit(EXIT_FAILURE); - } - - free(options.config_filepath); - - options_parse_config_file( - &options, &config_state, gamma_methods, location_providers); - - options_set_defaults(&options); - - if (options.scheme.dawn.start >= 0 || options.scheme.dawn.end >= 0 || - options.scheme.dusk.start >= 0 || options.scheme.dusk.end >= 0) { - if (options.scheme.dawn.start < 0 || - options.scheme.dawn.end < 0 || - options.scheme.dusk.start < 0 || - options.scheme.dusk.end < 0) { - fputs(_("Partitial time-configuration not" - " supported!\n"), stderr); - exit(EXIT_FAILURE); - } - - if (options.scheme.dawn.start > options.scheme.dawn.end || - options.scheme.dawn.end > options.scheme.dusk.start || - options.scheme.dusk.start > options.scheme.dusk.end) { - fputs(_("Invalid dawn/dusk time configuration!\n"), - stderr); - exit(EXIT_FAILURE); - } - - options.scheme.use_time = 1; - } + location_state_t *location_state; + /* Load settings from elektra. */ + r = options_load_from_elektra(&options, elektra, gamma_methods, location_providers); + // After loading everything from elektra, close it. + elektraClose (elektra); + if (r < 0) { + // Error message printed in options_load_from_elektra(...) + exit(EXIT_FAILURE); + } /* Initialize location provider if needed. If provider is NULL try all providers until one that works is found. */ - location_state_t *location_state; /* Location is not needed for reset mode and manual mode. */ int need_location = - options.mode != PROGRAM_MODE_RESET && - options.mode != PROGRAM_MODE_MANUAL && + options.mode != ELEKTRA_ENUM_MODE_RESET && + options.mode != ELEKTRA_ENUM_MODE_ONESHOTMANUAL && !options.scheme.use_time; if (need_location) { if (options.provider != NULL) { /* Use provider specified on command line. */ r = provider_try_start( options.provider, &location_state, - &config_state, options.provider_args); + &options); if (r < 0) exit(EXIT_FAILURE); } else { /* Try all providers, use the first that works. */ + fputs(_("You have not configured a location provider. Redshift will try to automatically choose a suitable one.\n"), stdout); for (int i = 0; location_providers[i].name != NULL; i++) { const location_provider_t *p = &location_providers[i]; - fprintf(stderr, + fprintf(stdout, _("Trying location provider `%s'...\n"), p->name); r = provider_try_start(p, &location_state, - &config_state, NULL); + &options); if (r < 0) { - fputs(_("Trying next provider...\n"), - stderr); + fputs(_("Trying next location provider...\n"), + stdout); continue; } /* Found provider that works. */ - printf(_("Using provider `%s'.\n"), p->name); + printf(_("`%s' works and will be used.\n"), p->name); options.provider = p; break; } @@ -1028,8 +930,7 @@ main(int argc, char *argv[]) /* Failure if no providers were successful at this point. */ if (options.provider == NULL) { - fputs(_("No more location providers" - " to try.\n"), stderr); + fputs(_("Redshift was unable to determine your location. Reason: None of the location providers of this build work on your system. Execute \"redshift --location-provider list\" to see which providers are supported in this build. Exiting now.\n"), stderr); exit(EXIT_FAILURE); } } @@ -1049,46 +950,14 @@ main(int argc, char *argv[]) } } - if (options.mode != PROGRAM_MODE_RESET && - options.mode != PROGRAM_MODE_MANUAL) { + if (options.mode != ELEKTRA_ENUM_MODE_RESET && + options.mode != ELEKTRA_ENUM_MODE_ONESHOTMANUAL) { if (options.verbose) { printf(_("Temperatures: %dK at day, %dK at night\n"), options.scheme.day.temperature, options.scheme.night.temperature); } - /* Color temperature */ - if (options.scheme.day.temperature < MIN_TEMP || - options.scheme.day.temperature > MAX_TEMP || - options.scheme.night.temperature < MIN_TEMP || - options.scheme.night.temperature > MAX_TEMP) { - fprintf(stderr, - _("Temperature must be between %uK and %uK.\n"), - MIN_TEMP, MAX_TEMP); - exit(EXIT_FAILURE); - } - } - - if (options.mode == PROGRAM_MODE_MANUAL) { - /* Check color temperature to be set */ - if (options.temp_set < MIN_TEMP || - options.temp_set > MAX_TEMP) { - fprintf(stderr, - _("Temperature must be between %uK and %uK.\n"), - MIN_TEMP, MAX_TEMP); - exit(EXIT_FAILURE); - } - } - - /* Brightness */ - if (options.scheme.day.brightness < MIN_BRIGHTNESS || - options.scheme.day.brightness > MAX_BRIGHTNESS || - options.scheme.night.brightness < MIN_BRIGHTNESS || - options.scheme.night.brightness > MAX_BRIGHTNESS) { - fprintf(stderr, - _("Brightness values must be between %.1f and %.1f.\n"), - MIN_BRIGHTNESS, MAX_BRIGHTNESS); - exit(EXIT_FAILURE); } if (options.verbose) { @@ -1126,50 +995,51 @@ main(int argc, char *argv[]) gamma_state_t *method_state; /* Gamma adjustment not needed for print mode */ - if (options.mode != PROGRAM_MODE_PRINT) { + if (options.mode != ELEKTRA_ENUM_MODE_PRINT) { if (options.method != NULL) { /* Use method specified on command line. */ r = method_try_start( - options.method, &method_state, &config_state, - options.method_args); + options.method, &method_state, &options); if (r < 0) exit(EXIT_FAILURE); } else { /* Try all methods, use the first that works. */ + fputs(_("You have not configured an adjustment method. Redshift will try to automatically choose a suitable one.\n"), stdout); for (int i = 0; gamma_methods[i].name != NULL; i++) { const gamma_method_t *m = &gamma_methods[i]; if (!m->autostart) continue; + fprintf(stdout, + _("Trying adjustment method `%s'...\n"), + m->name); r = method_try_start( - m, &method_state, &config_state, NULL); + m, &method_state, &options); if (r < 0) { - fputs(_("Trying next method...\n"), stderr); + fputs(_("Trying next method...\n"), stdout); continue; } /* Found method that works. */ - printf(_("Using method `%s'.\n"), m->name); + printf(_("`%s' works and will be used.\n"), m->name); options.method = m; break; } /* Failure if no methods were successful at this point. */ if (options.method == NULL) { - fputs(_("No more methods to try.\n"), stderr); + fputs(_("Redshift was unable to adjust your screen temperature. Reason: None of the temperature adjustment methods of this build work on your system. Execute \"redshift --method list\" to see which methods are supported in this build. Exiting now.\n"), stderr); exit(EXIT_FAILURE); } } } - config_ini_free(&config_state); - switch (options.mode) { - case PROGRAM_MODE_ONE_SHOT: - case PROGRAM_MODE_PRINT: + case ELEKTRA_ENUM_MODE_ONESHOT: + case ELEKTRA_ENUM_MODE_PRINT: { location_t loc = { NAN, NAN }; if (need_location) { fputs(_("Waiting for current location" - " to become available...\n"), stderr); + " to become available...\n"), stdout); /* Wait for location provider. */ int r = provider_get_location( @@ -1223,7 +1093,7 @@ main(int argc, char *argv[]) interpolate_transition_scheme( scheme, transition_prog, &interp); - if (options.verbose || options.mode == PROGRAM_MODE_PRINT) { + if (options.verbose || options.mode == ELEKTRA_ENUM_MODE_PRINT) { print_period(period, transition_prog); printf(_("Color temperature: %uK\n"), interp.temperature); @@ -1231,7 +1101,7 @@ main(int argc, char *argv[]) interp.brightness); } - if (options.mode != PROGRAM_MODE_PRINT) { + if (options.mode != ELEKTRA_ENUM_MODE_PRINT) { /* Adjust temperature */ r = options.method->set_temperature( method_state, &interp, options.preserve_gamma); @@ -1253,7 +1123,7 @@ main(int argc, char *argv[]) } } break; - case PROGRAM_MODE_MANUAL: + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: { if (options.verbose) { printf(_("Color temperature: %uK\n"), @@ -1280,7 +1150,7 @@ main(int argc, char *argv[]) } } break; - case PROGRAM_MODE_RESET: + case ELEKTRA_ENUM_MODE_RESET: { /* Reset screen */ color_setting_t reset; @@ -1302,7 +1172,7 @@ main(int argc, char *argv[]) } } break; - case PROGRAM_MODE_CONTINUAL: + case ELEKTRA_ENUM_MODE_CONTINUAL: { r = run_continual_mode( options.provider, location_state, scheme, @@ -1315,7 +1185,7 @@ main(int argc, char *argv[]) } /* Clean up gamma adjustment state */ - if (options.mode != PROGRAM_MODE_PRINT) { + if (options.mode != ELEKTRA_ENUM_MODE_PRINT) { options.method->free(method_state); } diff --git a/src/redshift.h b/src/redshift.h index 0282d839..d3ce54b0 100644 --- a/src/redshift.h +++ b/src/redshift.h @@ -22,6 +22,7 @@ #include #include +#include /* The color temperature when no adjustment is applied. */ #define NEUTRAL_TEMP 6500 @@ -48,15 +49,6 @@ typedef struct { float brightness; } color_setting_t; -/* Program modes. */ -typedef enum { - PROGRAM_MODE_CONTINUAL, - PROGRAM_MODE_ONE_SHOT, - PROGRAM_MODE_PRINT, - PROGRAM_MODE_RESET, - PROGRAM_MODE_MANUAL -} program_mode_t; - /* Time range. Fields are offsets from midnight in seconds. */ typedef struct { @@ -86,7 +78,7 @@ typedef int gamma_method_start_func(gamma_state_t *state); typedef void gamma_method_free_func(gamma_state_t *state); typedef void gamma_method_print_help_func(FILE *f); typedef int gamma_method_set_option_func(gamma_state_t *state, const char *key, - const char *value); + const unsigned short value); typedef void gamma_method_restore_func(gamma_state_t *state); typedef int gamma_method_set_temperature_func( gamma_state_t *state, const color_setting_t *setting, int preserve); @@ -124,7 +116,7 @@ typedef int location_provider_start_func(location_state_t *state); typedef void location_provider_free_func(location_state_t *state); typedef void location_provider_print_help_func(FILE *f); typedef int location_provider_set_option_func( - location_state_t *state, const char *key, const char *value); + location_state_t *state, const char *key, const float *value); typedef int location_provider_get_fd_func(location_state_t *state); typedef int location_provider_handle_func( location_state_t *state, location_t *location, int *available);