Skip to content

Commit

Permalink
Added getvolume command, analogous to setvolume command.
Browse files Browse the repository at this point in the history
Made setvolume command behave more similarly to getvolume command.
  • Loading branch information
alexreg committed Sep 29, 2013
1 parent ba7cbe3 commit 95c3ece
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WARN = -w

NAMES_CARBON = fileinfo getfcomment hfsdata lsmac mkalias setfcomment setfctypes setfflags setlabel setsuffix
NAMES_COCOA = geticon seticon wsupdate
NAMES_SCRIPT = cpath google osxutils rcmac setvolume trash wiki
NAMES_SCRIPT = cpath google osxutils rcmac getvolume setvolume trash wiki
NAMES = $(NAMES_CARBON) $(NAMES_COCOA)
PROGRAMS = $(foreach name,$(NAMES),$(name)/$(name))
SCRIPTS = $(foreach name,$(NAMES_SCRIPT),$(name)/$(name))
Expand Down
10 changes: 10 additions & 0 deletions getvolume/getvolume
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/perl

if ($ARGV[0] =~ m/-\w*h/)
{
printf("Usage: getvolume\n");
exit(64);
}

system("/usr/bin/osascript -e 'output volume of (get volume settings)'");
exit(0);
28 changes: 28 additions & 0 deletions getvolume/getvolume.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.Dd Tue Apr 01 2003
.Dt getvolume 1
.Os Darwin
.Sh NAME
.Nm getvolume
.Nd Gets global Mac OS X sound output volume
.Sh SYNOPSIS
.Nm
[0-100]
.Sh DESCRIPTION
.Nm
is a command line tool for checking the global Mac OS X sound output volume.
.Sh FILES
.Bl -tag -width "/usr/local/bin/getvolume" -compact
.It Pa /usr/local/bin/getvolume
.El
.Sh SEE ALSO
.Xr setvolume 1 ,
.Xr lsmac 1 ,
.Xr setfctypes 1 ,
.Xr setfflags 1 ,
.Xr mkalias 1 ,
.Xr setsuffix 1 ,
.Xr SetFile 1 ,
.Xr setfcomment 1 ,
.Xr wsupdate 1,
.Xr seticon 1,
.Xr geticon 1
7 changes: 3 additions & 4 deletions setvolume/setvolume
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/perl

$vol = $ARGV[0];

if ($vol eq "" or $vol !~ m/\d+/)
if ($ARGV[0] =~ m/-\w*h/ or $ARGV[0] eq "")
{
printf("Usage: setvolume [1-100]\n");
exit(64);
}

$vol = $ARGV[0];
system("/usr/bin/osascript -e 'set volume output volume $vol'");
exit(0);
exit(0);
3 changes: 2 additions & 1 deletion setvolume/setvolume.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
[0-100]
.Sh DESCRIPTION
.Nm
is a command line tool for controlling the global Mac OS X sound output voluem. It accepts a single number, from 0 (silent) to 100 (maximum volume).
is a command line tool for controlling the global Mac OS X sound output volume. It accepts a single number, from 0 (silent) to 100 (maximum volume).
.Sh FILES
.Bl -tag -width "/usr/local/bin/setvolume" -compact
.It Pa /usr/local/bin/setvolume
.El
.Sh SEE ALSO
.Xr getvolume 1 ,
.Xr lsmac 1 ,
.Xr setfctypes 1 ,
.Xr setfflags 1 ,
Expand Down

0 comments on commit 95c3ece

Please sign in to comment.