项目作者: Neur1n

项目描述 :
A unit of volume, a unit for volume.
高级语言: C++
项目地址: git://github.com/Neur1n/liter.git
创建时间: 2020-04-22T10:40:35Z
项目社区:https://github.com/Neur1n/liter

开源协议:MIT License

下载


liter

Liter is a command line tool to manipulate endpoint device volume.

Table of Contents

Features

  1. Get, set, mute, step up, or step down the volume of the default*
    endpoint device (e.g. a headphone).
  2. If an endpoint device is connected or disconnected to PC, liter should
    detect the change and allow manipulating the new default endpoint device.

* Windows API

Installation

Pre-built Binaries

Checkout releases.

Build from Source

Dependencies

  • Linux: (not supported)
  • MacOS: (not supported)
  • Windows 7, 8, 8.1: (not tested)
  • Windows 10: Windows 10 SDK

Building

The CMakeLists.txt is provided as an example instead of a ready-to-use CMake
file, since some environment parameters require manually setup. Now let’s break
it down.

  1. cmake_minimum_required(VERSION 2.8.2)
  2. project(liter)
  3. set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Set to 1 to enable generating the compilation database.
  4. set(CMAKE_BUILD_TYPE Release) # Set to Debug if you need to debug.
  5. file(GLOB_RECURSE HEADERS "include/*.h")
  6. file(GLOB_RECURSE SOURCES "src/*.cpp")
  7. # WINDOWS_SDK_INCLUDE_DIR can be set in CMakeLists.txt or system environment
  8. # variables in Windows. The value should be something like:
  9. # C:\Windows Kits\10\Include\10.0.17763.0
  10. include_directories(
  11. ${WINDOWS_SDK_INCLUDE_DIR}/um
  12. include
  13. )
  14. # Similarly, WINDOWS_SDK_LIB_DIR should be something like:
  15. # C:\Windows Kits\10\Lib\10.0.17763.0
  16. link_directories(
  17. ${WINDOWS_SDK_LIB_DIR}/um/x86
  18. )
  19. add_executable(liter src/main.cpp src/liter.cpp)

Usage

The executable of liter takes no arguments, instead, it takes in arguments
after it is launched. This makes it keep track of the endpoint device we are
interfacing, instead of getting the device every time an action is performed.

For demonstration or debugging purpose, one may set the DEBUG macro to true
in main.cpp to enable echoing of the inputs. The following demonstrations are
based on such configuration.

Exit

To terminate the program, pass x (i.e. “eXit”) when Action: is prompted in
the terminal.

  1. $ liter
  2. Action: x
  3. $

Get Volume

To get the current volume level (0.0 ~ 1.0), pass g (“get”) when Action: is
prompted in the terminal. Then the volume level will be shown as
Volume: <level>. In Windows, the range of volume is from 0 to 100, therefore
a volume level 0.1 means a volume of 10.

  1. $ liter
  2. Action: g
  3. Volume: 0.1

If DEBUG is set to false, the interaction should be like:

  1. $ liter
  2. g
  3. 0.1

Which make it easier for a wrapper to parse the stdout result.

Set Volume

To set a volume level, pass s (“set”) when Action: is prompted
in the terminal. Then it will ask you for another input for Param: which is
for the target volume level. The following example sets the volume to 12.

  1. $ liter
  2. Action: s
  3. Param: 0.12
  4. Volume: 0.12

If a number smaller than 0.0 or bigger than 1.0 is passed, the feedback will be
-1.

  1. $ liter
  2. Action: s
  3. Param: 1.3
  4. Volume: -1

Please notice that, if 0.0 is passed, the volume is set to 0 but you may still
hear sounds, which is different from mute.

Mute Volume

To mute, besides passing m (“mute”) when Action: is prompted, another
argument is required for Param: - non-zero for mute, zero for un-mute. When
mute, the feedback is 0; when un-mute, the volume level before mute is
feedbacked.

Please notice that, the volume level is in fact remained when mute, but 0 is
feedbacked instead for better indication. To get the volume level after mute,
use g.

  1. $ liter
  2. Action: g
  3. Volume: 0.12
  4. Action: m
  5. Param: 1.0
  6. Volume: 0
  7. Action: g
  8. Volume: 0.12
  1. $ liter
  2. Action: m
  3. Param: 0.0
  4. Volume: 0.2

Step Up Volume

To step up the volume, besides passing u (“up”) when Action: is prompted.
In Windows 10, the default step is 0.02.

  1. $ liter
  2. Action: g
  3. Volume: 0.12
  4. Action: u
  5. Volume: 0.14

Step Down Volume

To step down the volume, besides passing d (“down”) when Action: is
prompted. In Windows 10, the default step is 0.02.

  1. $ liter
  2. Action: g
  3. Volume: 0.14
  4. Action: d
  5. Volume: 0.12