37 #include <libaudtag/audtag.h>
42 #include "../libaudclient/audctrl.h"
47 #include "eggdesktopfile.h"
48 #include "eggsmclient.h"
63 #define AUTOSAVE_INTERVAL 300
83 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
85 const mode_t mode755 = S_IRWXU;
97 int len = strlen (path);
99 if (len > 3 && path[len - 1] ==
'\\')
101 if (len > 1 && path[len - 1] ==
'/')
108 char * slash = strrchr (path, G_DIR_SEPARATOR);
109 return (slash && slash[1]) ? slash + 1 :
NULL;
124 static void relocate_path (
char * * pathp,
const char * old,
const char *
new)
126 char * path = * pathp;
127 int oldlen = strlen (old);
128 int newlen = strlen (
new);
130 if (oldlen && old[oldlen - 1] == G_DIR_SEPARATOR)
132 if (newlen &&
new[newlen - 1] == G_DIR_SEPARATOR)
136 if (strncasecmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
138 if (strncmp (path, old, oldlen) || (path[oldlen] && path[oldlen] != G_DIR_SEPARATOR))
141 fprintf (stderr,
"Failed to relocate a data path. Falling back to "
142 "compile-time path: %s\n", path);
146 * pathp = g_strdup_printf (
"%.*s%s", newlen,
new, path + oldlen);
168 char * old = g_strdup (
aud_paths[AUD_PATH_BIN_DIR]);
215 const char * xdg_config_home = g_get_user_config_dir ();
216 const char * xdg_data_home = g_get_user_data_dir ();
221 g_setenv (
"HOME", g_get_home_dir (),
TRUE);
222 g_setenv (
"XDG_CONFIG_HOME", xdg_config_home,
TRUE);
223 g_setenv (
"XDG_DATA_HOME", xdg_data_home,
TRUE);
224 g_setenv (
"XDG_CACHE_HOME", g_get_user_cache_dir (),
TRUE);
243 {
"rew",
'r', 0, G_OPTION_ARG_NONE, &
options.rew,
N_(
"Skip backwards in playlist"),
NULL},
244 {
"play",
'p', 0, G_OPTION_ARG_NONE, &
options.play,
N_(
"Start playing current playlist"),
NULL},
245 {
"pause",
'u', 0, G_OPTION_ARG_NONE, &
options.pause,
N_(
"Pause current song"),
NULL},
246 {
"stop",
's', 0, G_OPTION_ARG_NONE, &
options.stop,
N_(
"Stop current song"),
NULL},
247 {
"play-pause",
't', 0, G_OPTION_ARG_NONE, &
options.play_pause,
N_(
"Pause if playing, play otherwise"),
NULL},
248 {
"fwd",
'f', 0, G_OPTION_ARG_NONE, &
options.fwd,
N_(
"Skip forward in playlist"),
NULL},
249 {
"show-jump-box",
'j', 0, G_OPTION_ARG_NONE, &
options.show_jump_box,
N_(
"Display Jump to File dialog"),
NULL},
250 {
"enqueue",
'e', 0, G_OPTION_ARG_NONE, &
options.enqueue,
N_(
"Add files to the playlist"),
NULL},
251 {
"enqueue-to-temp",
'E', 0, G_OPTION_ARG_NONE, &
options.enqueue_to_temp,
N_(
"Add new files to a temporary playlist"),
NULL},
252 {
"show-main-window",
'm', 0, G_OPTION_ARG_NONE, &
options.mainwin,
N_(
"Display the main window"),
NULL},
253 {
"version",
'v', 0, G_OPTION_ARG_NONE, &
options.version,
N_(
"Show version"),
NULL},
254 {
"verbose",
'V', 0, G_OPTION_ARG_NONE, &
options.verbose,
N_(
"Print debugging messages"),
NULL},
255 {
"headless",
'h', 0, G_OPTION_ARG_NONE, &
headless,
N_(
"Headless mode (beta)"),
NULL},
256 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &
options.filenames,
N_(
"FILE..."),
NULL},
262 GOptionContext *context;
268 context = g_option_context_new(
_(
"- play multimedia files"));
269 g_option_context_add_main_entries(context,
cmd_entries, PACKAGE);
270 g_option_context_add_group(context, gtk_get_option_group(
FALSE));
272 g_option_context_add_group(context, egg_sm_client_get_option_group());
275 if (!g_option_context_parse(context, argc, argv, &error))
278 _(
"%s: %s\nTry `%s --help' for more information.\n"), (* argv)[0],
279 error->message, (* argv)[0]);
283 g_option_context_free (context);
291 int handle = open (path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
296 fprintf (stderr,
"Cannot create %s: %s.\n", path, strerror (errno));
320 char * * f =
options.filenames;
321 char * cur = g_get_current_dir ();
323 for (
int i = 0; f[i]; i ++)
327 if (strstr (f[i],
"://"))
329 else if (g_path_is_absolute (f[i]))
337 char * tmp = g_build_filename (cur, f[i],
NULL);
372 list = g_list_prepend (list,
index_get (filenames, f));
410 fprintf (stderr,
"WARNING: Audacious seems to be already running but is not responding.\n");
457 bind_textdomain_codeset (PACKAGE,
"UTF-8");
458 bindtextdomain (PACKAGE
"-plugins",
aud_paths[AUD_PATH_LOCALE_DIR]);
459 bind_textdomain_codeset (PACKAGE
"-plugins",
"UTF-8");
460 textdomain (PACKAGE);
463 egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_NORMAL);
468 static void init_two (
int * p_argc,
char * * * p_argv)
472 g_thread_init (
NULL);
474 gtk_init (p_argc, p_argv);
492 AUDDBG (
"Loading lowlevel plugins.\n");
506 AUDDBG (
"Loading highlevel plugins.\n");
516 AUDDBG (
"Capturing state.\n");
520 AUDDBG (
"Unloading highlevel plugins.\n");
523 AUDDBG (
"Stopping playback.\n");
528 set_bool (
NULL,
"stop_after_current_song", stop_after_song);
540 AUDDBG (
"Unloading lowlevel plugins.\n");
543 AUDDBG (
"Saving configuration.\n");
554 AUDDBG (
"Saving configuration.\n");
561 int main(
int argc,
char ** argv)
568 printf (
"%s %s (%s)\n",
_(
"Audacious"), VERSION, BUILDSTAMP);
575 AUDDBG (
"No remote session; starting up.\n");
578 AUDDBG (
"Startup complete.\n");