Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

XDG compliance support #24

Merged
merged 1 commit into from

2 participants

pferor Greg Kroah-Hartman
pferor

Added XDG compliance support. It uses ~/.bti as well as ~/.config/bti as the config. file.
(Needs more testing)

In the file bti.c it checks if exists the ~/.config directory before establishing the default filename. In bti-shrink-urls script tests for both and uses the first found.`

Greg Kroah-Hartman gregkh merged commit a8b5255 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2013
  1. pferor
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 3 deletions.
  1. +1 −1  bti-shrink-urls
  2. +11 −2 bti.c
2  bti-shrink-urls
View
@@ -17,7 +17,7 @@
needs_escape=true
shrink_host=2tu.us
-test -f ~/.bti && . ~/.bti
+test -f ~/.bti && source ~/.bti || test -f ~/.config/bti && source ~/.config/bti
while test -n "$1" ; do
word="$1"
13 bti.c
View
@@ -275,8 +275,10 @@ static const char retweet_uri[] = "/retweet/";
static const char group_uri[] = "/../statusnet/groups/timeline/";
static const char config_default[] = "/etc/bti";
+static const char config_xdg_default[] = ".config/bti";
static const char config_user_default[] = ".bti";
+
static CURL *curl_init(void)
{
CURL *curl;
@@ -1203,6 +1205,7 @@ int main(int argc, char *argv[], char *envp[])
{ "retweet", 1, NULL, 'w' },
{ }
};
+ struct stat s;
struct session *session;
pid_t child;
char *tweet;
@@ -1236,13 +1239,19 @@ int main(int argc, char *argv[], char *envp[])
if (home) {
/* We have a home dir, so this might be a user */
session->homedir = strdup(home);
- config_file = config_user_default;
+
+ /* if '.config/' exists, use XDG standard, else don't */
+ if (-1 == stat("~/.config"), &s) {
+ config_file = config_xdg_default;
+ } else {
+ config_file = config_user_default;
+ }
} else {
session->homedir = strdup("");
config_file = config_default;
}
- /* set up a default config file location (traditionally ~/.bti) */
+ /* set up a default config file location (traditionally "~/.bti" or "~/.config/bti") */
session->configfile = zalloc(strlen(session->homedir) + strlen(config_file) + 7);
sprintf(session->configfile, "%s/%s", session->homedir, config_file);
Something went wrong with that request. Please try again.