33 Commits

Author SHA1 Message Date
Benedikt Heine
fe7d82380e Use GLib to spawn browser and dmenu 2018-10-08 18:27:11 +02:00
Benedikt Heine
357c4309e6 Pass URLs to browser as a single argument
Parsing the arguments with g_shell_parse_argv is more safe than just
splitting it by spaces. Also this allows to pass values with spaces to
the browser command.
2018-10-08 18:27:11 +02:00
Benedikt Heine
851953f5ef Start dmenu in a separate thread 2018-10-08 18:27:11 +02:00
Benedikt Heine
c80e3e9a42 Harness dispatch_menu_result against stupid input 2018-10-06 13:44:01 +02:00
Benedikt Heine
38c788c367 Split plain dmenu call into separate function 2018-10-06 13:44:01 +02:00
Benedikt Heine
958aa2bc96 Lock notifications while executing dmenu
When executing dmenu, the current notifications get "locked", by setting
their timeout temporarily to 0 and referencing them. So the notification
won't get closed (exept forcefully) and won't get freed while dmenu is
opened.

This is currently pointless, but as the dmenu call will become threaded,
it's necessary later.
2018-10-06 13:44:01 +02:00
Benedikt Heine
bbbddad3a7 Use structs for notifications 2018-09-16 02:58:31 +02:00
Benedikt Heine
f4fb95c827 Do not make explicit NULL checks on elements
Most of the NULL checks are actually doubly false logic. Turning the
logic around and removing the NULL check makes the program easier to
read.
2018-07-10 13:23:12 +02:00
Benedikt Heine
0a057450fe Fix typos 2018-06-11 14:10:07 +02:00
Benedikt Heine
c3e8bedfab
Merge pull request #474 from bebehei/logging
Logging with GLib
2018-02-12 13:13:37 +01:00
Benedikt Heine
38dced7591 Translate last unusual logging calls 2018-02-02 17:29:04 +01:00
Benedikt Heine
58dc09b415 Replace PERR macro with appropriate logging macro 2018-02-02 17:29:04 +01:00
Benedikt Heine
19b364d67c Translate fprintf statements into log messages 2018-02-02 17:29:04 +01:00
Benedikt Heine
7bfb0b9b5f Handle execvp error when opening dmenu
The execvp function usually doesn't return and exits by itself. But,
when having an error, it returns. A faulty dmenu setting could trigger
this and stop dunst receiving signals.
2018-01-14 00:50:10 +01:00
Benedikt Heine
87c0fd4d90 Don't overwrite settings in children
string_append frees the first argument. While it's a setting,
settings.browser will contain a false dangling pointer.
2018-01-13 23:52:40 +01:00
Benedikt Heine
b209d06963 Handle execvp error in open_browser
The execvp function usually doesn't return and exits by itself. But,
when having an error, it returns. As a faulty browser setting could
trigger this, dunst has to handle this, as the forked child wants to
access the X11 server too, resulting in XIO errors.

Fixes #476
2018-01-13 15:18:02 +01:00
Benedikt Heine
35dbd00611
Merge pull request #428 from bebehei/refactor-notification_init
Refactor notification init
2017-12-18 00:55:59 +01:00
Benedikt Heine
98d905b8e4 Strip [linktext] before opening URL
[linktext] can contain arbitary data and also a possible URL, which
would get passed to the browser, making the actual URL invalid.
2017-12-15 00:16:31 +01:00
Nikos Tsipinakis
ff6f3e496c Prefix signal functions with signal_
Make dbus function that emit a signal easier to distinguish by prefixing
them with 'signal_'.
2017-12-09 17:03:56 +02:00
Benedikt Heine
5b2a6e57b7 curly braces style
Curly braces should start on a new line, after a method declaration, but
should continue on the same line after a control structure.
2017-11-25 02:15:30 +01:00
Benedikt Heine
caa63d6275 Sort includes alphabetically 2017-11-25 01:28:03 +01:00
Benedikt Heine
a536e3f60b Force management of queues to queues.c 2017-10-29 20:38:40 +01:00
Benedikt Heine
a7003e3616 Refactor: Move queue specific methods to queues.c 2017-10-29 20:38:40 +01:00
Benedikt Heine
be3636c679 Remove _GNU_SOURCE macro
After some research, the _GNU_SOURCE does not affect any function call
anymore. To avoid future failures on other systems not using glibc,
_GNU_SOURCE gets removed.
2017-10-08 02:32:37 +02:00
Benedikt Heine
759aa518d5 Refactor star scheme of pointers
To achieve a consistent scheme, all stars of the
pointers should be on the side of the variable and
not on the side of the type.

wrong: char* a
wrong: char * a
good:  char *a

This commit is generated by the following sed command
with manual fixes of all false positives.

find src \( -name '*.c' -or -name '*.h' \) -print0
| xargs -0 -n1 sed -i
's/\([a-zA-Z]\+[-_a-zA-Z0-9]*\)\s*\*\s\+
\([a-zA-Z]\+[-_a-zA-Z0-9]*\)/\1 *\2/g'
2017-09-06 23:14:25 +02:00
Reto Schnyder
c8e6f317ab Move url prefix removal to open_browser
This way, it also applies to middle clicks.
Incidentally, it seems this fixed a crash when opening <a href> urls.
2017-06-29 19:59:50 +02:00
Nikos Tsipinakis
c23af0e021 Don't leave zombie processes if dmenu call fails
If dmenu didn't return anything we returned out of the function without
calling `waitpid` to collect the childs exit code, leaving to the child
process to be left as a zombie indefinitely. This commit makes `waitpid`
be called before the return checks are done.
2017-02-23 20:24:45 +02:00
Nikos Tsipinakis
375fcad223 Don't unconditionally append to dmenu_input
When generating the list of urls to pass to dmenu, string_append with a
newline as a separator was called unconditionally. This caused a newline
character to be added for each notification even if it didn't contain
any urls, leading to empty items in dmenu.

Fixes #300
2017-02-21 22:43:22 +02:00
John Chen
17e2929ee7 Change malloc and related functions to glib ones.
* malloc  -> g_malloc
* realloc -> g_realloc
* free    -> g_free
* strdup  -> g_strdup
* strndup -> g_strndup
2017-02-14 00:44:53 +08:00
John Chen
7037afb2bc Fix include. Add empty lines between include layers. 2017-02-14 00:39:04 +08:00
Nikos Tsipinakis
0c49b49254 Replace string_to_argv util function with g_shell_parse_argv
string_to_argv parsing was very simplistic and didn't properly handle
quotations. Since we are already using glib, g_shell_parse_argv serves
the same purpose with much better parsing and error handling.
2017-02-05 13:00:59 +02:00
Nikos Tsipinakis
0a0c02021d Update functions in dbus.c to use camel_case for consistency 2016-12-22 20:00:45 +02:00
Nikos Tsipinakis
2df2e7d06c Move dunst source files to src/ 2016-11-19 11:54:03 +02:00