A simple python script to control Spotify volume using keyboard shortcuts.
- Install python from official website or by using winget in your terminal or command prompt:
winget install python
- Install dependencies by running the following command in your terminal or command prompt:
pip install spotipy keyboard python-dotenv
- Download this repository as ZIP and extract it or clone it using git
-
Log into Spotify for Developers.
-
Create a new app:
- Choose any desired app name and description
- Set the redirect URI to anything you prefer, such as
https://open.spotify.com/
orhttp://localhost/
- Select Web API
- Accept the Developer Terms of Service and Design Guidelines
-
Open your application details and enter them into
.env-example
file -
Rename
.env-example
file to.env
- Edit the
spotify-volume.py
file. Change the key bindings to your desired keyboard shortcuts by modifying these lines of code:
volume_up_key = "f13"
volume_down_key = "f14"
volume_mute_key = "f15"
exit_key = "f12"
- Run the Python script by opening the
spotify-volume.bat
file or through the shell withpython [path]/spotify-volume.py
. Running the script directly won't work because it needs to create a cache file for your Spotify token.
You can change specific settings by modifying these lines of code:
volume_step = 2 # The increment/decrement step size for volume adjustments
max_volume = 100 # Maximum playback volume
min_volume = 0 # Minimum playback volume
bar_length = 25 # Volume bar length
refresh_rate = 5 # Time in seconds to refresh playback data