[pacman-dev] [PATCH] Added the --bell switch.
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- doc/pacman.8.txt | 3 +++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 3 +++ src/pacman/util.c | 15 +++++++++------ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 514f559..6e0617a 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -148,6 +148,9 @@ Options *\--arch* <arch>:: Specify an alternate architecture. +*\--bell*:: + Sound the terminal bell when input is required. + *\--cachedir* <dir>:: Specify an alternative package cache location (a typical default is +{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 7a7e9cf..463ae48 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short bell; double deltaratio; char *arch; char *print_format; @@ -201,7 +202,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_BELL }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 94685a7..07282e7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --bell sound the terminal bell when input is required\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -480,6 +481,7 @@ static int parsearg_global(int opt) case OP_CONFIRM: config->noconfirm = 0; break; + case OP_BELL: config->bell = 1; break; case OP_DBPATH: case 'b': free(config->dbpath); @@ -981,6 +983,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"bell", no_argument, 0, OP_BELL}, {0, 0, 0, 0} }; diff --git a/src/pacman/util.c b/src/pacman/util.c index 5f331e8..9183047 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1396,13 +1396,14 @@ int multiselect_question(char *array, int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a selection (default=all)")); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, response_len, stdin)) { @@ -1463,13 +1464,14 @@ int select_question(int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a number (default=%d)"), preset); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, sizeof(response), stdin)) { @@ -1517,13 +1519,14 @@ static int question(short preset, const char *format, va_list args) } fputs(config->colstr.nocolor, stream); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); return preset; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fd_in); if(safe_fgets(response, sizeof(response), stdin)) { -- 2.6.2
On 11/19/15 at 07:09am, Eric Toombs wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. ---
If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper script accomplish the same goal? pacman -Sy && printf "\a" && pacman -Su This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches. apg
doc/pacman.8.txt | 3 +++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 3 +++ src/pacman/util.c | 15 +++++++++------ 4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 514f559..6e0617a 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -148,6 +148,9 @@ Options *\--arch* <arch>:: Specify an alternate architecture. +*\--bell*:: + Sound the terminal bell when input is required. + *\--cachedir* <dir>:: Specify an alternative package cache location (a typical default is +{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 7a7e9cf..463ae48 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short bell; double deltaratio; char *arch; char *print_format; @@ -201,7 +202,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_BELL }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 94685a7..07282e7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --bell sound the terminal bell when input is required\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -480,6 +481,7 @@ static int parsearg_global(int opt) case OP_CONFIRM: config->noconfirm = 0; break; + case OP_BELL: config->bell = 1; break; case OP_DBPATH: case 'b': free(config->dbpath); @@ -981,6 +983,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"bell", no_argument, 0, OP_BELL}, {0, 0, 0, 0} }; diff --git a/src/pacman/util.c b/src/pacman/util.c index 5f331e8..9183047 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1396,13 +1396,14 @@ int multiselect_question(char *array, int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a selection (default=all)")); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, response_len, stdin)) { @@ -1463,13 +1464,14 @@ int select_question(int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a number (default=%d)"), preset); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, sizeof(response), stdin)) { @@ -1517,13 +1519,14 @@ static int question(short preset, const char *format, va_list args) } fputs(config->colstr.nocolor, stream); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); return preset; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fd_in); if(safe_fgets(response, sizeof(response), stdin)) { -- 2.6.2
That's a pretty good improvement, but there is also a long delay while pacman calculates dependencies for large upgrades. You might say that could be avoided by upgrading more frequently, but it is my style and the style of many others to opt for large monthly upgrades over small weekly or daily upgrades. I'll try formatting the patch again with git send-email. On 2015-12-14 12:12, Andrew Gregory wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper
On 11/19/15 at 07:09am, Eric Toombs wrote: script accomplish the same goal?
pacman -Sy && printf "\a" && pacman -Su
This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches.
apg
doc/pacman.8.txt | 3 +++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 3 +++ src/pacman/util.c | 15 +++++++++------ 4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 514f559..6e0617a 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -148,6 +148,9 @@ Options *\--arch* <arch>:: Specify an alternate architecture. +*\--bell*:: + Sound the terminal bell when input is required. + *\--cachedir* <dir>:: Specify an alternative package cache location (a typical default is +{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 7a7e9cf..463ae48 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short bell; double deltaratio; char *arch; char *print_format; @@ -201,7 +202,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_BELL }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 94685a7..07282e7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --bell sound the terminal bell when input is required\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -480,6 +481,7 @@ static int parsearg_global(int opt) case OP_CONFIRM: config->noconfirm = 0; break; + case OP_BELL: config->bell = 1; break; case OP_DBPATH: case 'b': free(config->dbpath); @@ -981,6 +983,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"bell", no_argument, 0, OP_BELL}, {0, 0, 0, 0} }; diff --git a/src/pacman/util.c b/src/pacman/util.c index 5f331e8..9183047 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1396,13 +1396,14 @@ int multiselect_question(char *array, int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a selection (default=all)")); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, response_len, stdin)) { @@ -1463,13 +1464,14 @@ int select_question(int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a number (default=%d)"), preset); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, sizeof(response), stdin)) { @@ -1517,13 +1519,14 @@ static int question(short preset, const char *format, va_list args) } fputs(config->colstr.nocolor, stream); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); return preset; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fd_in); if(safe_fgets(response, sizeof(response), stdin)) { -- 2.6.2
Yep, that patch got garbled something fierce. Thunderbird is to blame. I tried git send-email, but it was too complicated, so I'm just sending the patch as an attachment. Nothing should get garbled this time. On 2016-01-11 00:32, Eric Toombs wrote:
That's a pretty good improvement, but there is also a long delay while pacman calculates dependencies for large upgrades. You might say that could be avoided by upgrading more frequently, but it is my style and the style of many others to opt for large monthly upgrades over small weekly or daily upgrades. I'll try formatting the patch again with git send-email.
On 2015-12-14 12:12, Andrew Gregory wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper
On 11/19/15 at 07:09am, Eric Toombs wrote: script accomplish the same goal?
pacman -Sy && printf "\a" && pacman -Su
This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches.
apg
On 01/11/16 at 12:32am, Eric Toombs wrote:
That's a pretty good improvement, but there is also a long delay while pacman calculates dependencies for large upgrades. You might say that could be avoided by upgrading more frequently, but it is my style and the style of many others to opt for large monthly upgrades over small weekly or daily upgrades. I'll try formatting the patch again with git send-email.
Dependency calculation should be very fast. I suspect that the delay you're seeing is actually just pacman reading information from the local database. If that's the case, just loading the local db before the bell should give you the desired effect: pacman -Sy && pacman -Sup >/dev/null && printf "\a" && pacman -Su pacman-optimize may also be able to improve the speed of reading your local database. apg
On 2015-12-14 12:12, Andrew Gregory wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper
On 11/19/15 at 07:09am, Eric Toombs wrote: script accomplish the same goal?
pacman -Sy && printf "\a" && pacman -Su
This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches.
apg
So perhaps the switch isn't strictly necessary, but it's much easier to use. Your method requires knowledge of how pacman is implemented and could change as pacman's implementation is changed. I'd definitely rather use the --bell switch I implemented. On 2016-01-14 22:30, Andrew Gregory wrote:
That's a pretty good improvement, but there is also a long delay while pacman calculates dependencies for large upgrades. You might say that could be avoided by upgrading more frequently, but it is my style and the style of many others to opt for large monthly upgrades over small weekly or daily upgrades. I'll try formatting the patch again with git send-email. Dependency calculation should be very fast. I suspect that the delay you're seeing is actually just pacman reading information from the local database. If that's the case, just loading the local db before
On 01/11/16 at 12:32am, Eric Toombs wrote: the bell should give you the desired effect:
pacman -Sy && pacman -Sup >/dev/null && printf "\a" && pacman -Su
pacman-optimize may also be able to improve the speed of reading your local database.
apg
On 2015-12-14 12:12, Andrew Gregory wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper
On 11/19/15 at 07:09am, Eric Toombs wrote: script accomplish the same goal?
pacman -Sy && printf "\a" && pacman -Su
This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches.
apg
On 01/17/16 at 05:00am, Eric Toombs wrote:
So perhaps the switch isn't strictly necessary, but it's much easier to use. Your method requires knowledge of how pacman is implemented and could change as pacman's implementation is changed. I'd definitely rather use the --bell switch I implemented.
Please bottom-post. I don't think this is an unreasonable feature request so I don't mind if Allan wants to accept it, but as far as I can tell you are the only one interested in it. Personally, I'm not inclined to add features when the desired effect can already be achieved using existing features and only one person seems want it. I'm not sure what implementation knowledge you think this requires. All the script does is split the download and upgrade steps and pre-read the localdb so that the actual upgrade won't be reading it cold. apg
On 2016-01-14 22:30, Andrew Gregory wrote:
That's a pretty good improvement, but there is also a long delay while pacman calculates dependencies for large upgrades. You might say that could be avoided by upgrading more frequently, but it is my style and the style of many others to opt for large monthly upgrades over small weekly or daily upgrades. I'll try formatting the patch again with git send-email. Dependency calculation should be very fast. I suspect that the delay you're seeing is actually just pacman reading information from the local database. If that's the case, just loading the local db before
On 01/11/16 at 12:32am, Eric Toombs wrote: the bell should give you the desired effect:
pacman -Sy && pacman -Sup >/dev/null && printf "\a" && pacman -Su
pacman-optimize may also be able to improve the speed of reading your local database.
apg
On 2015-12-14 12:12, Andrew Gregory wrote:
This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- If your only interest in this is to get a notification when downloads are done because you have a slow connection, wouldn't a small wrapper
On 11/19/15 at 07:09am, Eric Toombs wrote: script accomplish the same goal?
pacman -Sy && printf "\a" && pacman -Su
This patch also appears to have some mangled whitespace. Please use `git send-email` to submit patches.
apg
On 18/01/16 01:00, Andrew Gregory wrote:
On 01/17/16 at 05:00am, Eric Toombs wrote:
So perhaps the switch isn't strictly necessary, but it's much easier to use. Your method requires knowledge of how pacman is implemented and could change as pacman's implementation is changed. I'd definitely rather use the --bell switch I implemented.
Please bottom-post.
I don't think this is an unreasonable feature request so I don't mind if Allan wants to accept it, but as far as I can tell you are the only one interested in it. Personally, I'm not inclined to add features when the desired effect can already be achieved using existing features and only one person seems want it.
I do not have a strong opinion on the inclusion/exclusion of this feature. Given it is zero effort to maintain and adds no overhead, I am leaning towards accepting. But this will need to wait for pacman > 5.0 Allan
On 2016-01-17 22:19, Allan McRae wrote:
On 18/01/16 01:00, Andrew Gregory wrote:
On 01/17/16 at 05:00am, Eric Toombs wrote:
So perhaps the switch isn't strictly necessary, but it's much easier to use. Your method requires knowledge of how pacman is implemented and could change as pacman's implementation is changed. I'd definitely rather use the --bell switch I implemented. Please bottom-post.
I don't think this is an unreasonable feature request so I don't mind if Allan wants to accept it, but as far as I can tell you are the only one interested in it. Personally, I'm not inclined to add features when the desired effect can already be achieved using existing features and only one person seems want it. I do not have a strong opinion on the inclusion/exclusion of this feature.
Given it is zero effort to maintain and adds no overhead, I am leaning towards accepting. But this will need to wait for pacman > 5.0
Allan I only just got this now. Thanks, Allan! Looking forward to 5.0!
participants (3)
-
Allan McRae
-
Andrew Gregory
-
Eric Toombs