From 5cfffbb057ab67576120db62c10f05d917e79352 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 20 Jul 2021 15:53:56 +0200 Subject: [PATCH 001/100] Add libelektra specification that corresponds to currently supported config files --- src/elektra/redshift.ini | 122 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/elektra/redshift.ini diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini new file mode 100644 index 00000000..e3af8067 --- /dev/null +++ b/src/elektra/redshift.ini @@ -0,0 +1,122 @@ +; Elektra spec file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) +; Based on: https://github.com/ElektraInitiative/libelektra/blob/master/examples/spec/lcdproc/LCDd.ini + +; TODO: +; 1. revise hierarchy, naming and types to make redshift config files easier to read and use and less error-prone. breaks backwards-compatibility. +; 2. after 1.: split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. +; 3. after 1. and 2.: add properties "required", "default", etc. +; 4. after 1. and 2.: add command line arguments to specification +; 5. after 1. and 2.: add enum values + +[] +mountpoint = redshift.ecf + +; Configuration values - section redshift +;======================================================= +[redshift/temp-day] +type = string +description = The color temperature the screen should have during daytime. + +[redshift/temp-night] +type = string +description = The color temperature the screen should have during nighttime. + +[redshift/transition] +type = unsigned_short +description = DEPRECATED, superseded by 'redshift/fade'. Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. + +[redshift/fade] +type = unsigned_short +description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. + +[redshift/brightness] +type = float +description = The screen brightness. + +[redshift/brightness-day] +type = float +description = The screen brightness during daytime. + +[redshift/brightness-night] +type = float +description = The screen brightness during nighttime. + +[redshift/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). + +[redshift/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). + +[redshift/gamma] +type = float +description = The screen gamma. + +[redshift/gamma-day] +type = float +description = The screen gamma during daytime. + +[redshift/gamma-night] +type = float +description = The screen gamma during nighttime. + +[redshift/adjustment-method] +type = string +description = The method used to adjust screen color temperature. + +[redshift/location-provider] +type = string +description = The location provider. Used to establish whether it is currently daytime or nighttime. + +[redshift/dawn-time] +type = string +description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). + +[redshift/dusk-time] +type = string +description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). + +; Configuration values - section manual +;======================================================= +; Values for location provider manual (see location_manual_set_option() in location-manual.c) +[manual/lat] +type = float +description = The location latitude. Only has an effect if location provider "manual" is used. + +[manual/lon] +type = float +description = The location longitude. Only has an effect if location provider "manual" is used. + +; Note: other location providers have no config parameters/cli arguments + +; Configuration values - section drm +;======================================================= +; Values for the adjustment method drm +[drm/card] +type = unsigned_short +description = Graphics card to apply adjustments to. + +[drm/crtc] +type = unsigned_short +description = CRTC to apply adjustments to. + +; Configuration values - section randr +;======================================================= +; Values for the adjustment method randr +[randr/screen] +type = unsigned_short +description = X screen to apply adjustments to. + +[randr/crtc] +type = unsigned_short +description = List of comma separated CRTCs to apply adjustments to. + +; Configuration values - section vidmode +;======================================================= +; Values for the adjustment method vidmode +[vidmode/screen] +type = unsigned_short +description = X screen to apply adjustments to. + +; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. \ No newline at end of file From a460cf8aac75af94c500d2402d65ad9b05abab91 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 20 Jul 2021 16:07:25 +0200 Subject: [PATCH 002/100] Remove deprecated configuration value "transition" from specification --- src/elektra/redshift.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index e3af8067..42e5b943 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -21,10 +21,6 @@ description = The color temperature the screen should have during daytime. type = string description = The color temperature the screen should have during nighttime. -[redshift/transition] -type = unsigned_short -description = DEPRECATED, superseded by 'redshift/fade'. Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. - [redshift/fade] type = unsigned_short description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. From 8cc96b74ed296ad611bfec936d24ba12383fa9ec Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 20 Jul 2021 16:27:59 +0200 Subject: [PATCH 003/100] Revise naming and hierarchy --- src/elektra/redshift.ini | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 42e5b943..f85b124a 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -13,12 +13,10 @@ mountpoint = redshift.ecf ; Configuration values - section redshift ;======================================================= -[redshift/temp-day] -type = string +[redshift/temp/day] description = The color temperature the screen should have during daytime. -[redshift/temp-night] -type = string +[redshift/temp/night] description = The color temperature the screen should have during nighttime. [redshift/fade] @@ -29,19 +27,19 @@ description = Whether transitions between color temperatures (e.g. from daytime type = float description = The screen brightness. -[redshift/brightness-day] +[redshift/brightness/day] type = float description = The screen brightness during daytime. -[redshift/brightness-night] +[redshift/brightness/night] type = float description = The screen brightness during nighttime. -[redshift/elevation-high] +[redshift/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). -[redshift/elevation-low] +[redshift/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). @@ -49,11 +47,11 @@ description = By default, Redshift will use the current elevation of the sun to type = float description = The screen gamma. -[redshift/gamma-day] +[redshift/gamma/day] type = float description = The screen gamma during daytime. -[redshift/gamma-night] +[redshift/gamma/night] type = float description = The screen gamma during nighttime. @@ -76,11 +74,11 @@ description = Instead of using the solar elevation, the time intervals of dawn a ; Configuration values - section manual ;======================================================= ; Values for location provider manual (see location_manual_set_option() in location-manual.c) -[manual/lat] +[redshift/location-providers/manual/lat] type = float description = The location latitude. Only has an effect if location provider "manual" is used. -[manual/lon] +[redshift/location-providers/manual/lon] type = float description = The location longitude. Only has an effect if location provider "manual" is used. @@ -89,29 +87,29 @@ description = The location longitude. Only has an effect if location provider "m ; Configuration values - section drm ;======================================================= ; Values for the adjustment method drm -[drm/card] +[redshift/adjustment-methods/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. -[drm/crtc] +[redshift/adjustment-methods/drm/crtc] type = unsigned_short description = CRTC to apply adjustments to. ; Configuration values - section randr ;======================================================= ; Values for the adjustment method randr -[randr/screen] +[redshift/adjustment-methods/randr/screen] type = unsigned_short description = X screen to apply adjustments to. -[randr/crtc] +[redshift/adjustment-methods/randr/crtc] type = unsigned_short description = List of comma separated CRTCs to apply adjustments to. ; Configuration values - section vidmode ;======================================================= ; Values for the adjustment method vidmode -[vidmode/screen] +[redshift/adjustment-methods/vidmode/screen] type = unsigned_short description = X screen to apply adjustments to. From 5e259189f9dfedb80422b879d58718f7d9bde692 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 20 Jul 2021 16:57:24 +0200 Subject: [PATCH 004/100] Change to types that better match possible values --- src/elektra/redshift.ini | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index f85b124a..bd58ecc7 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -14,13 +14,15 @@ mountpoint = redshift.ecf ; Configuration values - section redshift ;======================================================= [redshift/temp/day] +type = unsigned_short description = The color temperature the screen should have during daytime. [redshift/temp/night] +type = unsigned_short description = The color temperature the screen should have during nighttime. [redshift/fade] -type = unsigned_short +type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. [redshift/brightness] @@ -57,18 +59,29 @@ description = The screen gamma during nighttime. [redshift/adjustment-method] type = string +check/enum = #5 +check/enum/#0 = drm +check/enum/#1 = dummy +check/enum/#2 = quartz +check/enum/#3 = randr +check/enum/#4 = vidmode +check/enum/#5 = w32gdi description = The method used to adjust screen color temperature. [redshift/location-provider] type = string +check/enum = #2 +check/enum/#0 = corelocation +check/enum/#1 = geoclue2 +check/enum/#2 = manual description = The location provider. Used to establish whether it is currently daytime or nighttime. [redshift/dawn-time] -type = string +type = regex \d{2}:\d{2} description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). [redshift/dusk-time] -type = string +type = regex \d{2}:\d{2} description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). ; Configuration values - section manual From 62897f3a5b570c698344598e40b4a6d0b9aabca6 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 12:51:19 +0200 Subject: [PATCH 005/100] Add metadata for required plugins --- src/elektra/redshift.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index bd58ecc7..743f61b6 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -10,6 +10,7 @@ [] mountpoint = redshift.ecf +infos/plugins = ni validation ; Configuration values - section redshift ;======================================================= From 558c1e211f4f93d5daa03170588fb031dfa9642a Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 12:52:18 +0200 Subject: [PATCH 006/100] Add default values --- src/elektra/redshift.ini | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 743f61b6..05eedb7c 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -17,46 +17,57 @@ infos/plugins = ni validation [redshift/temp/day] type = unsigned_short description = The color temperature the screen should have during daytime. +default = 6500 [redshift/temp/night] type = unsigned_short description = The color temperature the screen should have during nighttime. +default = 4500 [redshift/fade] type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. +default = 1 [redshift/brightness] type = float description = The screen brightness. +default = 1.0 [redshift/brightness/day] type = float description = The screen brightness during daytime. +default = 1.0 [redshift/brightness/night] type = float description = The screen brightness during nighttime. +default = 1.0 [redshift/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). +default = 3.0 [redshift/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). +default = -6.0 [redshift/gamma] type = float description = The screen gamma. +default = 1.0 [redshift/gamma/day] type = float description = The screen gamma during daytime. +default = 1.0 [redshift/gamma/night] type = float description = The screen gamma during nighttime. +default = 1.0 [redshift/adjustment-method] type = string From 6a9936ceff8e69dd9cad7ec0d964a49baad05720 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 13:03:31 +0200 Subject: [PATCH 007/100] Add "range" metadata --- src/elektra/redshift.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 05eedb7c..12326f76 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -33,16 +33,19 @@ default = 1 type = float description = The screen brightness. default = 1.0 +check/range = 0-1 [redshift/brightness/day] type = float description = The screen brightness during daytime. default = 1.0 +check/range = 0-1 [redshift/brightness/night] type = float description = The screen brightness during nighttime. default = 1.0 +check/range = 0-1 [redshift/elevation/high] type = float @@ -102,10 +105,12 @@ description = Instead of using the solar elevation, the time intervals of dawn a [redshift/location-providers/manual/lat] type = float description = The location latitude. Only has an effect if location provider "manual" is used. +check/range = -90.0-90.0 [redshift/location-providers/manual/lon] type = float description = The location longitude. Only has an effect if location provider "manual" is used. +check/range = -180.0-180.0 ; Note: other location providers have no config parameters/cli arguments From 9dd2fcc8f8c373fcb3ebeace239e34df2f9d99d8 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 13:03:58 +0200 Subject: [PATCH 008/100] Replace regex for time values by check/date --- src/elektra/redshift.ini | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 12326f76..8bc5c07c 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -91,12 +91,14 @@ check/enum/#1 = geoclue2 check/enum/#2 = manual description = The location provider. Used to establish whether it is currently daytime or nighttime. -[redshift/dawn-time] -type = regex \d{2}:\d{2} +type = string +check/date = ISO8601 +check/date/format = timeofday description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). -[redshift/dusk-time] -type = regex \d{2}:\d{2} +type = string +check/date = ISO8601 +check/date/format = timeofday description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). ; Configuration values - section manual From 5381b57317d1437b259bb650f20e86e7d55e3d91 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 13:04:17 +0200 Subject: [PATCH 009/100] Add "require" metadata --- src/elektra/redshift.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 8bc5c07c..483db182 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -4,7 +4,7 @@ ; TODO: ; 1. revise hierarchy, naming and types to make redshift config files easier to read and use and less error-prone. breaks backwards-compatibility. ; 2. after 1.: split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. -; 3. after 1. and 2.: add properties "required", "default", etc. +; 3. after 1. and 2.: add properties "require", "default", etc. ; 4. after 1. and 2.: add command line arguments to specification ; 5. after 1. and 2.: add enum values @@ -82,6 +82,7 @@ check/enum/#3 = randr check/enum/#4 = vidmode check/enum/#5 = w32gdi description = The method used to adjust screen color temperature. +require = [redshift/location-provider] type = string @@ -89,7 +90,9 @@ check/enum = #2 check/enum/#0 = corelocation check/enum/#1 = geoclue2 check/enum/#2 = manual +require = description = The location provider. Used to establish whether it is currently daytime or nighttime. +require = type = string check/date = ISO8601 From b8cfdd161f453e2338744df9a45e7dc8a39e84ca Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 13:05:15 +0200 Subject: [PATCH 010/100] Remove prefix "redshift/" from key names --- src/elektra/redshift.ini | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 483db182..83ad19fe 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -14,65 +14,65 @@ infos/plugins = ni validation ; Configuration values - section redshift ;======================================================= -[redshift/temp/day] +[temp/day] type = unsigned_short description = The color temperature the screen should have during daytime. default = 6500 -[redshift/temp/night] +[temp/night] type = unsigned_short description = The color temperature the screen should have during nighttime. default = 4500 -[redshift/fade] +[fade] type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. default = 1 -[redshift/brightness] +[brightness] type = float description = The screen brightness. default = 1.0 check/range = 0-1 -[redshift/brightness/day] +[brightness/day] type = float description = The screen brightness during daytime. default = 1.0 check/range = 0-1 -[redshift/brightness/night] +[brightness/night] type = float description = The screen brightness during nighttime. default = 1.0 check/range = 0-1 -[redshift/elevation/high] +[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). default = 3.0 -[redshift/elevation/low] +[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). default = -6.0 -[redshift/gamma] +[gamma] type = float description = The screen gamma. default = 1.0 -[redshift/gamma/day] +[gamma/day] type = float description = The screen gamma during daytime. default = 1.0 -[redshift/gamma/night] +[gamma/night] type = float description = The screen gamma during nighttime. default = 1.0 -[redshift/adjustment-method] +[adjustment-method] type = string check/enum = #5 check/enum/#0 = drm @@ -84,21 +84,22 @@ check/enum/#5 = w32gdi description = The method used to adjust screen color temperature. require = -[redshift/location-provider] +[location-provider] type = string check/enum = #2 check/enum/#0 = corelocation check/enum/#1 = geoclue2 check/enum/#2 = manual -require = description = The location provider. Used to establish whether it is currently daytime or nighttime. require = +[dawn-time] type = string check/date = ISO8601 check/date/format = timeofday description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +[dusk-time] type = string check/date = ISO8601 check/date/format = timeofday @@ -107,12 +108,12 @@ description = Instead of using the solar elevation, the time intervals of dawn a ; Configuration values - section manual ;======================================================= ; Values for location provider manual (see location_manual_set_option() in location-manual.c) -[redshift/location-providers/manual/lat] +[location-providers/manual/lat] type = float description = The location latitude. Only has an effect if location provider "manual" is used. check/range = -90.0-90.0 -[redshift/location-providers/manual/lon] +[location-providers/manual/lon] type = float description = The location longitude. Only has an effect if location provider "manual" is used. check/range = -180.0-180.0 @@ -122,29 +123,29 @@ check/range = -180.0-180.0 ; Configuration values - section drm ;======================================================= ; Values for the adjustment method drm -[redshift/adjustment-methods/drm/card] +[adjustment-methods/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. -[redshift/adjustment-methods/drm/crtc] +[adjustment-methods/drm/crtc] type = unsigned_short description = CRTC to apply adjustments to. ; Configuration values - section randr ;======================================================= ; Values for the adjustment method randr -[redshift/adjustment-methods/randr/screen] +[adjustment-methods/randr/screen] type = unsigned_short description = X screen to apply adjustments to. -[redshift/adjustment-methods/randr/crtc] +[adjustment-methods/randr/crtc] type = unsigned_short description = List of comma separated CRTCs to apply adjustments to. ; Configuration values - section vidmode ;======================================================= ; Values for the adjustment method vidmode -[redshift/adjustment-methods/vidmode/screen] +[adjustment-methods/vidmode/screen] type = unsigned_short description = X screen to apply adjustments to. From b13b051a338fc6d5cfd01d2cfded33421fc9cb8f Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 21 Jul 2021 13:10:18 +0200 Subject: [PATCH 011/100] Revise TODOs --- src/elektra/redshift.ini | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 83ad19fe..03b00c95 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -2,11 +2,7 @@ ; Based on: https://github.com/ElektraInitiative/libelektra/blob/master/examples/spec/lcdproc/LCDd.ini ; TODO: -; 1. revise hierarchy, naming and types to make redshift config files easier to read and use and less error-prone. breaks backwards-compatibility. -; 2. after 1.: split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. -; 3. after 1. and 2.: add properties "require", "default", etc. -; 4. after 1. and 2.: add command line arguments to specification -; 5. after 1. and 2.: add enum values +; 6. add command line arguments to specification and split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. [] mountpoint = redshift.ecf From 4963eba09e607765d0800d5c2a4f7cf57a433c38 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 15:45:06 +0200 Subject: [PATCH 012/100] Remove infos/plugins (see https://github.com/jonls/redshift/pull/829#discussion_r674678554) --- src/elektra/redshift.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 03b00c95..b152fd29 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -6,7 +6,6 @@ [] mountpoint = redshift.ecf -infos/plugins = ni validation ; Configuration values - section redshift ;======================================================= From c00dea1d6cb3815d29fc6a59d98fca38a41b68cb Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 15:46:04 +0200 Subject: [PATCH 013/100] Add explanation and links about specification files --- src/elektra/redshift.ini | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index b152fd29..14846d55 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -1,5 +1,8 @@ -; Elektra spec file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) -; Based on: https://github.com/ElektraInitiative/libelektra/blob/master/examples/spec/lcdproc/LCDd.ini +; Elektra specification file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) +; This file is based on: https://github.com/ElektraInitiative/libelektra/blob/master/examples/spec/lcdproc/LCDd.ini +; +; A spec file "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) +; For details see: https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) ; TODO: ; 6. add command line arguments to specification and split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. From a4ee0a9598072a892f453158cead50a042b9b30c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 15:57:14 +0200 Subject: [PATCH 014/100] Improve naming and hierarchy of keys --- src/elektra/redshift.ini | 46 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 14846d55..09e74b73 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -70,7 +70,7 @@ type = float description = The screen gamma during nighttime. default = 1.0 -[adjustment-method] +[adjustment/method] type = string check/enum = #5 check/enum/#0 = drm @@ -82,36 +82,44 @@ check/enum/#5 = w32gdi description = The method used to adjust screen color temperature. require = -[location-provider] +[provider] type = string -check/enum = #2 -check/enum/#0 = corelocation -check/enum/#1 = geoclue2 -check/enum/#2 = manual -description = The location provider. Used to establish whether it is currently daytime or nighttime. -require = +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 -[dawn-time] +[provider/time/dawn] type = string check/date = ISO8601 check/date/format = timeofday -description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +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). -[dusk-time] +[provider/time/dusk] type = string check/date = ISO8601 check/date/format = timeofday -description = Instead of using the solar elevation, the time intervals of dawn and dusk can be specified manually (source: https://github.com/jonls/redshift/wiki/Configuration-file#custom-dawndusk-intervals). +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). +[provider/location] +type = string +check/enum = #2 +check/enum/#0 = corelocation +check/enum/#1 = geoclue2 +check/enum/#2 = manual +description = The location provider. Used to establish whether it is currently daytime or nighttime. +default = manual +example = geoclue2 ; Configuration values - section manual ;======================================================= ; Values for location provider manual (see location_manual_set_option() in location-manual.c) -[location-providers/manual/lat] +[provider/location/manual/lat] type = float description = The location latitude. Only has an effect if location provider "manual" is used. check/range = -90.0-90.0 -[location-providers/manual/lon] +[provider/location/manual/lon] type = float description = The location longitude. Only has an effect if location provider "manual" is used. check/range = -180.0-180.0 @@ -121,29 +129,29 @@ check/range = -180.0-180.0 ; Configuration values - section drm ;======================================================= ; Values for the adjustment method drm -[adjustment-methods/drm/card] +[adjustment/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. -[adjustment-methods/drm/crtc] +[adjustment/drm/crtc] type = unsigned_short description = CRTC to apply adjustments to. ; Configuration values - section randr ;======================================================= ; Values for the adjustment method randr -[adjustment-methods/randr/screen] +[adjustment/randr/screen] type = unsigned_short description = X screen to apply adjustments to. -[adjustment-methods/randr/crtc] +[adjustment/randr/crtc] type = unsigned_short description = List of comma separated CRTCs to apply adjustments to. ; Configuration values - section vidmode ;======================================================= ; Values for the adjustment method vidmode -[adjustment-methods/vidmode/screen] +[adjustment/vidmode/screen] type = unsigned_short description = X screen to apply adjustments to. From 7f32a6b4ccbec69e7e08fe7f5a966663ee9e4ed8 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 15:57:57 +0200 Subject: [PATCH 015/100] Add missing example, default and require --- src/elektra/redshift.ini | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 09e74b73..b7a68708 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -16,59 +16,70 @@ mountpoint = redshift.ecf type = unsigned_short description = The color temperature the screen should have during daytime. default = 6500 +example = 6500 [temp/night] type = unsigned_short description = The color temperature the screen should have during nighttime. default = 4500 +example = 4500 [fade] type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. default = 1 +example = 0 [brightness] type = float description = The screen brightness. default = 1.0 +example = 0.8 check/range = 0-1 [brightness/day] type = float description = The screen brightness during daytime. default = 1.0 +example = 0.8 check/range = 0-1 [brightness/night] type = float description = The screen brightness during nighttime. default = 1.0 +example = 0.8 check/range = 0-1 [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). default = 3.0 +example = 3.5 [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). default = -6.0 +example = -5.0 [gamma] type = float description = The screen gamma. default = 1.0 +example = 0.9 [gamma/day] type = float description = The screen gamma during daytime. default = 1.0 +example = 0.9 [gamma/night] type = float description = The screen gamma during nighttime. default = 1.0 +example = 0.9 [adjustment/method] type = string @@ -81,6 +92,10 @@ check/enum/#4 = vidmode check/enum/#5 = w32gdi description = The method used to adjust screen color temperature. require = +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' [provider] type = string @@ -89,18 +104,24 @@ 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 [provider/time/dawn] 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 [provider/time/dusk] 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 + [provider/location] type = string check/enum = #2 @@ -118,11 +139,19 @@ example = geoclue2 type = float description = The location latitude. Only has an effect if location provider "manual" is used. check/range = -90.0-90.0 +; Latitude of berlin: +example = 52.520008 +; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. +require = [provider/location/manual/lon] type = float description = The location longitude. Only has an effect if location provider "manual" is used. check/range = -180.0-180.0 +; Longitude of berlin: +example = 13.404954 +; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. +require = ; Note: other location providers have no config parameters/cli arguments @@ -132,10 +161,14 @@ check/range = -180.0-180.0 [adjustment/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. +default = 0 +example = 1 [adjustment/drm/crtc] type = unsigned_short description = CRTC to apply adjustments to. +default = 0 +example = 1 ; Configuration values - section randr ;======================================================= @@ -143,10 +176,14 @@ description = CRTC to apply adjustments to. [adjustment/randr/screen] type = unsigned_short description = X screen to apply adjustments to. +default = 0 +example = 1 [adjustment/randr/crtc] type = unsigned_short description = List of comma separated CRTCs to apply adjustments to. +default = 0 +example = 1 ; Configuration values - section vidmode ;======================================================= @@ -154,5 +191,7 @@ description = List of comma separated CRTCs to apply adjustments to. [adjustment/vidmode/screen] type = unsigned_short description = X screen to apply adjustments to. +default = 0 +example = 1 ; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. \ No newline at end of file From 0ad584ceffc0d2808df991189118da6046802d99 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 15:58:10 +0200 Subject: [PATCH 016/100] Add link to documentation for adjustment method --- src/elektra/redshift.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index b7a68708..547817b9 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -90,7 +90,7 @@ check/enum/#2 = quartz check/enum/#3 = randr check/enum/#4 = vidmode check/enum/#5 = w32gdi -description = The method used to adjust screen color temperature. +description = The method used to adjust screen color temperature. For details see section "Alternative Features" in file DESIGN in root directory. require = example = randr ; default = w32gdi - For Windows the default is the only supported method 'w32gdi' From d1b785d24d4748194e05571179ae2e7f19eb84a6 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 22 Jul 2021 16:01:16 +0200 Subject: [PATCH 017/100] Improve hierarchy of keys --- src/elektra/redshift.ini | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 547817b9..29ea2585 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -51,18 +51,6 @@ default = 1.0 example = 0.8 check/range = 0-1 -[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). -default = 3.0 -example = 3.5 - -[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). -default = -6.0 -example = -5.0 - [gamma] type = float description = The screen gamma. @@ -132,6 +120,18 @@ description = The location provider. Used to establish whether it is currently d default = manual example = geoclue2 +[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). +default = 3.0 +example = 3.5 + +[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). +default = -6.0 +example = -5.0 + ; Configuration values - section manual ;======================================================= ; Values for location provider manual (see location_manual_set_option() in location-manual.c) From 5bab4e603679069701e977e5fadb9c31e884477c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 09:47:38 +0200 Subject: [PATCH 018/100] Merge duplicate values randr/crtc resp. drm/crtc and randr/screen resp. vidmode/screen. --- src/elektra/redshift.ini | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 29ea2585..cd5c99e0 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -155,42 +155,28 @@ require = ; Note: other location providers have no config parameters/cli arguments -; Configuration values - section drm +; Configuration values - shared by randr and drm ;======================================================= -; Values for the adjustment method drm -[adjustment/drm/card] -type = unsigned_short -description = Graphics card to apply adjustments to. -default = 0 -example = 1 - -[adjustment/drm/crtc] +[adjustment/crtc] type = unsigned_short description = CRTC to apply adjustments to. default = 0 example = 1 -; Configuration values - section randr +; Configuration values - shared by randr and vidmode ;======================================================= -; Values for the adjustment method randr -[adjustment/randr/screen] +[adjustment/screen] type = unsigned_short description = X screen to apply adjustments to. default = 0 example = 1 -[adjustment/randr/crtc] -type = unsigned_short -description = List of comma separated CRTCs to apply adjustments to. -default = 0 -example = 1 - -; Configuration values - section vidmode +; Configuration values - section drm ;======================================================= -; Values for the adjustment method vidmode -[adjustment/vidmode/screen] +; Values for the adjustment method drm +[adjustment/drm/card] type = unsigned_short -description = X screen to apply adjustments to. +description = Graphics card to apply adjustments to. default = 0 example = 1 From e50c21dc0eec28acf5393de0b885b5b7a9aa2599 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 10:14:55 +0200 Subject: [PATCH 019/100] Improve descriptions of brightness/day and brightness/night --- src/elektra/redshift.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index cd5c99e0..6e22c440 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -39,14 +39,14 @@ check/range = 0-1 [brightness/day] type = float -description = The screen brightness during daytime. +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/range = 0-1 [brightness/night] type = float -description = The screen brightness during nighttime. +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/range = 0-1 From a18c2c62ad039a160cc1b99030ee464eb747df03 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 10:15:53 +0200 Subject: [PATCH 020/100] Fix wrong type and check of gamma, gamma/night and gamma/day --- src/elektra/redshift.ini | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 6e22c440..3794fa59 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -52,22 +52,28 @@ example = 0.8 check/range = 0-1 [gamma] -type = float +type = string description = The screen gamma. -default = 1.0 -example = 0.9 +default = 1.0:1.0:1.0 +example = 0.9:0.9:0.9 +; Regex checks that value is of format "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]+)$ [gamma/day] -type = float +type = string description = The screen gamma during daytime. -default = 1.0 -example = 0.9 +default = 1.0:1.0:1.0 +example = 0.9:0.9:0.9 +; Regex checks that value is of format "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]+)$ [gamma/night] -type = float +type = string description = The screen gamma during nighttime. -default = 1.0 -example = 0.9 +default = 1.0:1.0:1.0 +example = 0.9:0.9:0.9 +; Regex checks that value is of format "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]+)$ [adjustment/method] type = string From 3d9241cb152d81dbdd8064cbeb0684540586578d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 10:16:05 +0200 Subject: [PATCH 021/100] Add note about environment variables --- src/elektra/redshift.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 3794fa59..3314b3a2 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -4,8 +4,7 @@ ; A spec file "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) ; For details see: https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) -; TODO: -; 6. add command line arguments to specification and split up colon-separated options for location-providers and adjustment-methods into separate CLI arguments. +; Redshift uses no environment variables. [] mountpoint = redshift.ecf From 5a34613eee135fd91be4c9e5efe03ced202caa40 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 10:19:47 +0200 Subject: [PATCH 022/100] Add CLI arguments to spec file --- src/elektra/redshift.ini | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 3314b3a2..6363b776 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -16,18 +16,25 @@ type = unsigned_short description = The color temperature the screen should have during daytime. default = 6500 example = 6500 +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 +opt/long = temp-night +opt/arg = required [fade] type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. default = 1 example = 0 +opt = f +opt/long = fade +opt/arg = none [brightness] type = float @@ -35,6 +42,8 @@ description = The screen brightness. default = 1.0 example = 0.8 check/range = 0-1 +opt = b +opt/long = brightness [brightness/day] type = float @@ -42,6 +51,7 @@ description = The screen brightness during daytime. If both day and night bright default = 1.0 example = 0.8 check/range = 0-1 +opt/long = brightness-day [brightness/night] type = float @@ -49,6 +59,7 @@ description = The screen brightness during nighttime. If both day and night brig default = 1.0 example = 0.8 check/range = 0-1 +opt/long = brightness-night [gamma] type = string @@ -57,6 +68,8 @@ default = 1.0:1.0:1.0 example = 0.9:0.9:0.9 ; Regex checks that value is of format "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]+)$ +opt = g +opt/long = gamma [gamma/day] type = string @@ -65,6 +78,7 @@ default = 1.0:1.0:1.0 example = 0.9:0.9:0.9 ; Regex checks that value is of format "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]+)$ +opt/long = gamma-day [gamma/night] type = string @@ -73,6 +87,7 @@ default = 1.0:1.0:1.0 example = 0.9:0.9:0.9 ; Regex checks that value is of format "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]+)$ +opt/long = gamma-night [adjustment/method] type = string @@ -89,6 +104,8 @@ 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 [provider] type = string @@ -98,6 +115,7 @@ 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 [provider/time/dawn] type = string @@ -106,6 +124,7 @@ 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 [provider/time/dusk] type = string @@ -114,6 +133,7 @@ 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 [provider/location] type = string @@ -124,18 +144,21 @@ check/enum/#2 = manual description = The location provider. Used to establish whether it is currently daytime or nighttime. default = manual example = geoclue2 +opt/long = location-provider [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). default = 3.0 example = 3.5 +opt/long = elevation-high [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). default = -6.0 example = -5.0 +opt/long = elevation-low ; Configuration values - section manual ;======================================================= @@ -148,6 +171,7 @@ check/range = -90.0-90.0 example = 52.520008 ; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. require = +opt/long = lat [provider/location/manual/lon] type = float @@ -157,6 +181,7 @@ check/range = -180.0-180.0 example = 13.404954 ; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. require = +opt/long = lon ; Note: other location providers have no config parameters/cli arguments @@ -167,6 +192,7 @@ type = unsigned_short description = CRTC to apply adjustments to. default = 0 example = 1 +opt/long = crtc ; Configuration values - shared by randr and vidmode ;======================================================= @@ -175,6 +201,7 @@ type = unsigned_short description = X screen to apply adjustments to. default = 0 example = 1 +opt/long = screen ; Configuration values - section drm ;======================================================= @@ -184,5 +211,5 @@ type = unsigned_short description = Graphics card to apply adjustments to. default = 0 example = 1 - +opt/long = drm-card ; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. \ No newline at end of file From d345ea3344df7526cf48bad697beec90ad7f48fb Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 23 Jul 2021 10:27:12 +0200 Subject: [PATCH 023/100] Add opt/arg = required --- src/elektra/redshift.ini | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 6363b776..ec388ccf 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -44,6 +44,7 @@ example = 0.8 check/range = 0-1 opt = b opt/long = brightness +opt/arg = required [brightness/day] type = float @@ -52,6 +53,7 @@ default = 1.0 example = 0.8 check/range = 0-1 opt/long = brightness-day +opt/arg = required [brightness/night] type = float @@ -60,6 +62,7 @@ default = 1.0 example = 0.8 check/range = 0-1 opt/long = brightness-night +opt/arg = required [gamma] type = string @@ -70,6 +73,7 @@ example = 0.9:0.9:0.9 check/validation = ^([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+)$ opt = g opt/long = gamma +opt/arg = required [gamma/day] type = string @@ -79,6 +83,7 @@ example = 0.9:0.9:0.9 ; Regex checks that value is of format "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]+)$ opt/long = gamma-day +opt/arg = required [gamma/night] type = string @@ -88,6 +93,7 @@ example = 0.9:0.9:0.9 ; Regex checks that value is of format "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]+)$ opt/long = gamma-night +opt/arg = required [adjustment/method] type = string @@ -106,6 +112,7 @@ example = randr ; default = quartz - For macOS the default is 'quartz' opt = m opt/long = method +opt/arg = required [provider] type = string @@ -116,6 +123,7 @@ description = The provider used to decide at what times of day redshift should b default = location example = time opt/long = provider +opt/arg = required [provider/time/dawn] type = string @@ -125,6 +133,7 @@ description = Instead of using the solar elevation at the user's location, the t default = 05:00 example = 06:00 opt/long = time-dawn +opt/arg = required [provider/time/dusk] type = string @@ -134,6 +143,7 @@ description = Instead of using the solar elevation at the user's location, the t default = 19:00 example = 20:00 opt/long = time-dusk +opt/arg = required [provider/location] type = string @@ -145,6 +155,7 @@ description = The location provider. Used to establish whether it is currently d default = manual example = geoclue2 opt/long = location-provider +opt/arg = required [provider/location/elevation/high] type = float @@ -152,6 +163,7 @@ description = By default, Redshift will use the current elevation of the sun to default = 3.0 example = 3.5 opt/long = elevation-high +opt/arg = required [provider/location/elevation/low] type = float @@ -159,6 +171,7 @@ description = By default, Redshift will use the current elevation of the sun to default = -6.0 example = -5.0 opt/long = elevation-low +opt/arg = required ; Configuration values - section manual ;======================================================= @@ -172,6 +185,7 @@ example = 52.520008 ; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. require = opt/long = lat +opt/arg = required [provider/location/manual/lon] type = float @@ -182,6 +196,7 @@ example = 13.404954 ; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. require = opt/long = lon +opt/arg = required ; Note: other location providers have no config parameters/cli arguments @@ -193,6 +208,7 @@ description = CRTC to apply adjustments to. default = 0 example = 1 opt/long = crtc +opt/arg = required ; Configuration values - shared by randr and vidmode ;======================================================= @@ -202,6 +218,7 @@ description = X screen to apply adjustments to. default = 0 example = 1 opt/long = screen +opt/arg = required ; Configuration values - section drm ;======================================================= @@ -212,4 +229,6 @@ 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. \ No newline at end of file From 7bc88e1fb0484e8814f2aa1c200db395e4077e7a Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 29 Jul 2021 11:37:52 +0200 Subject: [PATCH 024/100] Add newline at end of file. --- src/elektra/redshift.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index ec388ccf..5516e0d1 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -231,4 +231,4 @@ 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. \ No newline at end of file +; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. From bce2269a576940ac049b246d96ede477fb1c844c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 29 Jul 2021 11:39:26 +0200 Subject: [PATCH 025/100] Remove obsolete comment, the parts of lcdprocs spec file have been replaced by my own work and feedback from @markus2330. --- src/elektra/redshift.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 5516e0d1..fa513397 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -1,5 +1,4 @@ ; Elektra specification file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) -; This file is based on: https://github.com/ElektraInitiative/libelektra/blob/master/examples/spec/lcdproc/LCDd.ini ; ; A spec file "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) ; For details see: https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) From d88215cce825aca4a4f95542c7e2614d5198b4d2 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 29 Jul 2021 11:39:56 +0200 Subject: [PATCH 026/100] Improve comments and configuration setting descriptions --- src/elektra/redshift.ini | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index fa513397..5d1e36a2 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -1,6 +1,6 @@ ; Elektra specification file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) ; -; A spec file "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) +; A specification file describes which configuration settings an application supports, their defaults and their associated CLI options. It also "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) ; For details see: https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) ; Redshift uses no environment variables. @@ -8,8 +8,6 @@ [] mountpoint = redshift.ecf -; Configuration values - section redshift -;======================================================= [temp/day] type = unsigned_short description = The color temperature the screen should have during daytime. @@ -150,7 +148,7 @@ check/enum = #2 check/enum/#0 = corelocation check/enum/#1 = geoclue2 check/enum/#2 = manual -description = The location provider. Used to establish whether it is currently daytime or nighttime. +description = The location provider to be used. The provider is used to establish whether it is currently daytime or nighttime. default = manual example = geoclue2 opt/long = location-provider @@ -158,7 +156,7 @@ opt/arg = required [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). +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 @@ -166,18 +164,15 @@ 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). +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 -; Configuration values - section manual -;======================================================= -; Values for location provider manual (see location_manual_set_option() in location-manual.c) [provider/location/manual/lat] type = float -description = The location latitude. Only has an effect if location provider "manual" is used. +description = The location latitude. Only applies to location provider "manual". check/range = -90.0-90.0 ; Latitude of berlin: example = 52.520008 @@ -188,7 +183,7 @@ opt/arg = required [provider/location/manual/lon] type = float -description = The location longitude. Only has an effect if location provider "manual" is used. +description = The location longitude. Only applies to location provider "manual". check/range = -180.0-180.0 ; Longitude of berlin: example = 13.404954 @@ -199,7 +194,7 @@ opt/arg = required ; Note: other location providers have no config parameters/cli arguments -; Configuration values - shared by randr and drm +; BEGIN Settings used by randr and drm ;======================================================= [adjustment/crtc] type = unsigned_short @@ -208,8 +203,10 @@ default = 0 example = 1 opt/long = crtc opt/arg = required +;======================================================= +; END Settings used by randr and drm -; Configuration values - shared by randr and vidmode +; BEGIN Settings used by randr and vidmode ;======================================================= [adjustment/screen] type = unsigned_short @@ -218,10 +215,11 @@ default = 0 example = 1 opt/long = screen opt/arg = required +;======================================================= +; END Settings used by randr and vidmode -; Configuration values - section drm +; BEGIN Settings used by drm ;======================================================= -; Values for the adjustment method drm [adjustment/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. @@ -229,5 +227,7 @@ default = 0 example = 1 opt/long = drm-card opt/arg = required +;======================================================= +; END Settings used by drm ; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. From 918f66c3d3912d485ec28f184353e3780738f109 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 5 Aug 2021 11:08:20 +0200 Subject: [PATCH 027/100] Add support for single value gamma values and improve descriptions and examples. --- src/elektra/redshift.ini | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 5d1e36a2..e51d6396 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -63,32 +63,32 @@ opt/arg = required [gamma] type = string -description = The screen gamma. +description = The screen gamma. 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:0.9:0.9 -; Regex checks that value is of format "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]+)$ +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]+))?$ opt = g opt/long = gamma opt/arg = required [gamma/day] type = string -description = The screen gamma during daytime. +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:0.9:0.9 -; Regex checks that value is of format "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]+)$ +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]+))?$ opt/long = gamma-day opt/arg = required [gamma/night] type = string -description = The screen gamma during nighttime. +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:0.9:0.9 -; Regex checks that value is of format "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]+)$ +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]+))?$ opt/long = gamma-night opt/arg = required From 83f5b3a58136891b3f6fc88584154b599c9f9696 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 5 Aug 2021 11:15:15 +0200 Subject: [PATCH 028/100] Add default option "auto" for adjustment/method and provider/location which automatically picks a suitable option --- src/elektra/redshift.ini | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index e51d6396..92b6d9bf 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -94,15 +94,16 @@ opt/arg = required [adjustment/method] type = string -check/enum = #5 +check/enum = #6 check/enum/#0 = drm check/enum/#1 = dummy check/enum/#2 = quartz check/enum/#3 = randr check/enum/#4 = vidmode check/enum/#5 = w32gdi -description = The method used to adjust screen color temperature. For details see section "Alternative Features" in file DESIGN in root directory. -require = +check/enum/#6 = auto +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' @@ -144,12 +145,13 @@ opt/arg = required [provider/location] type = string -check/enum = #2 +check/enum = #3 check/enum/#0 = corelocation check/enum/#1 = geoclue2 check/enum/#2 = manual -description = The location provider to be used. The provider is used to establish whether it is currently daytime or nighttime. -default = manual +check/enum/#3 = auto +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 From 64a188bc4b9cbd1eda42f864956c1bf14fc71ed6 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 5 Aug 2021 18:04:31 +0200 Subject: [PATCH 029/100] Fix type of enum keys --- src/elektra/redshift.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 92b6d9bf..b00097fb 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -93,7 +93,7 @@ opt/long = gamma-night opt/arg = required [adjustment/method] -type = string +type = enum check/enum = #6 check/enum/#0 = drm check/enum/#1 = dummy @@ -113,7 +113,7 @@ opt/long = method opt/arg = required [provider] -type = string +type = enum check/enum = #1 check/enum/#0 = time check/enum/#1 = location From 034b2cf2b669c40413851faf2b7eefeae35b4247 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 5 Aug 2021 18:04:55 +0200 Subject: [PATCH 030/100] Add missing check/type for float keys --- src/elektra/redshift.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index b00097fb..56078bbe 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -38,6 +38,7 @@ type = float description = The screen brightness. default = 1.0 example = 0.8 +check/type = float check/range = 0-1 opt = b opt/long = brightness @@ -48,6 +49,7 @@ 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 @@ -57,6 +59,7 @@ 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 @@ -175,6 +178,7 @@ opt/arg = required [provider/location/manual/lat] type = float description = The location latitude. Only applies to location provider "manual". +check/type = float check/range = -90.0-90.0 ; Latitude of berlin: example = 52.520008 @@ -186,6 +190,7 @@ opt/arg = required [provider/location/manual/lon] type = float description = The location longitude. Only applies to location provider "manual". +check/type = float check/range = -180.0-180.0 ; Longitude of berlin: example = 13.404954 From 3bd280b11ea1115e88cae4eeb7d1a582ef6b6dd4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 19 Aug 2021 11:35:13 +0200 Subject: [PATCH 031/100] Add files generated by ./bootstrap and ./configure to .gitignore --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index d56a6b60..d9bc9d8b 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,7 @@ 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 From c4cfbc4cf987c0da14eb8e4140de2f7a6dbdb4c4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 19 Aug 2021 11:35:33 +0200 Subject: [PATCH 032/100] Add folder generated by IntelliJ IDE to .gitinore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d9bc9d8b..fda09b62 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,6 @@ m4/lt~obsolete.m4 /po/.intltool-merge-cache /src/.deps/*.Po /src/.deps/*.Plo + +# IntelliJ IDE folder +.idea/ \ No newline at end of file From d49c5ecf0ce992f8948f7733a602f405f0a680a7 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 19 Aug 2021 11:38:45 +0200 Subject: [PATCH 033/100] Add line feed to end of file --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fda09b62..fe4a0406 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,4 @@ m4/lt~obsolete.m4 /src/.deps/*.Plo # IntelliJ IDE folder -.idea/ \ No newline at end of file +.idea/ From e9527feb4eacdbdcf0450c4a8f1e170c3daa6f69 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 31 Aug 2021 14:01:32 +0200 Subject: [PATCH 034/100] Add libelektra as dependency --- CONTRIBUTING.md | 1 + configure.ac | 4 ++++ src/Makefile.am | 9 ++++++++- src/redshift.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c8a29e75..cfdd9598 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,7 @@ Dependencies * autotools, gettext * intltool, libtool +* libelektra5 * libdrm (Optional, for DRM support) * libxcb, libxcb-randr (Optional, for RandR support) * libX11, libXxf86vm (Optional, for VidMode support) diff --git a/configure.ac b/configure.ac index b4116262..4ae4fbc8 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,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/src/Makefile.am b/src/Makefile.am index 8aa96ead..25618544 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,8 @@ redshift_SOURCES = \ redshift.c redshift.h \ signals.c signals.h \ solar.c solar.h \ - systemtime.c systemtime.h + systemtime.c systemtime.h \ + elektra/redshift-conf.c elektra/redshift-conf.h EXTRA_redshift_SOURCES = \ gamma-drm.c gamma-drm.h \ @@ -80,6 +81,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). diff --git a/src/redshift.h b/src/redshift.h index 0282d839..4196d996 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 From 770f2e4dab0edb1d68dce71b38d3ffa38ce67710 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 31 Aug 2021 15:43:56 +0200 Subject: [PATCH 035/100] Extend specification file to include more keys --- src/elektra/redshift.ini | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 56078bbe..3eb7961a 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -8,6 +8,33 @@ [] mountpoint = redshift.ecf +[mode] +type = enum +check/enum = #3 +check/enum/#0 = continual +check/enum/#1 = print +check/enum/#2 = oneshot +check/enum/#3 = reset +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. +default = continual +example = oneshot +opt/long = mode +opt/arg = required + +[verbose] +type = boolean +description = Verbose output. +default = false +example = true +opt = v + +[version] +type = boolean +description = Show program version. +default = false +example = true +opt = V + [temp/day] type = unsigned_short description = The color temperature the screen should have during daytime. @@ -95,6 +122,13 @@ check/validation = ^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9 opt/long = gamma-night opt/arg = required +[gamma/preserve] +type = boolean +description = Whether to preserve existing gamma ramps before applying adjustments. False will reset them first. +default = true +example = false +opt = P + [adjustment/method] type = enum check/enum = #6 From f5ff3f61537a51d164c6a24869f9e62295138b88 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 31 Aug 2021 15:44:10 +0200 Subject: [PATCH 036/100] Fix wrong type of key provider/location --- src/elektra/redshift.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 3eb7961a..e122f465 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -181,7 +181,7 @@ opt/long = time-dusk opt/arg = required [provider/location] -type = string +type = enum check/enum = #3 check/enum/#0 = corelocation check/enum/#1 = geoclue2 From 15f6c15bdff3b642d28e4eb6bf5d4c6a74c55da0 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 31 Aug 2021 16:54:12 +0200 Subject: [PATCH 037/100] Add range of legal values for keys temp/day and temp/night --- src/elektra/redshift.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index e122f465..5cc6bb9d 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -40,6 +40,8 @@ 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 @@ -48,6 +50,8 @@ 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 From 06845914cc83c9e50db019605b6e1f1f158b0255 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 31 Aug 2021 17:54:03 +0200 Subject: [PATCH 038/100] Remove config keys brightness and gamma in favor of their day/night variants. --- src/elektra/redshift.ini | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 5cc6bb9d..39960539 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -64,17 +64,6 @@ opt = f opt/long = fade opt/arg = none -[brightness] -type = float -description = The screen brightness. -default = 1.0 -example = 0.8 -check/type = float -check/range = 0-1 -opt = b -opt/long = brightness -opt/arg = required - [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. @@ -95,17 +84,6 @@ check/range = 0-1 opt/long = brightness-night opt/arg = required -[gamma] -type = string -description = The screen gamma. 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]+))?$ -opt = g -opt/long = gamma -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). From 27208abb70f9bc866a4adb263648c94d8aca1fe4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 1 Sep 2021 11:49:04 +0200 Subject: [PATCH 039/100] Change boolean values from "true", "false" to "1" and "0" as required by Elektra --- src/elektra/redshift.ini | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 39960539..78794219 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -24,15 +24,15 @@ opt/arg = required [verbose] type = boolean description = Verbose output. -default = false -example = true +default = 0 +example = 1 opt = v [version] type = boolean description = Show program version. -default = false -example = true +default = 0 +example = 1 opt = V [temp/day] @@ -107,8 +107,8 @@ opt/arg = required [gamma/preserve] type = boolean description = Whether to preserve existing gamma ramps before applying adjustments. False will reset them first. -default = true -example = false +default = 1 +example = 0 opt = P [adjustment/method] From 9c4772e08db49f843293b4850bc58e7143f49ab6 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 1 Sep 2021 12:11:18 +0200 Subject: [PATCH 040/100] Set default value for lat, lon of location provider manual. --- src/elektra/redshift.ini | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 78794219..7c5be032 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -197,9 +197,8 @@ description = The location latitude. Only applies to location provider "manual". check/type = float check/range = -90.0-90.0 ; Latitude of berlin: +default = 52.520008 example = 52.520008 -; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. -require = opt/long = lat opt/arg = required @@ -209,9 +208,8 @@ description = The location longitude. Only applies to location provider "manual" check/type = float check/range = -180.0-180.0 ; Longitude of berlin: +default = 13.404954 example = 13.404954 -; No default is provided, so that users are made aware they need to set their own location. A default would irritate users with an actual location that is not equal to the default. -require = opt/long = lon opt/arg = required From 7397bfc388301ac0184a8eeea9e7e886f76f3cd6 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 1 Sep 2021 12:12:02 +0200 Subject: [PATCH 041/100] Split up [provider/time/dawn] and [provider/time/dusk] into time ranges. --- src/elektra/redshift.ini | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 7c5be032..48a7a93f 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -142,24 +142,44 @@ example = time opt/long = provider opt/arg = required -[provider/time/dawn] +[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 +opt/long = time-dawn-start opt/arg = required -[provider/time/dusk] +[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 +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] From 629d68f81fe3358d1972baa631fa696cb0343925 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 1 Sep 2021 12:12:17 +0200 Subject: [PATCH 042/100] Add note on renaming enum values --- src/elektra/redshift.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 48a7a93f..a2a0f904 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -4,6 +4,8 @@ ; For details 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 From 1523d427030f0b9e4c2d05737898c69840e17705 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 1 Sep 2021 16:02:32 +0200 Subject: [PATCH 043/100] Add opt/arg = none for keys added in 770f2e4dab0edb1d68dce71b38d3ffa38ce67710 --- src/elektra/redshift.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index a2a0f904..c5d48280 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -29,6 +29,7 @@ description = Verbose output. default = 0 example = 1 opt = v +opt/arg = none [version] type = boolean @@ -36,6 +37,7 @@ description = Show program version. default = 0 example = 1 opt = V +opt/arg = none [temp/day] type = unsigned_short @@ -112,6 +114,7 @@ description = Whether to preserve existing gamma ramps before applying adjustmen default = 1 example = 0 opt = P +opt/arg = none [adjustment/method] type = enum From efd021934a6826074b3880ae73675597279455fd Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 2 Sep 2021 10:43:55 +0200 Subject: [PATCH 044/100] Improve description of key [gamma/preserve] --- src/elektra/redshift.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index c5d48280..430b945e 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -110,7 +110,7 @@ opt/arg = required [gamma/preserve] type = boolean -description = Whether to preserve existing gamma ramps before applying adjustments. False will reset them first. +description = Use to preserve existing gamma ramps before applying adjustments. default = 1 example = 0 opt = P From b07298e036f8344211d7f03ec866b1ca261801d1 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 2 Sep 2021 12:15:52 +0200 Subject: [PATCH 045/100] Add keys to spec for oneshotmanual, showing list and help for methods and providers --- src/elektra/redshift.ini | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 430b945e..843ef8c1 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -12,12 +12,13 @@ mountpoint = redshift.ecf [mode] type = enum -check/enum = #3 +check/enum = #4 check/enum/#0 = continual check/enum/#1 = print check/enum/#2 = oneshot check/enum/#3 = reset -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. +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 @@ -59,6 +60,16 @@ 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] type = boolean description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. @@ -118,7 +129,7 @@ opt/arg = none [adjustment/method] type = enum -check/enum = #6 +check/enum = #7 check/enum/#0 = drm check/enum/#1 = dummy check/enum/#2 = quartz @@ -126,6 +137,7 @@ 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 @@ -136,6 +148,14 @@ 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 @@ -189,17 +209,26 @@ opt/arg = required [provider/location] type = enum -check/enum = #3 +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. From 39d87838054920592e53cbf907e4b0bd8aabd4ae Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 2 Sep 2021 12:31:26 +0200 Subject: [PATCH 046/100] Replace loading of configuration by usage of Elektra --- src/elektra/redshift-conf.c | 753 ++++++++++++++ src/elektra/redshift-conf.h | 1466 ++++++++++++++++++++++++++++ src/elektra/redshift-conf.mount.sh | 44 + src/gamma-drm.c | 16 +- src/gamma-dummy.c | 5 +- src/gamma-quartz.c | 16 +- src/gamma-randr.c | 57 +- src/gamma-vidmode.c | 7 +- src/gamma-w32gdi.c | 5 +- src/location-corelocation.m | 5 +- src/location-geoclue2.c | 5 +- src/location-manual.c | 20 +- src/options.c | 693 ++++--------- src/options.h | 26 +- src/redshift.c | 249 ++--- src/redshift.h | 4 +- 16 files changed, 2579 insertions(+), 792 deletions(-) create mode 100644 src/elektra/redshift-conf.c create mode 100644 src/elektra/redshift-conf.h create mode 100644 src/elektra/redshift-conf.mount.sh diff --git a/src/elektra/redshift-conf.c b/src/elektra/redshift-conf.c new file mode 100644 index 00000000..40e75918 --- /dev/null +++ b/src/elektra/redshift-conf.c @@ -0,0 +1,753 @@ +// 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 (29, + 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", KEY_META, "default", "1", KEY_META, "description", "Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow.", KEY_META, "example", "0", KEY_META, "opt", "f", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "fade", 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, "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, "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 ("/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\".", 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\".", 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: sw_redshift__0_current [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 Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow.\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 , --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\".\n , --lon=ARG The location longitude. Only applies to location provider \"manual\".\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/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/redshift/#0/current", KEY_END); + + elektraGOptsContract (contract, argc, argv, envp, parentKey, NULL); + + + keyDel (parentKey); + + Elektra * e = elektraOpen ("/sw/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/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..eab96e47 --- /dev/null +++ b/src/elektra/redshift-conf.h @@ -0,0 +1,1466 @@ +// 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' +* +*/// +#define ELEKTRA_TAG_FADE Fade + +/** +* 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 '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' (tag #ELEKTRA_TAG_FADE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'fade'. + + */// +static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_FADE) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Boolean) (elektra, "fade"); +} + + +/** + * Set the value of key 'fade' (tag #ELEKTRA_TAG_FADE). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'fade'. + + * @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) (Elektra * elektra, + kdb_boolean_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Boolean) (elektra, "fade", 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 '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..d8189137 --- /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/sw_redshift__0_current' +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/redshift/#0/current. Please umount first." 1>&2 + exit 1 +} + +if kdb mount -13 | grep -Fxq 'spec:/sw/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'sw_redshift__0_current.overlay.spec.eqd on spec:/sw/redshift/#0/current with name spec:/sw/redshift/#0/current'; then + error_other_mp + fi + + MP=$(echo "spec:/sw/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 "sw_redshift__0_current.overlay.spec.eqd" "spec:/sw/redshift/#0/current" specload "app=$APP_PATH" +fi + +if kdb mount -13 | grep -Fxq '/sw/redshift/#0/current'; then + if ! kdb mount | grep -Fxq 'redshift.ecf on /sw/redshift/#0/current with name /sw/redshift/#0/current'; then + echo "ERROR: another mountpoint already exists on /sw/redshift/#0/current. Please umount first." 1>&2 + exit 1 + fi +else + sudo kdb spec-mount '/sw/redshift/#0/current' +fi diff --git a/src/gamma-drm.c b/src/gamma-drm.c index 04d4f2c0..1580c1e3 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; } diff --git a/src/gamma-dummy.c b/src/gamma-dummy.c index 1730743b..f57ed29a 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 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..458878aa 100644 --- a/src/options.c +++ b/src/options.c @@ -38,37 +38,7 @@ #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); - } -} +#include "elektra/redshift-conf.h" /* A gamma string contains either one floating point value, or three values separated by colon. */ @@ -119,105 +89,6 @@ 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) @@ -228,10 +99,8 @@ print_method_list(const gamma_method_t *gamma_methods) } 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. */ @@ -244,10 +113,8 @@ print_provider_list(const location_provider_t location_providers[]) } 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 +150,194 @@ 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 + + // Programm mode + ElektraEnumMode mode = elektraGetMode(elektra); + if (mode == ELEKTRA_ENUM_MODE_CONTINUAL) { + options->mode = PROGRAM_MODE_CONTINUAL; + } else if (mode == ELEKTRA_ENUM_MODE_ONESHOT) { + options->mode = PROGRAM_MODE_ONE_SHOT; + } else if (mode == ELEKTRA_ENUM_MODE_PRINT) { + options->mode = PROGRAM_MODE_PRINT; + } else if (mode == ELEKTRA_ENUM_MODE_RESET) { + options->mode = PROGRAM_MODE_RESET; + } else if (mode == ELEKTRA_ENUM_MODE_ONESHOTMANUAL) { + options->temp_set = elektraGetTempOneshotmanual(elektra); + options->mode = PROGRAM_MODE_MANUAL; + } + + // 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 locationProvider provider is not supported in this build of redshift.\n")); + 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 is not supported in this build of redshift.\n")); + 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 = elektraGetFade(elektra); + + // Temperature + options->scheme.day.temperature = elektraGetTempDay(elektra); + options->scheme.night.temperature = elektraGetTempNight(elektra); + + // Verbose + options->verbose = elektraGetVerbose(elektra); + + // Version + if (elektraGetVersion(elektra)) { + printf("%s\n", PACKAGE_STRING); + return -1; + } + + // 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 +345,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 +365,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->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..699237c6 100644 --- a/src/options.h +++ b/src/options.h @@ -39,25 +39,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..5f744497 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -60,6 +60,7 @@ int poll(struct pollfd *fds, int nfds, int timeout) { abort(); return -1; } #endif #include "redshift.h" +#include "elektra/redshift-conf.h" #include "config-ini.h" #include "solar.h" #include "systemtime.h" @@ -320,8 +321,7 @@ 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; @@ -332,73 +332,20 @@ provider_try_start(const location_provider_t *provider, 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); @@ -412,7 +359,7 @@ 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; @@ -423,58 +370,20 @@ method_try_start(const gamma_method_t *method, 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); @@ -890,11 +799,43 @@ run_continual_mode(const location_provider_t *provider, } -int -main(int argc, char *argv[]) +static void onFatalError (ElektraError * error) +{ + fprintf (stderr, "ERROR: %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, "An error occurred while opening Elektra: %s", 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, ""); @@ -946,49 +887,18 @@ 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 = @@ -1000,7 +910,7 @@ main(int argc, char *argv[]) /* 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. */ @@ -1012,7 +922,7 @@ main(int argc, char *argv[]) _("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); @@ -1130,8 +1040,7 @@ main(int argc, char *argv[]) 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. */ @@ -1140,7 +1049,7 @@ main(int argc, char *argv[]) if (!m->autostart) continue; r = method_try_start( - m, &method_state, &config_state, NULL); + m, &method_state, &options); if (r < 0) { fputs(_("Trying next method...\n"), stderr); continue; @@ -1160,8 +1069,6 @@ main(int argc, char *argv[]) } } - config_ini_free(&config_state); - switch (options.mode) { case PROGRAM_MODE_ONE_SHOT: case PROGRAM_MODE_PRINT: diff --git a/src/redshift.h b/src/redshift.h index 4196d996..ee5239ee 100644 --- a/src/redshift.h +++ b/src/redshift.h @@ -87,7 +87,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); @@ -125,7 +125,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); From f3a69b6964576be3913415687ca8902cae9fca2d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 2 Sep 2021 12:40:04 +0200 Subject: [PATCH 047/100] Remove now unused files config-ini.h and config-ini.c --- src/Makefile.am | 1 - src/config-ini.c | 326 ----------------------------------------------- src/config-ini.h | 49 ------- src/options.c | 1 - src/redshift.c | 1 - 5 files changed, 378 deletions(-) delete mode 100644 src/config-ini.c delete mode 100644 src/config-ini.h diff --git a/src/Makefile.am b/src/Makefile.am index 25618544..f7775504 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 \ 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/options.c b/src/options.c index 458878aa..221ee0cf 100644 --- a/src/options.c +++ b/src/options.c @@ -35,7 +35,6 @@ #endif #include "redshift.h" -#include "config-ini.h" #include "options.h" #include "solar.h" #include "elektra/redshift-conf.h" diff --git a/src/redshift.c b/src/redshift.c index 5f744497..050a5215 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -61,7 +61,6 @@ int poll(struct pollfd *fds, int nfds, int timeout) { abort(); return -1; } #include "redshift.h" #include "elektra/redshift-conf.h" -#include "config-ini.h" #include "solar.h" #include "systemtime.h" #include "hooks.h" From 961c95d899270bc48d1273fb52880420b5460f48 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 3 Sep 2021 09:32:50 +0200 Subject: [PATCH 048/100] Fix typo --- src/elektra/redshift.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 843ef8c1..48088dad 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -5,7 +5,7 @@ ; 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. +; (e.g. the string values of enum [provider/location] are used in options.c). [] mountpoint = redshift.ecf From 57dad1122cf446d905c93f699b4ca0462eb7843c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 9 Sep 2021 14:08:21 +0200 Subject: [PATCH 049/100] Add files generated by Elektra to .gitignore --- .gitignore | 2 + src/elektra/redshift-conf.c | 753 -------------- src/elektra/redshift-conf.h | 1466 ---------------------------- src/elektra/redshift-conf.mount.sh | 44 - 4 files changed, 2 insertions(+), 2263 deletions(-) delete mode 100644 src/elektra/redshift-conf.c delete mode 100644 src/elektra/redshift-conf.h delete mode 100644 src/elektra/redshift-conf.mount.sh diff --git a/.gitignore b/.gitignore index fe4a0406..8b1d2f7e 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,8 @@ m4/lt~obsolete.m4 /src/redshift-gtk/Makefile /src/redshift-gtk/redshift-gtk /src/redshift-gtk/__pycache__/ +# generated by Elektra +/src/elektra/redshift-conf.* # gettext /po/POTFILES diff --git a/src/elektra/redshift-conf.c b/src/elektra/redshift-conf.c deleted file mode 100644 index 40e75918..00000000 --- a/src/elektra/redshift-conf.c +++ /dev/null @@ -1,753 +0,0 @@ -// 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 (29, - 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", KEY_META, "default", "1", KEY_META, "description", "Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow.", KEY_META, "example", "0", KEY_META, "opt", "f", KEY_META, "opt/arg", "none", KEY_META, "opt/long", "fade", 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, "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, "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 ("/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\".", 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\".", 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: sw_redshift__0_current [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 Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow.\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 , --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\".\n , --lon=ARG The location longitude. Only applies to location provider \"manual\".\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/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/redshift/#0/current", KEY_END); - - elektraGOptsContract (contract, argc, argv, envp, parentKey, NULL); - - - keyDel (parentKey); - - Elektra * e = elektraOpen ("/sw/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/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 deleted file mode 100644 index eab96e47..00000000 --- a/src/elektra/redshift-conf.h +++ /dev/null @@ -1,1466 +0,0 @@ -// 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' -* -*/// -#define ELEKTRA_TAG_FADE Fade - -/** -* 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 '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' (tag #ELEKTRA_TAG_FADE). - * - * @param elektra Instance of Elektra. Create with loadConfiguration(). - - * - * @return the value of 'fade'. - - */// -static inline kdb_boolean_t ELEKTRA_GET (ELEKTRA_TAG_FADE) (Elektra * elektra ) -{ - - return ELEKTRA_GET (Boolean) (elektra, "fade"); -} - - -/** - * Set the value of key 'fade' (tag #ELEKTRA_TAG_FADE). - * - * @param elektra Instance of Elektra. Create with loadConfiguration(). - * @param value The value of 'fade'. - - * @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) (Elektra * elektra, - kdb_boolean_t value, ElektraError ** error) -{ - - ELEKTRA_SET (Boolean) (elektra, "fade", 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 '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 deleted file mode 100644 index d8189137..00000000 --- a/src/elektra/redshift-conf.mount.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -if [ -z "$APP_PATH" ]; then - # TODO: set APP_PATH to the installed path of your application - APP_PATH='/usr/local/bin/sw_redshift__0_current' -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/redshift/#0/current. Please umount first." 1>&2 - exit 1 -} - -if kdb mount -13 | grep -Fxq 'spec:/sw/redshift/#0/current'; then - if ! kdb mount | grep -Fxq 'sw_redshift__0_current.overlay.spec.eqd on spec:/sw/redshift/#0/current with name spec:/sw/redshift/#0/current'; then - error_other_mp - fi - - MP=$(echo "spec:/sw/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 "sw_redshift__0_current.overlay.spec.eqd" "spec:/sw/redshift/#0/current" specload "app=$APP_PATH" -fi - -if kdb mount -13 | grep -Fxq '/sw/redshift/#0/current'; then - if ! kdb mount | grep -Fxq 'redshift.ecf on /sw/redshift/#0/current with name /sw/redshift/#0/current'; then - echo "ERROR: another mountpoint already exists on /sw/redshift/#0/current. Please umount first." 1>&2 - exit 1 - fi -else - sudo kdb spec-mount '/sw/redshift/#0/current' -fi From 09dc2841f8bd110860169a87dc201e1c59324510 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 9 Sep 2021 14:10:42 +0200 Subject: [PATCH 050/100] Add kdb gen and mount to autotools configuration and contributing documentation --- CONTRIBUTING.md | 3 ++- src/Makefile.am | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cfdd9598..edabb884 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,10 +25,11 @@ $ ./configure --prefix=$HOME/redshift/root \ --with-systemduserunitdir=$HOME/.config/systemd/user ``` -Now, build the files: +Now, build the files and mount the Elektra specification: ``` shell $ make +$ APP_PATH=`pwd`/src/redshift sh src/elektra/redshift-conf.mount.sh ``` The main redshift program can be run at this point. To install to the diff --git a/src/Makefile.am b/src/Makefile.am index f7775504..092417df 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,16 @@ EXTRA_redshift_SOURCES = \ windows/appicon.rc \ windows/versioninfo.rc +# Note: CLEANFILES and KDB are based on https://github.com/kodebach/lcdproc/blob/3e2b9d3f5cade3bbe21fdb5a9ea1c9ffc1c994fa/server/Makefile.am +CLEANFILES = elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh + +scriptsdir = $(prefix)/libexec +scripts_DATA = elektra/redshift-conf.mount.sh + +KDB ?= kdb +elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh: elektra/redshift.ini + $(KDB) gen -F ni=elektra/redshift.ini highlevel "/sw/redshift/#0/current" elektra/redshift-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; + AM_CFLAGS = redshift_LDADD = @LIBINTL@ EXTRA_DIST = windows/redshift.ico From 5f859498474567753d8253c71bd01568cd4c206a Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 11 Sep 2021 15:11:04 +0200 Subject: [PATCH 051/100] Fix parallel execution of make --- po/redshift.pot | 809 ------------------------------------------------ src/Makefile.am | 17 +- 2 files changed, 10 insertions(+), 816 deletions(-) delete mode 100644 po/redshift.pot 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/src/Makefile.am b/src/Makefile.am index 092417df..408d5cbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,8 +18,7 @@ redshift_SOURCES = \ redshift.c redshift.h \ signals.c signals.h \ solar.c solar.h \ - systemtime.c systemtime.h \ - elektra/redshift-conf.c elektra/redshift-conf.h + systemtime.c systemtime.h EXTRA_redshift_SOURCES = \ gamma-drm.c gamma-drm.h \ @@ -32,16 +31,20 @@ EXTRA_redshift_SOURCES = \ windows/appicon.rc \ windows/versioninfo.rc -# Note: CLEANFILES and KDB are based on https://github.com/kodebach/lcdproc/blob/3e2b9d3f5cade3bbe21fdb5a9ea1c9ffc1c994fa/server/Makefile.am +# Note: rules for Elektra are based on https://github.com/kodebach/lcdproc/blob/3e2b9d3f5cade3bbe21fdb5a9ea1c9ffc1c994fa/server/Makefile.am CLEANFILES = elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh +nodist_redshift_SOURCES = elektra/redshift-conf.h elektra/redshift-conf.c +redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-conf.c + +KDB ?= kdb +# Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. +# see https://stackoverflow.com/a/10609434 +%-conf.c %-conf.h %-conf.mount.sh: %.ini + $(KDB) gen -F ni=$*.ini highlevel "/sw/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh -KDB ?= kdb -elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh: elektra/redshift.ini - $(KDB) gen -F ni=elektra/redshift.ini highlevel "/sw/redshift/#0/current" elektra/redshift-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; - AM_CFLAGS = redshift_LDADD = @LIBINTL@ EXTRA_DIST = windows/redshift.ico From 20f98909e7ca350429a5103ef334dfa48e120e4e Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 14:33:34 +0200 Subject: [PATCH 052/100] Update README.md with infos about changing configuration and remove obsolete sample configuration file. Solves https://github.com/jonls/redshift/pull/837#discussion_r706225769. --- README.md | 38 ++++++++++++++++-------- redshift.conf.sample | 70 -------------------------------------------- 2 files changed, 25 insertions(+), 83 deletions(-) delete mode 100644 redshift.conf.sample diff --git a/README.md b/README.md index 85c00e0d..24f6eb62 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/redshift/#0/current/provider/location manual +kdb set user:/sw/redshift/#0/current/provider/location/manual/lat 52.0 +kdb set user:/sw/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/redshift/#0/current` +* For details on a configuration option execute: + * `kdb meta-get spec:/sw/redshift/#0/current/INSERT_OPTION_NAME description` + * e.g.: `kdb meta-get spec:/sw/redshift/#0/current/fade description` ### Where can I find my coordinates to put in the configuration file? 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 From 06c474429936ebcf675210aab15c3b9bc983b1f5 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 14:37:11 +0200 Subject: [PATCH 053/100] Add note that mounting specification requires root privileges. Solves https://github.com/jonls/redshift/pull/837#discussion_r706227664 --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index edabb884..4298d828 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,8 @@ $ ./configure --prefix=$HOME/redshift/root \ --with-systemduserunitdir=$HOME/.config/systemd/user ``` -Now, build the files and mount the Elektra specification: +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 From 18112302f2459cb582e6d02019290af1204fb6df Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 14:55:56 +0200 Subject: [PATCH 054/100] Reformat comment about specification files --- src/elektra/redshift.ini | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ini index 48088dad..b875f451 100644 --- a/src/elektra/redshift.ini +++ b/src/elektra/redshift.ini @@ -1,7 +1,13 @@ ; Elektra specification file for redshift@490ba2aae9cfee097a88b6e2be98aeb1ce990050 (= redshift v1.12 + some small commits) ; -; A specification file describes which configuration settings an application supports, their defaults and their associated CLI options. It also "(...) defines how the configuration settings should be validated" (source: https://www.libelektra.org/tutorials/validate-configuration) -; For details see: https://www.libelektra.org/tutorials/writing-a-specification-for-your-configuration) +; 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. From 6e44e5a2d9f9c2ebb9a2a9b1a6b54930ea1c83a2 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:01:57 +0200 Subject: [PATCH 055/100] Change file suffix of specification file to .ni. Solves https://github.com/jonls/redshift/pull/837#discussion_r706233696 --- src/Makefile.am | 4 ++-- src/elektra/{redshift.ini => redshift.ni} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/elektra/{redshift.ini => redshift.ni} (100%) diff --git a/src/Makefile.am b/src/Makefile.am index 408d5cbc..9408a60a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,8 +39,8 @@ redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-c KDB ?= kdb # Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. # see https://stackoverflow.com/a/10609434 -%-conf.c %-conf.h %-conf.mount.sh: %.ini - $(KDB) gen -F ni=$*.ini highlevel "/sw/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; +%-conf.c %-conf.h %-conf.mount.sh: %.ni + $(KDB) gen -F ni=$*.ni highlevel "/sw/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh diff --git a/src/elektra/redshift.ini b/src/elektra/redshift.ni similarity index 100% rename from src/elektra/redshift.ini rename to src/elektra/redshift.ni From 1c946bb8a49832936e4c0e22813561365f48659d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:06:27 +0200 Subject: [PATCH 056/100] Add organisation part "jonls" to redshift's application key name. Solves https://github.com/jonls/redshift/pull/837#discussion_r706248711 --- README.md | 12 ++++++------ src/Makefile.am | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 24f6eb62..f811e164 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,18 @@ please see _Building from source_ and _Latest builds from master branch_ below. * To set your location via `kdb` execute: ``` -kdb set user:/sw/redshift/#0/current/provider/location manual -kdb set user:/sw/redshift/#0/current/provider/location/manual/lat 52.0 -kdb set user:/sw/redshift/#0/current/provider/location/manual/lon 14.0 +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/redshift/#0/current` + * `kdb ls spec:/sw/jonls/redshift/#0/current` * For details on a configuration option execute: - * `kdb meta-get spec:/sw/redshift/#0/current/INSERT_OPTION_NAME description` - * e.g.: `kdb meta-get spec:/sw/redshift/#0/current/fade description` + * `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/src/Makefile.am b/src/Makefile.am index 9408a60a..5e765474 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,7 +40,7 @@ KDB ?= kdb # Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. # see https://stackoverflow.com/a/10609434 %-conf.c %-conf.h %-conf.mount.sh: %.ni - $(KDB) gen -F ni=$*.ni highlevel "/sw/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; + $(KDB) gen -F ni=$*.ni highlevel "/sw/jonls/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh From 6cac79470b40c458433fe09aeb411bf19f8fb4fe Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:18:24 +0200 Subject: [PATCH 057/100] Improve description and fix wrong mapping of "fastfade" option. Solves https://github.com/jonls/redshift/pull/837#discussion_r706249256 --- src/elektra/redshift.ni | 10 +++++----- src/options.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index b875f451..bf1469c0 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -76,13 +76,13 @@ check/range = 1000-25000 opt/long = temp-oneshotmanual opt/arg = required -[fade] +[fastfade] type = boolean -description = Whether transitions between color temperatures (e.g. from daytime to nighttime) should happen fast or slow. -default = 1 -example = 0 +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 +opt/long = fastfade opt/arg = none [brightness/day] diff --git a/src/options.c b/src/options.c index 221ee0cf..5fb3b9aa 100644 --- a/src/options.c +++ b/src/options.c @@ -285,7 +285,7 @@ options_load_from_elektra( options->preserve_gamma = elektraGetGammaPreserve(elektra); // Fade - options->use_fade = elektraGetFade(elektra); + options->use_fade = !elektraGetFastfade(elektra); // Temperature options->scheme.day.temperature = elektraGetTempDay(elektra); From 5c1b3c23160b8ea8d3c70284170197888f897fa3 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:24:26 +0200 Subject: [PATCH 058/100] Ensure string format of configured location is compatible with specification. Solves https://github.com/jonls/redshift/pull/837#discussion_r706253739 --- src/redshift.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 050a5215..68e657ab 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -250,12 +250,8 @@ print_location(const location_t *location) /* 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 latitude: %.2f, longitude: %.2f\n"), location->lat, location->lon); } /* Interpolate color setting structs given alpha. */ From df9937fbfad27169f3ee2301d799d1fde739cc9d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:30:37 +0200 Subject: [PATCH 059/100] Remove obsolete compass direction abbreviations. Addendum to 5c1b3c23160b8ea8d3c70284170197888f897fa3. --- src/redshift.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 68e657ab..d355e1ef 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -241,15 +241,6 @@ 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.*/ printf(_("Location latitude: %.2f, longitude: %.2f\n"), location->lat, location->lon); } From 45939538bb83a47bdc96be3a0afa27bc3199cb76 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:36:47 +0200 Subject: [PATCH 060/100] Add human-readable error message for options gamma/day and gamma/night. Solves https://github.com/jonls/redshift/pull/837#discussion_r706268909 --- src/elektra/redshift.ni | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index bf1469c0..b263df98 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -112,6 +112,7 @@ 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 @@ -122,6 +123,7 @@ 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 From 65fcae3fdad47be16f736b2c43c067dae3a41f76 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:42:06 +0200 Subject: [PATCH 061/100] Remove obsolete comments from specification file. https://github.com/jonls/redshift/pull/837#discussion_r706272570 --- src/elektra/redshift.ni | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index b263df98..2e4dbdb5 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -277,8 +277,6 @@ opt/arg = required ; Note: other location providers have no config parameters/cli arguments -; BEGIN Settings used by randr and drm -;======================================================= [adjustment/crtc] type = unsigned_short description = CRTC to apply adjustments to. @@ -286,11 +284,7 @@ default = 0 example = 1 opt/long = crtc opt/arg = required -;======================================================= -; END Settings used by randr and drm -; BEGIN Settings used by randr and vidmode -;======================================================= [adjustment/screen] type = unsigned_short description = X screen to apply adjustments to. @@ -298,11 +292,7 @@ default = 0 example = 1 opt/long = screen opt/arg = required -;======================================================= -; END Settings used by randr and vidmode -; BEGIN Settings used by drm -;======================================================= [adjustment/drm/card] type = unsigned_short description = Graphics card to apply adjustments to. @@ -310,7 +300,5 @@ default = 0 example = 1 opt/long = drm-card opt/arg = required -;======================================================= -; END Settings used by drm ; Note: adjustment methods dummy, quartz and w32gdi have no config parameters/cli arguments or none that have an effect. From 0faff13e12180b8cb3167ebf7458ec7edf05f9f4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:43:59 +0200 Subject: [PATCH 062/100] Fix typo. Solves https://github.com/jonls/redshift/pull/837#discussion_r706272685 --- src/elektra/redshift.ni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index 2e4dbdb5..a0a93917 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -258,7 +258,7 @@ type = float description = The location latitude. Only applies to location provider "manual". check/type = float check/range = -90.0-90.0 -; Latitude of berlin: +; Latitude of Berlin: default = 52.520008 example = 52.520008 opt/long = lat From 2d099f1e4a79a3252ae47059857fd73d192e7cd3 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 15:52:10 +0200 Subject: [PATCH 063/100] Add info about negative values for "lat" and "lon" options. Solves https://github.com/jonls/redshift/pull/837#discussion_r706273118 --- src/elektra/redshift.ni | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index a0a93917..45618a80 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -255,7 +255,7 @@ opt/arg = required [provider/location/manual/lat] type = float -description = The location latitude. Only applies to location provider "manual". +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: @@ -266,7 +266,7 @@ opt/arg = required [provider/location/manual/lon] type = float -description = The location longitude. Only applies to location provider "manual". +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: From b677acf003e4841b5399e45dc22b7d04d6d9f3f8 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 16:01:04 +0200 Subject: [PATCH 064/100] Refactor mapping of programm mode from if-else to switch. This triggers compiler warnings when a new mode is added to the specification but not handled in code. Solves https://github.com/jonls/redshift/pull/837#discussion_r706274940. --- src/options.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/options.c b/src/options.c index 5fb3b9aa..c13b8f43 100644 --- a/src/options.c +++ b/src/options.c @@ -173,17 +173,28 @@ options_load_from_elektra( // Programm mode ElektraEnumMode mode = elektraGetMode(elektra); - if (mode == ELEKTRA_ENUM_MODE_CONTINUAL) { - options->mode = PROGRAM_MODE_CONTINUAL; - } else if (mode == ELEKTRA_ENUM_MODE_ONESHOT) { - options->mode = PROGRAM_MODE_ONE_SHOT; - } else if (mode == ELEKTRA_ENUM_MODE_PRINT) { - options->mode = PROGRAM_MODE_PRINT; - } else if (mode == ELEKTRA_ENUM_MODE_RESET) { - options->mode = PROGRAM_MODE_RESET; - } else if (mode == ELEKTRA_ENUM_MODE_ONESHOTMANUAL) { - options->temp_set = elektraGetTempOneshotmanual(elektra); - options->mode = PROGRAM_MODE_MANUAL; + switch (mode) { + case ELEKTRA_ENUM_MODE_CONTINUAL: { + options->mode = PROGRAM_MODE_CONTINUAL; + break; + } + case ELEKTRA_ENUM_MODE_ONESHOT: { + options->mode = PROGRAM_MODE_ONE_SHOT; + break; + } + case ELEKTRA_ENUM_MODE_PRINT: { + options->mode = PROGRAM_MODE_PRINT; + break; + } + case ELEKTRA_ENUM_MODE_RESET: { + options->mode = PROGRAM_MODE_RESET; + break; + } + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: { + options->temp_set = elektraGetTempOneshotmanual(elektra); + options->mode = PROGRAM_MODE_MANUAL; + break; + } } // Brightness From ef12443c38f0d48ae8e41c2c4546ec2d65a47832 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 13 Sep 2021 16:06:28 +0200 Subject: [PATCH 065/100] Improve error messages for unsupported location provider/adjustment method. Solves https://github.com/jonls/redshift/pull/837#discussion_r706275884 --- src/options.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options.c b/src/options.c index c13b8f43..79f1b6a4 100644 --- a/src/options.c +++ b/src/options.c @@ -249,7 +249,7 @@ options_load_from_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 locationProvider provider is not supported in this build of redshift.\n")); + fprintf(stderr, _("The chosen location provider \"%s\" is not supported in this build of redshift.\n"), locationProviderName); return -1; } else { @@ -279,7 +279,7 @@ options_load_from_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 is not supported in this build of redshift.\n")); + fprintf(stderr, _("The chosen adjustment method \"%s\" is not supported in this build of redshift.\n"), adjustmentMethodName); return -1; } else { From b0d66c6b805e39c0f99db826e47482e3a6e4afa4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 17 Sep 2021 13:37:42 +0200 Subject: [PATCH 066/100] Make error messages more user-friendly --- src/redshift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index d355e1ef..5824fbeb 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -787,7 +787,7 @@ run_continual_mode(const location_provider_t *provider, static void onFatalError (ElektraError * error) { - fprintf (stderr, "ERROR: %s\n", elektraErrorDescription (error)); + fprintf (stderr, "Accessing redshift's configuration failed: %s\n", elektraErrorDescription (error)); elektraErrorReset (&error); exit (EXIT_FAILURE); } @@ -804,7 +804,7 @@ int main(int argc, const char * const *argv, const char * const *envp) if (rc == -1) { - fprintf (stderr, "An error occurred while opening Elektra: %s", elektraErrorDescription (error)); + fprintf (stderr, "Opening redshift's configuration failed: %s", elektraErrorDescription (error)); elektraErrorReset (&error); exit (EXIT_FAILURE); } From f8d59d2e64c8a316f9255f6ce4be575efa195f77 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 11:23:13 +0200 Subject: [PATCH 067/100] Improve error messages --- src/redshift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 5824fbeb..6bb5acf1 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -804,7 +804,7 @@ int main(int argc, const char * const *argv, const char * const *envp) if (rc == -1) { - fprintf (stderr, "Opening redshift's configuration failed: %s", elektraErrorDescription (error)); + fprintf (stderr, "Opening redshift's configuration failed: %s\n", elektraErrorDescription (error)); elektraErrorReset (&error); exit (EXIT_FAILURE); } @@ -1049,7 +1049,7 @@ int main(int argc, const char * const *argv, const char * const *envp) /* 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. Exiting now.\n"), stderr); exit(EXIT_FAILURE); } } From 9c0bf1b20c64e228d5b739a7dc4b64f6b737dd14 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 11:36:27 +0200 Subject: [PATCH 068/100] Improve error message about no working location provider --- src/redshift.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 6bb5acf1..9a04d920 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -924,8 +924,7 @@ int main(int argc, const char * const *argv, const char * const *envp) /* 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,7 +1048,7 @@ int main(int argc, const char * const *argv, const char * const *envp) /* Failure if no methods were successful at this point. */ if (options.method == NULL) { - fputs(_("Redshift was unable to adjust your screen temperature. Reason: None of the temperature adjustment methods of this build work on your system. Exiting now.\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); } } From 39468d0a18a4bfce5a16968f178a862e296a1e27 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 12:10:20 +0200 Subject: [PATCH 069/100] Add line breaks to error messages --- src/redshift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 9a04d920..a61d728d 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -787,7 +787,7 @@ run_continual_mode(const location_provider_t *provider, static void onFatalError (ElektraError * error) { - fprintf (stderr, "Accessing redshift's configuration failed: %s\n", elektraErrorDescription (error)); + fprintf (stderr, "Accessing redshift's configuration failed: \n%s\n", elektraErrorDescription (error)); elektraErrorReset (&error); exit (EXIT_FAILURE); } @@ -804,7 +804,7 @@ int main(int argc, const char * const *argv, const char * const *envp) if (rc == -1) { - fprintf (stderr, "Opening redshift's configuration failed: %s\n", elektraErrorDescription (error)); + fprintf (stderr, "Opening redshift's configuration failed: \n%s\n", elektraErrorDescription (error)); elektraErrorReset (&error); exit (EXIT_FAILURE); } From 268a813c651e8cfa180c197c9b2fb3ddbab7e436 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 12:58:46 +0200 Subject: [PATCH 070/100] Improve usability of automatic adjustment method selection: 1. Make all methods eligible for autostart. 2. Move DRM method down in priority list -> it will be tried last before the dummy method. This improves usability: Users who start redshift in a build that only has "dummy" or "drm" will be informed about the situation. Before this commit, the startup failed when only "dummy" was available, which can lead to confusion. --- src/gamma-drm.c | 2 +- src/gamma-dummy.c | 2 +- src/redshift.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gamma-drm.c b/src/gamma-drm.c index 1580c1e3..fcf9dcb6 100644 --- a/src/gamma-drm.c +++ b/src/gamma-drm.c @@ -316,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 f57ed29a..937dd88c 100644 --- a/src/gamma-dummy.c +++ b/src/gamma-dummy.c @@ -81,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/redshift.c b/src/redshift.c index a61d728d..c5641f49 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -834,9 +834,6 @@ int main(int argc, const char * const *argv, const char * const *envp) /* List of gamma methods. */ const gamma_method_t gamma_methods[] = { -#ifdef ENABLE_DRM - drm_gamma_method, -#endif #ifdef ENABLE_RANDR randr_gamma_method, #endif @@ -848,6 +845,9 @@ int main(int argc, const char * const *argv, const char * const *envp) #endif #ifdef ENABLE_WINGDI w32gdi_gamma_method, +#endif +#ifdef ENABLE_DRM + drm_gamma_method, #endif dummy_gamma_method, { NULL } From ea42cf2ca07e80d38c48fe8c5f296b463b1ea804 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:01:47 +0200 Subject: [PATCH 071/100] Improve usability of method and location provider listing. Users are now informed, if their build of redshift contains no method/provider that would work on their system. --- src/options.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/options.c b/src/options.c index 79f1b6a4..a71ae2af 100644 --- a/src/options.c +++ b/src/options.c @@ -92,7 +92,12 @@ parse_transition_time(const char *str, const char **end) 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); } @@ -106,7 +111,12 @@ print_method_list(const gamma_method_t *gamma_methods) 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); } From 5ccebbb2fe655ad4a85b03d010cf03e37f03cc93 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:47:04 +0200 Subject: [PATCH 072/100] Improve usability of auto mode for method and location provider. --- src/redshift.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index c5641f49..7e5b07bf 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -313,7 +313,7 @@ provider_try_start(const location_provider_t *provider, 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; } @@ -335,7 +335,7 @@ provider_try_start(const location_provider_t *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; } @@ -351,7 +351,7 @@ method_try_start(const gamma_method_t *method, 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; } @@ -900,6 +900,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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 one.\n"), stdout); for (int i = 0; location_providers[i].name != NULL; i++) { const location_provider_t *p = @@ -1029,6 +1030,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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 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; From 4c7e6636b8ac6ec306ac43f2ce5b1ca63213f1cb Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:50:42 +0200 Subject: [PATCH 073/100] Improve usability of auto mode for method and location provider. --- CONTRIBUTING.md | 59 ++++++++++++++++++++++++++++++++++++------------- src/redshift.c | 12 +++++----- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4298d828..b9c2c757 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,29 +2,49 @@ 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 ``` +### 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). @@ -33,8 +53,14 @@ $ make $ APP_PATH=`pwd`/src/redshift sh src/elektra/redshift-conf.mount.sh ``` -The main redshift program can be run at this point. To install to the -prefix directory run: +### 4. Execute redshift +The main redshift program can be run at this point: +```shell +$ src/redshift +``` + +### 5. Optional: Install +To install to the prefix directory run: ``` shell $ make install @@ -53,15 +79,18 @@ Dependencies * autotools, gettext * intltool, libtool * libelektra5 -* libdrm (Optional, for DRM support) -* libxcb, libxcb-randr (Optional, for RandR support) -* libX11, libXxf86vm (Optional, for VidMode support) +* 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**! Coding style for C code diff --git a/src/redshift.c b/src/redshift.c index 7e5b07bf..af85266a 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -900,7 +900,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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 one.\n"), stdout); + 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 = @@ -911,13 +911,13 @@ int main(int argc, const char * const *argv, const char * const *envp) r = provider_try_start(p, &location_state, &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(_("Automatically chose location provider `%s'.\n"), p->name); options.provider = p; break; } @@ -1030,7 +1030,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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 one.\n"), stdout); + 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; @@ -1043,7 +1043,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } /* Found method that works. */ - printf(_("Using method `%s'.\n"), m->name); + printf(_("Automatically chose adjustment method `%s'.\n"), m->name); options.method = m; break; } From 8785b4519484177e8c5552828cfd622261b9fec0 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:51:07 +0200 Subject: [PATCH 074/100] Use stderr only for errors, not for infos. --- src/redshift.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index af85266a..dee27381 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -533,7 +533,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); @@ -905,7 +905,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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, @@ -1038,7 +1038,7 @@ int main(int argc, const char * const *argv, const char * const *envp) r = method_try_start( m, &method_state, &options); if (r < 0) { - fputs(_("Trying next method...\n"), stderr); + fputs(_("Trying next method...\n"), stdout); continue; } @@ -1063,7 +1063,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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( From 35eabb1952d476047895ad40e70fc97a88b70d77 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:53:31 +0200 Subject: [PATCH 075/100] Improve info messages for auto mode for method and location provider. --- src/redshift.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index dee27381..156b0078 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -917,7 +917,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } /* Found provider that works. */ - printf(_("Automatically chose location provider `%s'.\n"), p->name); + printf(_("`%s' works and will be used.\n"), p->name); options.provider = p; break; } @@ -1035,6 +1035,9 @@ int main(int argc, const char * const *argv, const char * const *envp) 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, &options); if (r < 0) { @@ -1043,7 +1046,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } /* Found method that works. */ - printf(_("Automatically chose adjustment method `%s'.\n"), m->name); + printf(_("`%s' works and will be used.\n"), m->name); options.method = m; break; } From 42b57687e570d09c84616edc44f6dd0909403999 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 13:54:50 +0200 Subject: [PATCH 076/100] Improve info message for location available. --- src/redshift.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redshift.c b/src/redshift.c index 156b0078..0456eb89 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -242,7 +242,7 @@ static void print_location(const location_t *location) { /* TRANSLATORS: Append degree symbols after %f if possible.*/ - printf(_("Location latitude: %.2f, longitude: %.2f\n"), location->lat, location->lon); + printf(_("Location is now available! Latitude: %.2f, longitude: %.2f\n"), location->lat, location->lon); } /* Interpolate color setting structs given alpha. */ From c6b8e479b32ed8f315d6c34d075f3e72e9d03cd0 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 14:00:27 +0200 Subject: [PATCH 077/100] Revert CONTRIBUTING.md which was commited too early in 4c7e6636b8ac6ec306ac43f2ce5b1ca63213f1cb. --- CONTRIBUTING.md | 59 +++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 44 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b9c2c757..4298d828 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,49 +2,29 @@ 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. -### 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 +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 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 --enable-randr --prefix=$HOME/redshift/root \ +$ ./configure --prefix=$HOME/redshift/root \ --with-systemduserunitdir=$HOME/.config/systemd/user ``` -### 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). @@ -53,14 +33,8 @@ $ 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 -``` - -### 5. Optional: Install -To install to the prefix directory run: +The main redshift program can be run at this point. To install to the +prefix directory run: ``` shell $ make install @@ -79,18 +53,15 @@ Dependencies * autotools, gettext * intltool, libtool * 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) +* libdrm (Optional, for DRM support) +* libxcb, libxcb-randr (Optional, for RandR support) +* libX11, libXxf86vm (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) -#### 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**! +Ubuntu users will find all these dependencies in the packages listed in ``.travis.yml``. Coding style for C code From 52f3417c1f0cb1a6e6138f66724f5fd36a268ad2 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 14:03:25 +0200 Subject: [PATCH 078/100] Improve CONTRIBUTING.md: 1. Emphasize that redshift's functionality will be very limited without installed dependencies. 2. Improve structure by adding more headers and enumerations. 3. Add details about purpose and options of ./configure script 4. Emphasize that dependencies are optional but suggested 5. Emhpasize that "-dev" packages are required for dependencies. --- CONTRIBUTING.md | 59 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4298d828..ac2822c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,29 +2,49 @@ 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 ``` +### 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). @@ -33,8 +53,14 @@ $ make $ APP_PATH=`pwd`/src/redshift sh src/elektra/redshift-conf.mount.sh ``` -The main redshift program can be run at this point. To install to the -prefix directory run: +### 4. Execute redshift +The main redshift program can be run at this point: +```shell +$ src/redshift +``` + +### 5. Optional: Install +To install to the prefix directory run: ``` shell $ make install @@ -53,15 +79,18 @@ Dependencies * autotools, gettext * intltool, libtool * libelektra5 -* libdrm (Optional, for DRM support) -* libxcb, libxcb-randr (Optional, for RandR support) -* libX11, libXxf86vm (Optional, for VidMode support) +* 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 From 4868f6119d9abd26a36c955200eb35e7f05d8b28 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 14:10:19 +0200 Subject: [PATCH 079/100] Move check for version flag to the top of option parsing so redshift can exit early. --- src/options.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/options.c b/src/options.c index a71ae2af..1a8fc86a 100644 --- a/src/options.c +++ b/src/options.c @@ -180,6 +180,15 @@ options_load_from_elektra( * 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 + + // Version + if (elektraGetVersion(elektra)) { + printf("%s\n", PACKAGE_STRING); + return -1; + } + + // Verbose + options->verbose = elektraGetVerbose(elektra); // Programm mode ElektraEnumMode mode = elektraGetMode(elektra); @@ -312,15 +321,6 @@ options_load_from_elektra( options->scheme.day.temperature = elektraGetTempDay(elektra); options->scheme.night.temperature = elektraGetTempNight(elektra); - // Verbose - options->verbose = elektraGetVerbose(elektra); - - // Version - if (elektraGetVersion(elektra)) { - printf("%s\n", PACKAGE_STRING); - return -1; - } - // END Block // BEGIN Block: From parse_config_file_option (if not already handled above) From 49e197edb2cd8d27fa1507b1e111308fbb872223 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sat, 18 Sep 2021 14:20:26 +0200 Subject: [PATCH 080/100] Implement printing help messagewhen short CLI option "-h" is used. Previously, only "--help" worked. --- src/elektra/redshift.ni | 9 +++++++++ src/options.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index 45618a80..6d3f3a30 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -46,6 +46,15 @@ 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. diff --git a/src/options.c b/src/options.c index 1a8fc86a..cdccf93d 100644 --- a/src/options.c +++ b/src/options.c @@ -181,6 +181,12 @@ options_load_from_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); From 80314ebc83ac7d919648cdbf289de6510ed8287d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Mon, 20 Sep 2021 16:09:29 +0200 Subject: [PATCH 081/100] Change key hierarchy and CLI option name of "fastfade" --- src/elektra/redshift.ni | 4 ++-- src/options.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/elektra/redshift.ni b/src/elektra/redshift.ni index 6d3f3a30..d9dc010c 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -85,13 +85,13 @@ check/range = 1000-25000 opt/long = temp-oneshotmanual opt/arg = required -[fastfade] +[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 = fastfade +opt/long = fade-fast opt/arg = none [brightness/day] diff --git a/src/options.c b/src/options.c index cdccf93d..b34ed6e3 100644 --- a/src/options.c +++ b/src/options.c @@ -321,7 +321,7 @@ options_load_from_elektra( options->preserve_gamma = elektraGetGammaPreserve(elektra); // Fade - options->use_fade = !elektraGetFastfade(elektra); + options->use_fade = !elektraGetFadeFast(elektra); // Temperature options->scheme.day.temperature = elektraGetTempDay(elektra); From 2555f15afc3e460c9e845c0207ebdef7c1464ad2 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 23 Sep 2021 15:22:49 +0200 Subject: [PATCH 082/100] Remove dependency to file redshift.conf.sample from Makefile.am and appveyor.yml. This is an addendum to 20f98909e7ca350429a5103ef334dfa48e120e4e --- Makefile.am | 3 +-- appveyor.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) 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/appveyor.yml b/appveyor.yml index 0ac39835..5abe4e9d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -46,7 +46,6 @@ after_build: 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 From f90b740f7ffb4e7ab976ffd56320d79c6529a21a Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Fri, 24 Sep 2021 21:32:36 +0200 Subject: [PATCH 083/100] Add copy of redshift.ni in dump format for windows builds --- src/elektra/redshift-win.dump | 773 ++++++++++++++++++++++++++++++++++ 1 file changed, 773 insertions(+) create mode 100644 src/elektra/redshift-win.dump diff --git a/src/elektra/redshift-win.dump b/src/elektra/redshift-win.dump new file mode 100644 index 00000000..aff58906 --- /dev/null +++ b/src/elektra/redshift-win.dump @@ -0,0 +1,773 @@ +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 11 3 +check/range +0-1 +$meta 10 5 +check/type +float +$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 11 3 +check/range +0-1 +$meta 10 5 +check/type +float +$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 16 67 +check/validation +^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ +$meta 24 237 +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). +$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 16 67 +check/validation +^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ +$meta 24 237 +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). +$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 11 10 +check/range +-90.0-90.0 +$meta 10 5 +check/type +float +$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 11 12 +check/range +-180.0-180.0 +$meta 10 5 +check/type +float +$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 10 7 +check/date +ISO8601 +$meta 17 9 +check/date/format +timeofday +$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 10 7 +check/date +ISO8601 +$meta 17 9 +check/date/format +timeofday +$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 10 7 +check/date +ISO8601 +$meta 17 9 +check/date/format +timeofday +$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 10 7 +check/date +ISO8601 +$meta 17 9 +check/date/format +timeofday +$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 11 10 +check/range +1000-25000 +$meta 10 14 +check/type +unsigned_short +$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 11 10 +check/range +1000-25000 +$meta 10 14 +check/type +unsigned_short +$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 11 10 +check/range +1000-25000 +$meta 10 14 +check/type +unsigned_short +$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 From b22f5773491eb134a7bc3bf493a0d2832e2efd67 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 20:53:19 +0200 Subject: [PATCH 084/100] Download and install Elektra during appveyor build --- appveyor.yml | 4 ++++ src/Makefile.am | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 5abe4e9d..0a59b5a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,6 +20,10 @@ build_script: $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) +- ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER elektra-download) +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && wget https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip && unzip elektra.zip" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" - 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\"" diff --git a/src/Makefile.am b/src/Makefile.am index 5e765474..360e134d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,11 +36,14 @@ CLEANFILES = elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-co nodist_redshift_SOURCES = elektra/redshift-conf.h elektra/redshift-conf.c redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-conf.c +if ENABLE_WINDOWS_RESOURCE +else KDB ?= kdb # Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. # see https://stackoverflow.com/a/10609434 %-conf.c %-conf.h %-conf.mount.sh: %.ni $(KDB) gen -F ni=$*.ni highlevel "/sw/jonls/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; +endif scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh @@ -118,6 +121,7 @@ endif # Windows resources if ENABLE_WINDOWS_RESOURCE redshift_SOURCES += windows/appicon.rc windows/versioninfo.rc + endif .rc.o: From 73fd5ee914d7d62261fdb9a29265eee96e2f8f6d Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:01:41 +0200 Subject: [PATCH 085/100] Replace wget by curl in appveyor.yml script --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0a59b5a5..9e2c8ad3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,7 @@ build_script: - ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER root) - ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER elektra-download) -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && wget https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip && unzip elektra.zip" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && curl -fsS -o elektra.zip https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip && unzip elektra.zip" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap" From 121bc396614040a29ef83729a651e10605aeb262 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:06:16 +0200 Subject: [PATCH 086/100] Replace cur by Start-FileDownload in appveyor.yml script --- appveyor.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9e2c8ad3..9d7cdbbf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,8 +20,13 @@ build_script: $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) -- ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER elektra-download) -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && curl -fsS -o elektra.zip https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip && unzip elektra.zip" +- ps: | + md (Join-Path $env:APPVEYOR_BUILD_FOLDER elektra-download) + cd $env:APPVEYOR_BUILD_FOLDER + cd elektra-download + Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' + +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && unzip elektra.zip" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap" From 6b29a59dec3c16770ad6bb77751118c8e15b29a4 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:07:42 +0200 Subject: [PATCH 087/100] Fix typo in appveyor.yml --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9d7cdbbf..0d06f306 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,9 +26,9 @@ build_script: cd elektra-download Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && unzip elektra.zip" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && unzip elektra.zip" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/include /usr/include" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/lib /usr/lib" - 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\"" From 3e6b13562c74f09d4b1d3af3c9309933f46a2544 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:10:36 +0200 Subject: [PATCH 088/100] Replace unzip by 7z in appveyor.yml script --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0d06f306..3673e68a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,7 +26,7 @@ build_script: cd elektra-download Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && unzip elektra.zip" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && 7z x elektra.zip" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/include /usr/include" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/lib /usr/lib" - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap" From 268ef910cd9671597f71245c7f46a2fb1842358f Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:12:05 +0200 Subject: [PATCH 089/100] Fix wrong path in appveyor.yml --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3673e68a..d6ea104c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,8 +27,8 @@ build_script: Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && 7z x elektra.zip" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/include /usr/include" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && cp -r usr/local/lib /usr/lib" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" - 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\"" From 500feb664b1aed13ce7e8478721de9f34c5e2504 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:15:04 +0200 Subject: [PATCH 090/100] Fix wrong path in appveyor.yml --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d6ea104c..1ae7a9d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,8 +27,8 @@ build_script: Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' - C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && 7z x elektra.zip" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include /usr/include" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib /usr/lib" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include/* /usr/include" +- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib/* /usr/lib" - 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\"" From d97c3f5b0cac9c3c590b396fef7ddba653ab497c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 29 Sep 2021 17:12:21 +0200 Subject: [PATCH 091/100] Replace Redshift's program_mode_t enum by enum generated by Elektra --- src/options.c | 26 +++----------------------- src/options.h | 3 ++- src/redshift.c | 26 +++++++++++++------------- src/redshift.h | 9 --------- 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/options.c b/src/options.c index b34ed6e3..f56a66ed 100644 --- a/src/options.c +++ b/src/options.c @@ -197,29 +197,9 @@ options_load_from_elektra( options->verbose = elektraGetVerbose(elektra); // Programm mode - ElektraEnumMode mode = elektraGetMode(elektra); - switch (mode) { - case ELEKTRA_ENUM_MODE_CONTINUAL: { - options->mode = PROGRAM_MODE_CONTINUAL; - break; - } - case ELEKTRA_ENUM_MODE_ONESHOT: { - options->mode = PROGRAM_MODE_ONE_SHOT; - break; - } - case ELEKTRA_ENUM_MODE_PRINT: { - options->mode = PROGRAM_MODE_PRINT; - break; - } - case ELEKTRA_ENUM_MODE_RESET: { - options->mode = PROGRAM_MODE_RESET; - break; - } - case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: { + options->mode = elektraGetMode(elektra); + if(options->mode == ELEKTRA_ENUM_MODE_ONESHOTMANUAL) { options->temp_set = elektraGetTempOneshotmanual(elektra); - options->mode = PROGRAM_MODE_MANUAL; - break; - } } // Brightness @@ -399,6 +379,6 @@ options_init(options_t *options) options->use_fade = -1; options->preserve_gamma = 1; - options->mode = PROGRAM_MODE_CONTINUAL; + options->mode = ELEKTRA_ENUM_MODE_CONTINUAL; options->verbose = 0; } diff --git a/src/options.h b/src/options.h index 699237c6..34b43126 100644 --- a/src/options.h +++ b/src/options.h @@ -21,13 +21,14 @@ #define REDSHIFT_OPTIONS_H #include "redshift.h" +#include "elektra/redshift-conf.h" 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. */ diff --git a/src/redshift.c b/src/redshift.c index 0456eb89..c056f220 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -888,8 +888,8 @@ int main(int argc, const char * const *argv, const char * const *envp) /* 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) { @@ -945,8 +945,8 @@ int main(int argc, const char * const *argv, const char * const *envp) } } - 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, @@ -1022,7 +1022,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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( @@ -1060,8 +1060,8 @@ int main(int argc, const char * const *argv, const char * const *envp) } 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) { @@ -1120,7 +1120,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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); @@ -1128,7 +1128,7 @@ int main(int argc, const char * const *argv, const char * const *envp) 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); @@ -1150,7 +1150,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } } break; - case PROGRAM_MODE_MANUAL: + case ELEKTRA_ENUM_MODE_ONESHOTMANUAL: { if (options.verbose) { printf(_("Color temperature: %uK\n"), @@ -1177,7 +1177,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } } break; - case PROGRAM_MODE_RESET: + case ELEKTRA_ENUM_MODE_RESET: { /* Reset screen */ color_setting_t reset; @@ -1199,7 +1199,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } } break; - case PROGRAM_MODE_CONTINUAL: + case ELEKTRA_ENUM_MODE_CONTINUAL: { r = run_continual_mode( options.provider, location_state, scheme, @@ -1212,7 +1212,7 @@ int main(int argc, const char * const *argv, const char * const *envp) } /* 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 ee5239ee..d3ce54b0 100644 --- a/src/redshift.h +++ b/src/redshift.h @@ -49,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 { From 632fb69c0d7c60b9b18ec87430e54e3f582c8eff Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Wed, 29 Sep 2021 17:13:48 +0200 Subject: [PATCH 092/100] Remove Redshift's validation of temperature and brightness values because they are handled by Elektra --- src/redshift.c | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index c056f220..11fb1b53 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -110,15 +110,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 @@ -953,38 +953,6 @@ int main(int argc, const char * const *argv, const char * const *envp) 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) { From 90246d6fb6e4143979fd9e227f89c8cfd6c5bf16 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 22:12:55 +0200 Subject: [PATCH 093/100] Make files generated by elektra compatible with windows builds --- configure.ac | 1 + src/Makefile.am | 7 +- src/elektra/windows/redshift-conf.c | 754 ++++++++++ src/elektra/windows/redshift-conf.h | 1507 +++++++++++++++++++ src/elektra/windows/redshift-conf.mount.sh | 44 + src/elektra/{ => windows}/redshift-win.dump | 78 - src/options.c | 5 + src/redshift.c | 7 +- 8 files changed, 2322 insertions(+), 81 deletions(-) create mode 100644 src/elektra/windows/redshift-conf.c create mode 100644 src/elektra/windows/redshift-conf.h create mode 100644 src/elektra/windows/redshift-conf.mount.sh rename src/elektra/{ => windows}/redshift-win.dump (87%) diff --git a/configure.ac b/configure.ac index 4ae4fbc8..9fb821ed 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]) ], [ enable_windows_resource=no ]) diff --git a/src/Makefile.am b/src/Makefile.am index 360e134d..32e497b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,11 +33,14 @@ EXTRA_redshift_SOURCES = \ # Note: rules for Elektra are based on https://github.com/kodebach/lcdproc/blob/3e2b9d3f5cade3bbe21fdb5a9ea1c9ffc1c994fa/server/Makefile.am CLEANFILES = elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh -nodist_redshift_SOURCES = elektra/redshift-conf.h elektra/redshift-conf.c -redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-conf.c if ENABLE_WINDOWS_RESOURCE +redshift_SOURCES += elektra/windows/redshift-conf.h elektra/windows/redshift-conf.c else + +# Linux builds generate the files during make +redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-conf.c +nodist_redshift_SOURCES = elektra/redshift-conf.h elektra/redshift-conf.c KDB ?= kdb # Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. # see https://stackoverflow.com/a/10609434 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/redshift-win.dump b/src/elektra/windows/redshift-win.dump similarity index 87% rename from src/elektra/redshift-win.dump rename to src/elektra/windows/redshift-win.dump index aff58906..6c4ddac6 100644 --- a/src/elektra/redshift-win.dump +++ b/src/elektra/windows/redshift-win.dump @@ -143,12 +143,6 @@ unsigned_short $key string 14 0 brightness/day -$meta 11 3 -check/range -0-1 -$meta 10 5 -check/type -float $meta 7 3 default 1.0 @@ -170,12 +164,6 @@ float $key string 16 0 brightness/night -$meta 11 3 -check/range -0-1 -$meta 10 5 -check/type -float $meta 7 3 default 1.0 @@ -221,12 +209,6 @@ boolean $key string 9 0 gamma/day -$meta 16 67 -check/validation -^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ -$meta 24 237 -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). $meta 7 11 default 1.0:1.0:1.0 @@ -248,12 +230,6 @@ string $key string 11 0 gamma/night -$meta 16 67 -check/validation -^([0-9]*[\.,]?[0-9]+)(:([0-9]*[\.,]?[0-9]+):([0-9]*[\.,]?[0-9]+))?$ -$meta 24 237 -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). $meta 7 11 default 1.0:1.0:1.0 @@ -488,12 +464,6 @@ boolean $key string 28 0 provider/location/manual/lat -$meta 11 10 -check/range --90.0-90.0 -$meta 10 5 -check/type -float $meta 7 9 default 52.520008 @@ -515,12 +485,6 @@ float $key string 28 0 provider/location/manual/lon -$meta 11 12 -check/range --180.0-180.0 -$meta 10 5 -check/type -float $meta 7 9 default 13.404954 @@ -542,12 +506,6 @@ float $key string 22 0 provider/time/dawn/end -$meta 10 7 -check/date -ISO8601 -$meta 17 9 -check/date/format -timeofday $meta 7 5 default 06:30 @@ -569,12 +527,6 @@ string $key string 24 0 provider/time/dawn/start -$meta 10 7 -check/date -ISO8601 -$meta 17 9 -check/date/format -timeofday $meta 7 5 default 05:00 @@ -596,12 +548,6 @@ string $key string 22 0 provider/time/dusk/end -$meta 10 7 -check/date -ISO8601 -$meta 17 9 -check/date/format -timeofday $meta 7 5 default 20:30 @@ -623,12 +569,6 @@ string $key string 24 0 provider/time/dusk/start -$meta 10 7 -check/date -ISO8601 -$meta 17 9 -check/date/format -timeofday $meta 7 5 default 19:00 @@ -650,12 +590,6 @@ string $key string 8 0 temp/day -$meta 11 10 -check/range -1000-25000 -$meta 10 14 -check/type -unsigned_short $meta 7 4 default 6500 @@ -677,12 +611,6 @@ unsigned_short $key string 10 0 temp/night -$meta 11 10 -check/range -1000-25000 -$meta 10 14 -check/type -unsigned_short $meta 7 4 default 4500 @@ -704,12 +632,6 @@ unsigned_short $key string 18 0 temp/oneshotmanual -$meta 11 10 -check/range -1000-25000 -$meta 10 14 -check/type -unsigned_short $meta 7 4 default 6500 diff --git a/src/options.c b/src/options.c index b34ed6e3..2c1a2d33 100644 --- a/src/options.c +++ b/src/options.c @@ -37,7 +37,12 @@ #include "redshift.h" #include "options.h" #include "solar.h" + +#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. */ diff --git a/src/redshift.c b/src/redshift.c index 0456eb89..917a5df8 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 "elektra/redshift-conf.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__ From ad742591f5986078c5aeb15bcc9c8d4b20b1e4e0 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 23:02:03 +0200 Subject: [PATCH 094/100] Remove reference to already deleted file src/config.ini.c from POTFILES.in --- po/POTFILES.in | 1 - 1 file changed, 1 deletion(-) 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 From 56f62945a7291e4019a41369ceffe43e922f34ae Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 22:31:47 +0200 Subject: [PATCH 095/100] Fix AC_DEFINE --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9fb821ed..d06e8d4c 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +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]) + AC_DEFINE([WINDOWS_BUILD], [1], [Add a DEFINE that this is a Windows build]) ], [ enable_windows_resource=no ]) From 6f652de1e06634913e7531bcc4d34993a172c9cd Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 22:54:55 +0200 Subject: [PATCH 096/100] Fix makefile for windows builds, add elektra resources to zip artefact --- appveyor.yml | 2 ++ src/Makefile.am | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1ae7a9d3..813d18b0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,6 +52,8 @@ 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\src\elektra\windows\redshift-win.dump -Destination $ZIP_NAME + Copy-Item -Path $env:APPVEYOR_BUILD_FOLDER\elektra-download\elektra\usr\local\bin\kdb-static.exe -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 diff --git a/src/Makefile.am b/src/Makefile.am index 32e497b5..017a11a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,10 +46,10 @@ KDB ?= kdb # see https://stackoverflow.com/a/10609434 %-conf.c %-conf.h %-conf.mount.sh: %.ni $(KDB) gen -F ni=$*.ni highlevel "/sw/jonls/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; -endif - scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh +endif + AM_CFLAGS = redshift_LDADD = @LIBINTL@ From 164db0c50e5c8824cda14b74134487c4f33b4d6c Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Sun, 26 Sep 2021 21:26:19 +0200 Subject: [PATCH 097/100] Rewrite appveyor.yml to support Redshift with Elektra --- appveyor.yml | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 813d18b0..027e1f94 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,38 +13,57 @@ build_script: - ps: | If ($env:arch -Match "x86_64") { $env:MSYSTEM = "MINGW64" + $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/PR-4070/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64-x86_64/elektra.zip" + $env:PATH_FOR_ELEKTRA_FILES = "C:\msys64\mingw64" } Else { $env:MSYSTEM = "MINGW32" + $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/PR-4070/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 - cd elektra-download - Start-FileDownload 'https://build.libelektra.org/job/libelektra/job/master/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64/elektra.zip' - -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download && 7z x elektra.zip" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/include/* /usr/include" -- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && cd elektra-download/elektra && cp -r usr/local/lib/* /usr/lib" + 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" @@ -52,8 +71,9 @@ 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 $env:APPVEYOR_BUILD_FOLDER\elektra-download\elektra\usr\local\bin\kdb-static.exe -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 From 11367819c83342ab5ca3bea3eff5df2b8cf0a909 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 30 Sep 2021 21:32:13 +0200 Subject: [PATCH 098/100] Replace ELEKTRA_DOWNLOAD_URL with "master" --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 027e1f94..88adc058 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,11 +13,13 @@ build_script: - ps: | If ($env:arch -Match "x86_64") { $env:MSYSTEM = "MINGW64" - $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/PR-4070/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64-x86_64/elektra.zip" + # 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" - $env:ELEKTRA_DOWNLOAD_URL = "https://build.libelektra.org/job/libelektra/job/PR-4070/lastSuccessfulBuild/artifact/artifacts/debian-bullseye-mingw-w64-i686/elektra.zip" + # 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" } From 750344b5494752bf218080ac644784d661d49d10 Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Thu, 30 Sep 2021 22:04:18 +0200 Subject: [PATCH 099/100] Add macro branching in options.h --- src/options.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/options.h b/src/options.h index 34b43126..765e47e5 100644 --- a/src/options.h +++ b/src/options.h @@ -21,7 +21,11 @@ #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 */ From dcd3ab81632158ed92c3c4cb0a600f72ed33f61b Mon Sep 17 00:00:00 2001 From: Tobias Schubert Date: Tue, 5 Oct 2021 18:46:30 +0200 Subject: [PATCH 100/100] Add files generated by Elektra to git, document how to regenerate them. --- .gitignore | 2 - CONTRIBUTING.md | 9 + src/Makefile.am | 13 +- src/elektra/redshift-conf.c | 756 ++++++++++++++ src/elektra/redshift-conf.h | 1507 ++++++++++++++++++++++++++++ src/elektra/redshift-conf.mount.sh | 44 + src/elektra/redshift.ni | 3 + 7 files changed, 2320 insertions(+), 14 deletions(-) create mode 100644 src/elektra/redshift-conf.c create mode 100644 src/elektra/redshift-conf.h create mode 100644 src/elektra/redshift-conf.mount.sh diff --git a/.gitignore b/.gitignore index 8b1d2f7e..fe4a0406 100644 --- a/.gitignore +++ b/.gitignore @@ -120,8 +120,6 @@ m4/lt~obsolete.m4 /src/redshift-gtk/Makefile /src/redshift-gtk/redshift-gtk /src/redshift-gtk/__pycache__/ -# generated by Elektra -/src/elektra/redshift-conf.* # gettext /po/POTFILES diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac2822c2..7d8bc356 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,6 +72,15 @@ 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 ------------ diff --git a/src/Makefile.am b/src/Makefile.am index 017a11a2..fac65fcf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,21 +31,10 @@ EXTRA_redshift_SOURCES = \ windows/appicon.rc \ windows/versioninfo.rc -# Note: rules for Elektra are based on https://github.com/kodebach/lcdproc/blob/3e2b9d3f5cade3bbe21fdb5a9ea1c9ffc1c994fa/server/Makefile.am -CLEANFILES = elektra/redshift-conf.c elektra/redshift-conf.h elektra/redshift-conf.mount.sh - if ENABLE_WINDOWS_RESOURCE redshift_SOURCES += elektra/windows/redshift-conf.h elektra/windows/redshift-conf.c else - -# Linux builds generate the files during make -redshift.$(OBJEXT) options.$(OBJEXT): elektra/redshift-conf.h elektra/redshift-conf.c -nodist_redshift_SOURCES = elektra/redshift-conf.h elektra/redshift-conf.c -KDB ?= kdb -# Use pattern rule to ensure that kdb gen is only executed once, even if make -jN is used. -# see https://stackoverflow.com/a/10609434 -%-conf.c %-conf.h %-conf.mount.sh: %.ni - $(KDB) gen -F ni=$*.ni highlevel "/sw/jonls/redshift/#0/current" $*-conf initFn=loadConfiguration helpFn=printHelpMessage specloadFn=exitForSpecload embeddedSpec=full; +redshift_SOURCES += elektra/redshift-conf.h elektra/redshift-conf.c scriptsdir = $(prefix)/libexec scripts_DATA = elektra/redshift-conf.mount.sh endif 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 index d9dc010c..aeed5be5 100644 --- a/src/elektra/redshift.ni +++ b/src/elektra/redshift.ni @@ -1,4 +1,7 @@ ; 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,