<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
   [
    <!ENTITY app "<application>Viking</application>">
    <!ENTITY appname          "Viking">
    <!ENTITY dhpackage        "viking">
   ]
>
<!-- Shared between man page and main Help -->
<section id="configuring" xreflabel="Configuring Viking">
    <title>Configuring Viking</title>
    <para><!-- Force an empty paragraph in an attempt to make man output easier to see --></para>

      <section id="config_file_loc" xreflabel="User Configuration File Location">
        <title>User Configuration File Location</title>
        <para><!-- Force an empty paragraph in an attempt to make man output easier to see --></para>
        <para>Viking looks for its configuration files (<filename>viking.prefs</filename>, <filename>viking.ini</filename>, <filename>viking.ini</filename> and <filename>keys.rc</filename>) in a specific directory, searching legacy locations first before trying new locations. Thus if you upgrade &appname; it will continue to use your existing setup.</para>
        <para>For <trademark>UNIX</trademark> like systems:</para>
        <variablelist>
          <varlistentry>
            <term>Up to v1.8</term>
            <listitem>
              <para><filename>~/.viking/</filename></para>
              <para>(typically <filename>/home/<replaceable>username</replaceable>/.viking</filename>)</para>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>From v1.9 onwards</term>
            <listitem>
              <para><ulink url="https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory compliant</ulink></para>
              <para>Typically <filename>~/config/viking/</filename></para>
            </listitem>
          </varlistentry>
        </variablelist>
        <para>For <trademark>Windows</trademark> systems:</para>
        <variablelist>
          <varlistentry>
            <term>v1.8 or earlier</term>
            <listitem>
              <para><filename>C:\Users\<replaceable>username</replaceable>\.viking</filename></para>
            </listitem>
          </varlistentry>
          <varlistentry>
            <term>v1.9 onwards</term>
            <listitem>
              <para><filename>C:\Users\<replaceable>username</replaceable>\AppData\Local\viking</filename></para>
            </listitem>
          </varlistentry>
        </variablelist>
        <para>For <trademark>Mac</trademark>:</para>
        <para><filename>/Library/Application Support/Viking</filename></para>

        <note>
          <para>
            If you've upgraded &app; to v1.9 and want it to use the new location, you will have to manually move the existing directory (when &app; is not running). e.g. in the command line: <command>mv ~/.viking ~/.config/viking</command>
          </para>
        </note>
        <note>
          <para>
            The User Configuration File Location directory can be overridden for the current session by explicitly setting the configuration directory via the <emphasis>--config-dir</emphasis> command line option. See <xref linkend="commandline"/> for more detail.
          </para>
        </note>
      </section>

      <section>
        <title>Primary Settings</title>
        <para>&app;'s primary configuration options are controllable via the GUI as previously covered in Preferences:<xref linkend="prefs"/>.</para>
        <para>These values are stored in the plain text file <filename>viking.prefs</filename></para>
      </section>

      <section id="misc_settings" xreflabel="Miscellaneous Settings">
        <title>Miscellaneous Settings</title>
        <para>Various individual values are automatically saved between &app; sessions in the <filename>viking.ini</filename> file placed in your <xref linkend="config_file_loc"/>.</para>
        <para>This file is not intended to be manually edited, but since it is a plain text file it can be changed if desired.</para>
        <para>Some values in this file are <emphasis>non-GUI</emphasis>, in the sense that there is no way to set it other than by manually entering in the keys and values (the key will not exist in the file otherwise). This allows some fine tuning of &app; behaviours, without resorting to recompiling the code. However is it not expected that these values should need to be changed for a normal user, hence no GUI options for these have been provided.</para>
        <para>Here is the list of the <emphasis>non-GUI</emphasis> keys and their default values.</para>
	<itemizedlist>
	  <listitem>
	    <para>curl_cainfo=NULL</para>
	    <para>See <ulink url="https://curl.haxx.se/libcurl/c/CURLOPT_CAINFO.html">CURLOPT_CAINFO</ulink></para>
	  </listitem>
	  <listitem>
	    <para>For <trademark>UNIX</trademark> like systems: curl_ssl_verifypeer=1</para>
	    <para>For <trademark>Windows</trademark> systems: curl_ssl_verifypeer=0</para>
	    <para>See <ulink url="https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html">CURLOPT_SSL_VERIFYPEER</ulink></para>
	    <note><para>If you encounter issues downloading from https sources, setting this to 0 should get HTTPS connections to work. For <trademark>UNIX</trademark> like operating systems SSL Certificate management is typically handled system wide and trusted certficate issuers updated regularly. Whereas for &appname; under Windows this is only done at installation/version update time and so may become out of date or encounter unknown sources and thus more likely to raise verification failures. Hence this is why is is turned off by default on <trademark>Windows</trademark> - especially to ensure the default Maps of OpenTopoMap work without manual user intervention.</para></note>
	  </listitem>
	  <listitem>
	    <para>curl_user_agent=NULL</para>
            <para>Override the default HTTP User-Agent (which is otherwise generated automatically from a combination of &appname;'s name, the version and curl information) set in all download requests with the value specified.</para>
	    <para>Also see <ulink url="https://curl.se/libcurl/c/CURLOPT_USERAGENT.html">CURLOPT_USERAGENT</ulink></para>
            <para>NB The User Agent for individual downloads/requests can be set via the relevant <emphasis>user-agent</emphasis> property when defining use of additional resources.</para>
	  </listitem>
	  <listitem>
	    <para>export_gpsmapper_option=false</para>
	    <para>To enable the export to the little used GPS Mapper format option, set this to true.</para>
	  </listitem>
	  <listitem>
	    <para>export_gpspoint_option=false</para>
	    <para>To enable the export to the little used GPS Point format option, set this to true.</para>
	  </listitem>
	  <listitem>
	    <para>geoclue_accuracy_level=4</para>
	    <para>Set the integer value for the accuracy level request to the GeoClue service. Values to match the <ulink url="https://www.freedesktop.org/software/geoclue/docs/libgeoclue/libgeoclue-gclue-enums.html#GClueAccuracyLevel">GClueAccuracyLevel</ulink>:</para>
	    <itemizedlist>
	      <listitem><para>0 = GCLUE_ACCURACY_LEVEL_NONE</para></listitem>
	      <listitem><para>1 = GCLUE_ACCURACY_LEVEL_COUNTRY</para></listitem>
	      <listitem><para>4 = GCLUE_ACCURACY_LEVEL_CITY</para></listitem>
	      <listitem><para>5 = GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD</para></listitem>
	      <listitem><para>6 = GCLUE_ACCURACY_LEVEL_STREET</para></listitem>
	      <listitem><para>8 = GCLUE_ACCURACY_LEVEL_EXACT</para></listitem>
	    </itemizedlist>
	  </listitem>
	  <listitem>
	    <para>gpx_tidy_points=true</para>
	    <para>ATM Only attempts to remove a suspicious first point of a GPX track
	                (as opposed to any points within a track).</para>
	  </listitem>
	  <listitem>
	    <para>gpx_tidy_points_max_speed=340</para>
	    <para>Over this speed (in metres per second) for the first pair of points - the first point is removed.</para>
	  </listitem>
	  <listitem>
	    <para>layers_create_trw_auto_default=false</para>
	    <para>Create new TrackWaypoint layers without showing the layer properties dialog first.</para>
	  </listitem>
	  <listitem>
	    <para>layers_panel_calendar_markup_mode=3</para>
	    <para>0=No markups. 1=Day marked. 2=Day marked and tooltips created. 3=Auto (timed tooltip creation, so if too slow it reverts to 1).</para>
            <para>
              If the following message is shown in the message log:<blockquote><para><emphasis>vik_layers_panel_calendar_update: detail level reduced as taking too long</emphasis></para></blockquote>then consider setting this value to 2 - although with the caveat that calendar refreshes may introduce noticable delays.
            </para>
	  </listitem>
	  <listitem>
	    <para>maps_cache_status_no_file_color=red</para>
	  </listitem>
	  <listitem>
	    <para>maps_cache_status_expired_color=yellow</para>
	  </listitem>
	  <listitem>
	    <para>maps_cache_status_download_error_color=darkred</para>
	  </listitem>
	  <listitem>
	    <para>maps_cache_status_okay_color=teal</para>
            <note>
              <para>maps_cache_status_*_color value strings are passed directly into the low level function <ulink url="https://docs.gtk.org/gdk3/type_func.Color.parse.html">gdk_color_parse()</ulink>.
              </para>
              <para>
                The string can either one of a large set of standard names (taken from the X11 rgb.txt file), or it can be a hexadecimal value in the form "#rgb" "#rrggbb", "#rrrgggbbb" or "#rrrrggggbbbb" where 'r', 'g' and 'b' are hex digits of the red, green, and blue components of the color, respectively.
              </para>
            </note>
	  </listitem>
	  <listitem>
	    <para>maps_max_tiles=1000</para>
	  </listitem>
	  <listitem>
	    <para>maps_min_shrinkfactor=0.0312499</para>
	  </listitem>
	  <listitem>
	    <para>maps_max_shrinkfactor=8.0000001</para>
	  </listitem>
	  <listitem>
	    <para>maps_real_min_shrinkfactor=0.0039062499</para>
	  </listitem>
	  <listitem>
	    <para>maps_scale_inc_down=4</para>
	  </listitem>
	  <listitem>
	    <para>maps_scale_inc_up=2</para>
	  </listitem>
	  <listitem>
	    <para>maps_scale_smaller_zoom_first=true</para>
	  </listitem>
	  <listitem>
	    <para>modifications_ignore_visibility_toggle=false</para>
            <para>Particularly if one often views large .vik files,
              then changing the visibility of items may be considered just part of the viewing process.
              Thus maybe you don't want to be notified on exit about such things -
              in this case you can set this value to true.
            </para>
	  </listitem>
	  <listitem>
	    <para>srtm_http_base_url=https://dds.cr.usgs.gov/srtm/version2_1/SRTM3</para>
	    <para>Allows using an alternative service for acquiring DEM SRTM files.
	    Note that the layout on the server needs to be split into Continent directories.</para>
	  </listitem>
	  <listitem>
	    <para>mapnik_buffer_size=128 (in pixels)</para>
	  </listitem>
	  <listitem>
	    <para>osm_basic_auth=false</para>
	    <para>Set to true to force the use of HTTP Basic Authentication even when OAuth is available</para>
	  </listitem>
	  <listitem>
	    <para>background_max_threads=10</para>
	  </listitem>
	  <listitem>
	    <para>background_max_threads_local=<emphasis>Number of CPUs</emphasis></para>
	  </listitem>
	  <listitem>
	    <para>window_default_tool=Select</para>
	    <para>Options are: Pan, Zoom, Ruler or Select</para>
	  </listitem>
	  <listitem>
	    <para>window_menubar=true</para>
	  </listitem>
	  <listitem>
	    <para>window_copy_centre_full_format=false</para>
	  </listitem>
	  <listitem>
	    <para>window_move_scroll_timeout=5 (milliseconds)</para>
	    <para>Time to wait between move scroll events before redrawing</para>
	  </listitem>
	  <listitem>
	    <para>window_zoom_scroll_timeout=150 (milliseconds)</para>
	    <para>Time to wait between zoom scroll events before redrawing</para>
	  </listitem>
	  <listitem>
	    <para>window_pinch_gesture_factor=1.5</para>
	    <para>Sensitivity factor for pinch zooming. Best to use keep this value somewhere between 0.5 and 3.0 - a higher value is more sensitive.</para>
	  </listitem>
	  <listitem>
	    <para>window_mount_device_id=NULL</para>
	    <para>If your desktop environment doesn't automatically mount USB storage devices or you wish to also manage it in &appname; -
            then set this to a device's drive label e.g <emphasis>GARMIN</emphasis> or <emphasis>UUID</emphasis> value.</para>
	    <para>&appname; will then put menu entries under <guimenu>Help</guimenu> so you can be manually perform operations as required.</para>
	    <para>This is provided as a very basic opt in feature, only allowing specification and management of just one device via some additional menu entries. Presently <emphasis>no</emphasis> intention to make this a more fully fledged feature; USB device management is left to other programs.</para>
	  </listitem>
	  <listitem>
	    <para>version_check_period_days=14</para>
	  </listitem>
	  <listitem>
	    <para>trackwaypoint_start_end_distance_diff=100.0</para>
	  </listitem>
	  <listitem>
	    <para>trackwaypoint_tab_default=0</para>
	    <para>Allows changing the default tab displayed when the layer property dialog is shown.</para>
	  </listitem>
	  <listitem>
	    <para>gps_statusbar_format=GSA</para>
	    <para>This string is in the Message Format Code</para>
	  </listitem>
	  <listitem>
	    <para>geoclue_statusbar_format=SA</para>
	    <para>This string is in the Message Format Code</para>
	  </listitem>
	  <listitem>
	    <para>trkpt_selected_statusbar_format=KEATDN</para>
	    <para>This string is in the Message Format Code</para>
	  </listitem>
	  <listitem>
	    <para>utils_nearest_tz_factor=1.0</para>
	  </listitem>
	  <listitem>
	    <para>viewport_history_size=20</para>
	  </listitem>
	  <listitem>
	    <para>viewport_history_diff_dist=500</para>
	    <para>In metres.</para>
	    <para>
	      Go Back or Go Forward requests over this range from the last history location will move back to that position.
	      If within this range it will skip over this location and move on to the next saved history location.
	    </para>
	  </listitem>
	  <listitem>
	    <para>viewport_scale=1</para>
	    <para>
	      If Viking doesn't automatically detect a high resolution display, you can force the setting here - typically by setting this to 2.
	    </para>
	  </listitem>
	  <listitem>
	    <para>viewport_popup_delay=200</para>
	    <para>In milliseconds</para>
	    <para>
	      Viking should show a popup with the name of the current track selected.
              If it is not shown (perhaps you have a slowish machine), try increasing this value.
	    </para>
	  </listitem>
	  <listitem>
	    <para>external_diary_program=<ulink url="https://rednotebook.sourceforge.io/">rednotebook</ulink></para>
	    <para>Or in Windows it uses <filename>C:/Progra~1/Rednotebook/rednotebook.exe</filename> - This string value must use Unix separators and not have spaces.</para>
	  </listitem>
	  <listitem>
	    <para>external_astro_program=<ulink url="https://stellarium.org/">stellarium</ulink></para>
	    <para>Or in Windows use <filename>C:/Progra~1/Stellarium/stellarium.exe</filename> - This string value must use Unix separators and not have spaces.
	          Needs to be version 0.15.0 or greater (otherwise due to this <ulink url="https://bugs.launchpad.net/stellarium/+bug/1410529">Bug</ulink> means this does not actually work).</para>
	  </listitem>
	  <listitem>
	    <para>external_text_program=<application>gedit</application></para>
	    <para>Or in Windows it uses <application>notepad</application> - This string value must use Unix separators and not have spaces.</para>
	  </listitem>
	  <listitem>
	    <para>bfilter_simplify=100</para>
	  </listitem>
	  <listitem>
	    <para>bfilter_compress=0.001</para>
	  </listitem>
	  <listitem>
	    <para>list_date_format=%Y-%m-%d %H:%M</para>
	    <para>A <ulink url="https://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html">date format description</ulink> as passed on to strftime().
	          Note that when displayed in tables sorting by this column simply uses the text value, rather than the underlying date/time value.
	    </para>
	  </listitem>
	  <listitem>
	    <para>export_device_path=OS Specific</para>
	    <para>UNIX = "/media/<emphasis role="italic">user</emphasis>/GARMIN/Garmin/GPX"</para>
	    <para>WINDOWS = ":/Garmin/GPX"</para>
	  </listitem>
	  <listitem>
	    <para>export_device_trackpoint_limit=10000 (Typical Garmin Edge limit)</para>
	    <para>Older Garmins limits are typically much lower - Etrex 20/30 is 500</para>
	  </listitem>
	  <listitem>
	    <para>export_device_routepoint_limit=250</para>
	  </listitem>
	  <listitem>
	    <para>kmz_default_maps_dir=<emphasis role="italic">Empty</emphasis></para>
	    <para>You may want to use something like: "/media/<emphasis role="italic">user</emphasis>/GARMIN/Garmin/CustomMaps"</para>
	  </listitem>
	  <listitem>
	    <para>geotag_photo_dir="/home/<emphasis role="italic">user</emphasis>/Pictures"</para>
	    <para>Override the base search location for photographs</para>
	    <para>A matching dated directory corresponding to the track is attempted of the format /geotag_photo_dir/YYYY/MM/DD</para>
	  </listitem>
	  <listitem>
	    <para>gpx_comment_time_format="%d-%B-%y %H:%M:%S"</para>
	    <para>The fallback format used in generating timestamps for waypoints from their comment</para>
	  </listitem>
	  <listitem>
	    <para>use_env_browser=false</para>
	    <para>By default &appname; uses the low level function gtk_show_uri_on_window() function to open URLs, which typically results in opening a new instance of a web browser.</para>
	    <para>This can be overridden by setting this configuration value to true and setting the environment variable <envar>BROWSER</envar> to invoke the desired browser, optionally including command line parameters to invoke the desired behaviour; such as "firefox --new-tab".</para>
	    <para>One could even have a more complicated string to run a specific version with a specific profile, e.g.
              <command>BROWSER="/home/rob/Downloads/firefox/firefox -P 'Nightly' --new-tab" viking</command>
            </para>
            <para>Note that if you set <envar>BROWSER</envar>, other programs may also use this value.</para>
	    <para>This is not applicable on Windows as currently &appname; uses the low level function ShellExecute() method to open URLs.</para>
	  </listitem>
	</itemizedlist>

	<section>
          <title>Message Format Code</title>
	  <para>Currently for ease of implementation the message format code is a string of characters.</para>
          <para>Each character represents what should be inserted in relation to a Trackpoint.</para>
	  <para>One day it might evolve into something more user friendly with a frontend to control it, perhaps allowing arbitrary text too. However for now at least some control is offered :)</para>
	  <para>
          <variablelist>
            <varlistentry>
              <term>Character Code</term>
              <listitem>
              <para>G = Some text to display at the start of the message - <emphasis>GPSD</emphasis></para>
              <para>K = Some text to display at the start of the message - <emphasis>Trkpt</emphasis></para>
              <para>A = Altitude of a Trackpoint</para>
              <para>S = Speed of a Trackpoint</para>
              <para>B = Vertical Speed (Climb)</para>
              <para>C = Course of a Trackpoint</para>
              <para>L = Location of a Trackpoint</para>
              <para>T = Time of a Trackpoint</para>
              <para>M = Time diff of a Trackpoint from the previous trackpoint</para>
              <para>X = Number of satellites used in the trackpoint fix</para>
              <para>D = Distance of the trackpoint from the start of a track (following along the track)</para>
              <para>F = Distance of the trackpoint from the finish (end) of a track (following along the track)</para>
              <para>P = Distance difference of the trackpoint from the previous trackpoint</para>
              <para>N = Name of track to which the trackpoint belongs</para>
              <para>E = Name of the trackpoint</para>
	      </listitem>
            </varlistentry>
            <varlistentry>
              <term>Output Notes</term>
              <listitem>
	      <para>If the output has <emphasis>*</emphasis> after it, then the value has been calculated via interpolation (such as speed when the Trackpoint does not contain a speed value).</para>
	      <para>If the output has <emphasis>**</emphasis> after it, then difficulties were encountered in trying to work out the value so probably a default of 0 will be shown.</para>
	      </listitem>
            </varlistentry>
          </variablelist>
	  </para>
	</section>

      </section>

    <section id="config_keys" xreflabel="Keyboard Shortcuts File">
      <title>Keyboard Shortcuts (Accelerator) Settings</title>
      <para>This is held in the file <filename>keys.rc</filename> in your <xref linkend="config_file_loc"/>.</para>
      <para>It is in the standard GTK Accelerator map format. Values are automatically read in and saved between &app; sessions.</para>
      <para>This file is not intended to be manually edited, but since it is a plain text file it can be changed if desired.</para>
    </section>

</section>
