summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-05-29 18:51:53 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-05-29 18:51:53 +0200
commita6c521fecd91867c6e184106f4e63445d1cb158a (patch)
tree15151d4f86de5567c366a35434daee62021525b1
parent83bfec016bd1a0c50f2d34822ecd1be4a2c8a4c6 (diff)
downloadpianobar-a6c521fecd91867c6e184106f4e63445d1cb158a.tar.gz
pianobar-a6c521fecd91867c6e184106f4e63445d1cb158a.tar.bz2
pianobar-a6c521fecd91867c6e184106f4e63445d1cb158a.zip
Re-enable terminal echoing on exit
-rw-r--r--src/main.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 8409583..8965bb9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,6 +33,8 @@ THE SOFTWARE.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+/* tcset/getattr () */
+#include <termios.h>
/* last.fm scrobbling library */
#include <wardrobe.h>
@@ -75,11 +77,15 @@ int main (int argc, char **argv) {
nfds_t pollsLen = 0;
char buf = '\0';
BarKeyShortcut_t *curShortcut = NULL;
+ /* terminal attributes _before_ we started messing around with ~ECHO */
+ struct termios termOrig;
BarUiMsg (MSG_NONE, "Welcome to " PACKAGE "!\n");
- /* init some things */
+ /* save terminal attributes, before disabling echoing */
+ tcgetattr (fileno (stdin), &termOrig);
BarTermSetEcho (0);
+ /* init some things */
xmlInitParser ();
ao_initialize ();
PianoInit (&ph);
@@ -124,7 +130,9 @@ int main (int argc, char **argv) {
/* setup control connection */
if (settings.controlProxy != NULL) {
char tmpPath[2];
- WaitressSplitUrl (settings.controlProxy, ph.waith.proxyHost, sizeof (ph.waith.proxyHost), ph.waith.proxyPort, sizeof (ph.waith.proxyPort), tmpPath, sizeof (tmpPath));
+ WaitressSplitUrl (settings.controlProxy, ph.waith.proxyHost,
+ sizeof (ph.waith.proxyHost), ph.waith.proxyPort,
+ sizeof (ph.waith.proxyPort), tmpPath, sizeof (tmpPath));
}
BarTermSetBuffer (0);
@@ -296,5 +304,8 @@ int main (int argc, char **argv) {
xmlCleanupParser ();
BarSettingsDestroy (&settings);
+ /* restore terminal attributes, zsh doesn't need this, bash does... */
+ tcsetattr (fileno (stdin), TCSANOW, &termOrig);
+
return 0;
}