--- cpufreq_orig.c	2006-01-13 12:09:58.000000000 +0100
+++ cpufreq.c	2006-01-13 12:08:57.000000000 +0100
@@ -52,8 +52,9 @@
 
 static int interface_proc;
 static int interface_sys;
 
+static double khz_min;
 static double khz_max;
 static double khz;
 
 static double temperature;
@@ -82,11 +83,34 @@
 static gint gov_enable = 1;
 static gint gov_enable_current;
 static gint slider_enable = 1;
 static gint slider_enable_current;
+static gint slider_offset_zero_disable = 0;
 static gint slider_userspace_enable = 1;
 static gint style_id;
 
+/**
+ * read double from given filename and return it
+ * Pre: the file may only contain a number
+ * Return: double from file or 0
+ */
+double cpufreq_read_from_file(char* filename_)
+{
+    FILE* fp_;
+    double khz_ = 0; // default is zero
+
+    fp_ = fopen(filename_, "r");
+    if (fp_) {
+        char input_[length];
+        if (fgets(input_, length, fp_)) {
+            khz_ = atof(input_);
+        }
+        fclose(fp_);
+    }
+
+    return khz_;
+}
+
 static void read_governor() {
 
   FILE* fp;
   int success = 0;
@@ -183,24 +207,11 @@
     }
   }
 
   /* max freq */
-
-  if (!interface_sys && interface_proc) {
-    double khz_max_proc = 0;
-    fp = fopen( "/proc/sys/cpu/0/speed-max", "r" );
-    if ( fp ) {
-      char input[length];
-      if ( fgets( input, length, fp ) ) {
-        khz_max_proc = atof(input);
-      }
-      fclose( fp );
-    }
-    khz_max = khz_max_proc > khz_max ? khz_max_proc : khz_max;
+  if (khz_max < khz) {
+      khz_max = khz;
   }
-
-  khz_max = khz > khz_max ? khz : khz_max;
-
 }
 
 static void read_temperature() {
   if (temp_enable) {
@@ -233,10 +244,9 @@
   read_khz();
   read_temperature();
 
   if (slider_enable_current && !slider_in_motion) {
-    int krellpos = slider_krell->w_scale*khz/khz_max;
-    gkrellm_update_krell(panel, slider_krell, krellpos);
+    gkrellm_update_krell(panel, slider_krell, khz-khz_min);
   }
   
   char theText[length];
   if (temp_enable) {
@@ -396,21 +406,38 @@
   y = text_decal->y + text_decal->h + 1;
 
   /* the slider */
   if (slider_enable) {
+    // read min/max if available
+    if (interface_sys) {
+        khz_max = cpufreq_read_from_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq");
+        khz_min = cpufreq_read_from_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq");
+    } else if (!interface_sys && interface_proc) {
+        double khz_max_proc = cpufreq_read_from_file("/proc/sys/cpu/0/speed-max");
+        khz_max = khz_max_proc > khz_max ? khz_max_proc : khz_max;
+        khz_min = cpufreq_read_from_file("/proc/sys/cpu/0/speed-min");
+    } else {
+        khz_max = 0; //will be dynamicly adjusted
+        khz_min = 0;
+    }
+    // use offset zero if enabled
+    if (!slider_offset_zero_disable) {
+        khz_min = 0;
+    }
+
     krell_image = gkrellm_krell_slider_piximage();
     gkrellm_set_style_slider_values_default(style,
 	y,     /* y offset */
 	0, 0); /* Left and right krell margins */
     slider_krell = gkrellm_create_krell(panel, krell_image, style);
     y = slider_krell->y0 + slider_krell->h_frame + 2;
 
     gkrellm_monotonic_krell_values(slider_krell, FALSE);
-    gkrellm_set_krell_full_scale(slider_krell, slider_krell->w_scale, 1);
+    gkrellm_set_krell_full_scale(slider_krell, (khz_max-khz_min), 1);
     gkrellm_update_krell(panel, slider_krell, 0);
 
     read_khz();
-    update_slider_position(slider_krell, slider_krell->w_scale*khz/khz_max);
+    update_slider_position(slider_krell, khz-khz_min);
   }
   slider_enable_current = slider_enable;
 
   /* configure and create the panel  */
@@ -435,8 +462,9 @@
 
 static GtkWidget* temp_enable_button;
 static GtkWidget* gov_enable_button;
 static GtkWidget* slider_enable_button;
+static GtkWidget* slider_offset_zero_disable_button;
 static GtkWidget* slider_userspace_enable_button;
 static GtkWidget* temperature_file_entry;
 static GtkWidget* temperature_scale_entry;
 
@@ -452,8 +480,10 @@
           tempfile_offset);
   fprintf(f, "%s temperature_scale %g\n", PLUGIN_CONFIG_KEYWORD,
           temperature_scale);
   fprintf(f, "%s slider_enable %d\n", PLUGIN_CONFIG_KEYWORD, slider_enable);
+  fprintf(f, "%s slider_offset_zero_disable %d\n", PLUGIN_CONFIG_KEYWORD,
+          slider_offset_zero_disable);
 }
 
 static void load_plugin_config(gchar *arg) {
   gchar	config[64], item[256];
@@ -471,8 +501,10 @@
       sscanf(item, "%d", &temp_enable);
     } else if (strcmp(config, "slider_enable") == 0) {
       sscanf(item, "%d", &slider_enable);
       slider_enable_current = slider_enable;
+    } else if (strcmp(config, "slider_offset_zero_disable") == 0) {
+      sscanf(item, "%d", &slider_offset_zero_disable);
     } else if (strcmp(config, "slider_userspace_enable") == 0) {
       sscanf(item, "%d", &slider_userspace_enable);
     } else if (strcmp(config, "gov_enable") == 0) {
       sscanf(item, "%d", &gov_enable);
@@ -491,8 +523,10 @@
 static void apply_plugin_config(void) {
   temp_enable = GTK_TOGGLE_BUTTON(temp_enable_button)->active;
   gov_enable = GTK_TOGGLE_BUTTON(gov_enable_button)->active;
   slider_enable = GTK_TOGGLE_BUTTON(slider_enable_button)->active;
+  slider_offset_zero_disable =
+    GTK_TOGGLE_BUTTON(slider_offset_zero_disable_button)->active;
   slider_userspace_enable =
     GTK_TOGGLE_BUTTON(slider_userspace_enable_button)->active;
   strcpy(temperature_file,
          gkrellm_gtk_entry_get_text(&temperature_file_entry));
@@ -550,8 +584,11 @@
   /* -- Slider options -- */
   vbox1 = gkrellm_gtk_framed_vbox(vbox, "Slider", 4, FALSE, 0, 2);
   gkrellm_gtk_check_button(vbox1, &slider_enable_button, slider_enable, FALSE,
                            0, "Show slider (see Info tab)");
+  gkrellm_gtk_check_button(vbox1, &slider_offset_zero_disable_button,
+                           slider_offset_zero_disable, FALSE, 0,
+                           "Minimal slider value is minimal frequency instead of 0");
 
   /* -- Temperature options -- */
   vbox1 = gkrellm_gtk_framed_vbox(vbox, "CPU temperature", 4, FALSE, 0, 2);
   gkrellm_gtk_check_button(vbox1, &temp_enable_button, temp_enable, FALSE, 0,
