Kaynağa Gözat

Make xlunch read config files by default

tags/v3.2.13
Peter Munch-Ellingsen 2 yıl önce
ebeveyn
işleme
90f93ff930
3 değiştirilmiş dosya ile 43 ekleme ve 13 silme
  1. +1
    -1
      Makefile
  2. +10
    -10
      default.conf
  3. +32
    -2
      xlunch.c

+ 1
- 1
Makefile Dosyayı Görüntüle

@@ -17,7 +17,7 @@ install: xlunch
cp extra/genentries $(DESTDIR)/usr/bin
cp extra/updateentries $(DESTDIR)/usr/bin
cp extra/genentries.desktop $(DESTDIR)/usr/share/applications/
cp extra/default.conf $(DESTDIR)/etc/xlunch/default.conf
cp default.conf $(DESTDIR)/etc/xlunch/default.conf
bash extra/genentries --path $(DESTDIR)/usr/share/xlunch/svgicons/ > $(DESTDIR)/etc/xlunch/entries.dsv
cp -r svgicons/ $(DESTDIR)/usr/share/xlunch/ 2>/dev/null || :



+ 10
- 10
default.conf Dosyayı Görüntüle

@@ -1,13 +1,13 @@
## This file is never implicitly used, it just serves as a reference to the
## available configuration options. Copy this file to e.g.
## ~/.config/xlunch/xlunch.conf and make your own changes. Options that are
## commented out are either switches that are turned on by the presence of an
## option, or options that takes a value but defaults to empty or has special
## meaning when no option is given. Simply uncomment the options you want and
## set them to the required value. Note that strings are not delimited by
## quotes, all values are read until the end of the line but whitespace is
## trunkcated from the front. To see what the options do, refer to
## `xlunch --help` or see http://xlunch.org
## This file is read if you don't specify a config file with `--config` and
## there is no file in ~/.config/xlunch/xlunch.conf. You shuldn't edit this
## file directly but copy this file to e.g. ~/.config/xlunch/xlunch.conf and
## make your own changes. Options that are commented out are either switches
## that are turned on by the presence of an option, or options that takes a
## value but defaults to empty or has special meaning when no option is given.
## Simply uncomment the options you want and set them to the required value.
## Note that strings are not delimited by quotes, all values are read until the
## end of the line but whitespace is trunkcated from the front. To see what the
## options do, refer to `xlunch --help` or see http://xlunch.org

# desktop
# noprompt


+ 32
- 2
xlunch.c Dosyayı Görüntüle

@@ -212,6 +212,7 @@ int prompt_y;
char * background_file = "";
char * highlight_file = "";
char * input_file = "";
char * config_file = "";
FILE * input_source = NULL;
char * prompt = "";
char * font_name = "";
@@ -730,7 +731,7 @@ FILE * determine_input_source(){
}
if (fp == NULL)
{
fprintf(stderr, "Error opening entries file from %s.\nReverting back to system conf.\n", input_file);
fprintf(stderr, "Error opening entries file from %s.\nReverting back to system entries list.\n", input_file);
input_file = "/etc/xlunch/entries.dsv";
fp = fopen(input_file, "rb");

@@ -750,6 +751,28 @@ FILE * determine_input_source(){
return fp;
}

FILE * determine_config_source(){
FILE * fp;
if(strlen(config_file) == 0) {
char * homeconf = NULL;

char * home = getenv("HOME");
if (home!=NULL)
{
homeconf = concat(home,"/.config/xlunch/xlunch.conf");
}
fp = fopen(homeconf, "rb");
if(fp == NULL) {
fp = fopen("/etc/xlunch/default.conf", "rb");
}
free(homeconf);
} else {
fp = fopen(config_file, "rb");
}
return fp;
}


int mouse_over_cell(node_t * cell, int index, int mouse_x, int mouse_y)
{
if (cell->hidden) return 0;
@@ -1777,7 +1800,7 @@ void handle_option(int c, char *optarg) {
break;

case 1014:
parse_config(fopen(optarg, "rb"));
config_file = optarg;
break;

case 1015:
@@ -1956,6 +1979,13 @@ void init(int argc, char **argv)
handle_option(c, optarg);
}

FILE *config_source = determine_config_source();
if(config_source != NULL){
parse_config(config_source);
fclose(config_source);
}


if (least_v_margin == -1) least_v_margin = least_margin;
if (icon_v_padding == -1) icon_v_padding = icon_padding;



Yükleniyor…
İptal
Kaydet