Compare commits

..

No commits in common. "0c369dc5df9480bdc3fabd52c17b8ff0d8e75b8b" and "72b558707ee3096d4a77d262025c3bf695073fcf" have entirely different histories.

3 changed files with 21 additions and 45 deletions

View File

@ -15,24 +15,24 @@ This library's import path is `go.arsenm.dev/infinitime`.
### Dependencies
This library requires `dbus`, and `bluez` to function. These allow the library to use bluetooth, control media, control volume, etc.
This library requires `dbus`, `bluez`, and `pactl` to function. These allow the library to use bluetooth, control media, control volume, etc.
#### Arch
```shell
sudo pacman -S dbus bluez --needed
sudo pacman -S dbus bluez libpulse --needed
```
#### Debian/Ubuntu
```shell
sudo apt install dbus bluez
sudo apt install dbus bluez pulseaudio-utils
```
#### Fedora
```shell
sudo dnf install dbus bluez
sudo dnf install dbus bluez pulseaudio-utils
```
---
@ -53,4 +53,4 @@ This library currently supports the following features:
### Mentions
The DFU process used in this library was created with the help of [siglo](https://github.com/alexr4535/siglo)'s source code. Specifically, this file: [ble_dfu.py](https://github.com/alexr4535/siglo/blob/main/src/ble_dfu.py)
The DFU process used in this library was created with the help of [siglo](https://github.com/alexr4535/siglo)'s source code. Specifically, this file: [ble_dfu.py](https://github.com/alexr4535/siglo/blob/main/src/ble_dfu.py)

16
pkg/player/pactl.go Normal file
View File

@ -0,0 +1,16 @@
package player
import (
"fmt"
"os/exec"
)
// VolUp uses pactl to increase the volume of the default sink
func VolUp(percent uint) error {
return exec.Command("pactl", "set-sink-volume", "@DEFAULT_SINK@", fmt.Sprintf("+%d%%", percent)).Run()
}
// VolDown uses pactl to decrease the volume of the default sink
func VolDown(percent uint) error {
return exec.Command("pactl", "set-sink-volume", "@DEFAULT_SINK@", fmt.Sprintf("-%d%%", percent)).Run()
}

View File

@ -107,46 +107,6 @@ func Prev() error {
return nil
}
func VolUp(percent uint) error {
player, err := getPlayerObj()
if err != nil {
return err
}
if player != nil {
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
if err != nil {
return err
}
newVal := currentVal.Value().(float64) + (float64(percent) / 100)
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
if err != nil {
return err
}
}
return nil
}
func VolDown(percent uint) error {
player, err := getPlayerObj()
if err != nil {
return err
}
if player != nil {
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
if err != nil {
return err
}
newVal := currentVal.Value().(float64) - (float64(percent) / 100)
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
if err != nil {
return err
}
}
return nil
}
type ChangeType int
const (