diff options
-rw-r--r-- | volume.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -9,11 +9,14 @@ using namespace std; int printusage(int,const char *const *argv,const char *message=NULL){ if(message)cout<<message<<endl; - cout<<"Usage: "<<argv[0]<<" [volume]"<<endl; - cout<<"If [volume] is given, changes volume to that value. (Integer in [0,100].)"<<endl; - cout<<"Otherwise, it shows a graphical slider, adjustable with the arrow keys or h/j/k/l."<<endl; - cout<<"In graphical mode, 'm' toggles whether sound is muted."<<endl; - cout<<"If the output is not a tty, the graphical slider is disabled."<<endl; + cout<<"Usage: "<<argv[0]<<" [volume]\n" + "If [volume] is given, changes volume to that value. (Integer in [0,100].)\n" + "Otherwise, it shows a graphical slider, adjustable with the arrow keys or h/j/k/l;\n" + "'m' toggles whether sound is muted; a number directly sets the volume.\n" + "Enter or 'q' exits graphical mode.\n" + "If the output is not a tty, the current volume is outputted, possibly suffixed\n" + "with an 'm' if muted." + <<endl; return 1; } @@ -172,7 +175,10 @@ int main(int argc,char **argv){ if(vol<0||vol>100)return printusage(argc,argv,"Volume argument not in range"); return setvolume(vol); } - if(!isatty(1))return printusage(argc,argv,"Won't display slider if stdout is not a terminal"); + if(!isatty(1)){ + cout<<getvolume()<<(getmuted()?"m":"")<<endl; + return 0; + } initscreen(); atexit(endscreen); bool m=getmuted(); |