32 #include <libaudtag/audtag.h>
35 #include "../libaudclient/audctrl.h"
51 #define AUTOSAVE_INTERVAL 300
72 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
74 const mode_t mode755 = S_IRWXU;
86 int len = strlen (path);
88 if (len > 3 && path[len - 1] ==
'\\')
90 if (len > 1 && path[len - 1] ==
'/')
97 char * slash = strrchr (path, G_DIR_SEPARATOR);
98 return (slash && slash[1]) ? slash + 1 :
NULL;
113 static void relocate_path (
char * * pathp,
const char * old,
const char *
new)
115 char * path = * pathp;
116 int oldlen = strlen (old);
117 int newlen = strlen (
new);
119 if (oldlen && old[oldlen - 1] == G_DIR_SEPARATOR)
121 if (newlen &&
new[newlen - 1] == G_DIR_SEPARATOR)
125 if (strncasecmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
127 if (strncmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
130 fprintf (stderr,
"Failed to relocate a data path. Falling back to "
131 "compile-time path: %s\n", path);
135 * pathp = g_strdup_printf (
"%.*s%s", newlen,
new, path + oldlen);
157 char * old = g_strdup (
aud_paths[AUD_PATH_BIN_DIR]);
204 const char * xdg_config_home = g_get_user_config_dir ();
205 const char * xdg_data_home = g_get_user_data_dir ();
210 g_setenv (
"HOME", g_get_home_dir (),
TRUE);
211 g_setenv (
"XDG_CONFIG_HOME", xdg_config_home,
TRUE);
212 g_setenv (
"XDG_DATA_HOME", xdg_data_home,
TRUE);
213 g_setenv (
"XDG_CACHE_HOME", g_get_user_cache_dir (),
TRUE);
232 {
"rew",
'r', 0, G_OPTION_ARG_NONE, &
options.rew,
N_(
"Skip backwards in playlist"),
NULL},
233 {
"play",
'p', 0, G_OPTION_ARG_NONE, &
options.play,
N_(
"Start playing current playlist"),
NULL},
234 {
"pause",
'u', 0, G_OPTION_ARG_NONE, &
options.pause,
N_(
"Pause current song"),
NULL},
235 {
"stop",
's', 0, G_OPTION_ARG_NONE, &
options.stop,
N_(
"Stop current song"),
NULL},
236 {
"play-pause",
't', 0, G_OPTION_ARG_NONE, &
options.play_pause,
N_(
"Pause if playing, play otherwise"),
NULL},
237 {
"fwd",
'f', 0, G_OPTION_ARG_NONE, &
options.fwd,
N_(
"Skip forward in playlist"),
NULL},
238 {
"show-jump-box",
'j', 0, G_OPTION_ARG_NONE, &
options.show_jump_box,
N_(
"Display Jump to File dialog"),
NULL},
239 {
"enqueue",
'e', 0, G_OPTION_ARG_NONE, &
options.enqueue,
N_(
"Add files to the playlist"),
NULL},
240 {
"enqueue-to-temp",
'E', 0, G_OPTION_ARG_NONE, &
options.enqueue_to_temp,
N_(
"Add new files to a temporary playlist"),
NULL},
241 {
"show-main-window",
'm', 0, G_OPTION_ARG_NONE, &
options.mainwin,
N_(
"Display the main window"),
NULL},
242 {
"headless",
'h', 0, G_OPTION_ARG_NONE, &
headless,
N_(
"Headless mode"),
NULL},
243 {
"quit-after-play",
'q', 0, G_OPTION_ARG_NONE, &
options.quit_after_play,
N_(
"Quit on playback stop"),
NULL},
244 {
"version",
'v', 0, G_OPTION_ARG_NONE, &
options.version,
N_(
"Show version"),
NULL},
245 {
"verbose",
'V', 0, G_OPTION_ARG_NONE, &
options.verbose,
N_(
"Print debugging messages"),
NULL},
246 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &
options.filenames,
N_(
"FILE..."),
NULL},
252 GOptionContext *context;
258 context = g_option_context_new(
_(
"- play multimedia files"));
259 g_option_context_add_main_entries(context,
cmd_entries, PACKAGE);
260 g_option_context_add_group(context, gtk_get_option_group(
FALSE));
262 if (!g_option_context_parse(context, argc, argv, &error))
265 _(
"%s: %s\nTry `%s --help' for more information.\n"), (* argv)[0],
266 error->message, (* argv)[0]);
270 g_option_context_free (context);
278 int handle = open (path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
283 fprintf (stderr,
"Cannot create %s: %s.\n", path, strerror (errno));
307 char * * f =
options.filenames;
308 char * cur = g_get_current_dir ();
310 for (
int i = 0; f[i]; i ++)
314 if (strstr (f[i],
"://"))
316 else if (g_path_is_absolute (f[i]))
324 char * tmp = g_build_filename (cur, f[i],
NULL);
359 list = g_list_prepend (list,
index_get (filenames, f));
397 fprintf (stderr,
"WARNING: Audacious seems to be already running but is not responding.\n");
443 setlocale (LC_ALL,
"");
445 bind_textdomain_codeset (PACKAGE,
"UTF-8");
446 bindtextdomain (PACKAGE
"-plugins",
aud_paths[AUD_PATH_LOCALE_DIR]);
447 bind_textdomain_codeset (PACKAGE
"-plugins",
"UTF-8");
448 textdomain (PACKAGE);
451 static void init_two (
int * p_argc,
char * * * p_argv)
455 #if ! GLIB_CHECK_VERSION (2, 32, 0)
456 g_thread_init (
NULL);
458 gtk_init (p_argc, p_argv);
461 AUDDBG (
"Loading configuration.\n");
464 AUDDBG (
"Initializing.\n");
477 AUDDBG (
"Loading lowlevel plugins.\n");
480 AUDDBG (
"Starting worker threads.\n");
484 AUDDBG (
"Restoring state.\n");
489 AUDDBG (
"Loading highlevel plugins.\n");
503 AUDDBG (
"Saving playlist state.\n");
506 AUDDBG (
"Unloading highlevel plugins.\n");
513 AUDDBG (
"Stopping playback.\n");
517 AUDDBG (
"Stopping worker threads.\n");
521 AUDDBG (
"Unloading lowlevel plugins.\n");
524 AUDDBG (
"Saving configuration.\n");
528 AUDDBG (
"Cleaning up.\n");
539 AUDDBG (
"Saving configuration.\n");
557 int main(
int argc,
char ** argv)
564 printf (
"%s %s (%s)\n",
_(
"Audacious"), VERSION, BUILDSTAMP);
571 AUDDBG (
"No remote session; starting up.\n");
574 AUDDBG (
"Startup complete.\n");