Simple rofi script to choose player for playerctl to execute its command

Overview

rofi-playerctl-switcher

simple rofi script to choose player for playerctl to execute its command

Usage

copy playerSwitch.py and playerctl.sh to ~/.config/i3/scripts/ or you can change the directory that you want inside the scripts

to run player switcher, do

python ~/.config/i3/scripts/playerSwitch.py

and to control player, do

~/.config/i3/scripts/playerctl.sh [playerctl command (playerctl -h)]

or you can also add it to your i3 config file

bindsym $mod+u exec python ~/.config/i3/scripts/playerSwitch.py

bindsym XF86AudioPlay exec ~/.config/i3/scripts/playerctl.sh play-pause
bindsym XF86AudioPause exec ~/.config/i3/scripts/playerctl.sh pause
bindsym XF86AudioNext exec ~/.config/i3/scripts/playerctl.sh next
bindsym XF86AudioPrev exec ~/.config/i3/scripts/playerctl.sh previous
You might also like...
A chain of stores wants a 3-month demand forecast for its 10 different stores and 50 different products.
A chain of stores wants a 3-month demand forecast for its 10 different stores and 50 different products.

Demand Forecasting Objective A chain store wants a machine learning project for a 3-month demand forecast for 10 different stores and 50 different pro

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero.

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with places after the decimal.

Automates the fixing of problems reported by yamllint by parsing its output

yamlfixer yamlfixer automates the fixing of problems reported by yamllint by parsing its output. Usage This software automatically fixes some errors a

A timer for bird lovers, plays a random birdcall while displaying its image and info.
A timer for bird lovers, plays a random birdcall while displaying its image and info.

Birdcall Timer A timer for bird lovers. Siriema hatchling by Junior Peres Junior Background My partner needed a customizable timer for sitting and sta

CBO uses its Capital Tax model (CBO-CapTax) to estimate the effects of federal taxes on capital income from new investment

CBO’s CapTax Model CBO uses its Capital Tax model (CBO-CapTax) to estimate the effects of federal taxes on capital income from new investment. Specifi

Python script to commit to your github for a perfect commit streak. This is purely for education purposes, please don't use this script to do bad stuff.

Daily-Git-Commit Commit to repo every day for the perfect commit streak Requirments pip install -r requirements.txt Setup Download this repository. Cr

Simple python script for AD enumeration
Simple python script for AD enumeration

AutoAD - Simple python script for AD enumeration This tool was created on my spare time to help fellow penetration testers in automating the basic enu

A simple script that can watch a list of directories for change and does some action
A simple script that can watch a list of directories for change and does some action

plot_watcher A simple script that can watch a list of directories and does some action when a specific kind of change happens In its current implement

A simple script that shows important photography times. written in python.
A simple script that shows important photography times. written in python.

A simple script that shows important photography times. written in python.

Comments
  • Avoid using `player` auxiliary file

    Avoid using `player` auxiliary file

    Hey! I updated your playerSwitch.py such that it doesn't need to create an auxiliary file to select the player. This has the advantage (in my opinion) of not needing the player.sh and changing the configuration of i3.

    The updated playerSwitch.py looks like this:

    import os
    import subprocess
    
    # config
    path = "~/.config/i3/scripts"
    rofiOption = ""
    
    # get list of players
    players = subprocess.run(['playerctl', '-l'], capture_output=True, text=True).stdout.split("\n")
    players.pop(len(players)-1)
    
    # create class
    class playersData:
        def __init__(self, display, command):
            self.display = display
            self.command = command
    
    # create list and input players info into class of it's own
    list = []
    for i, player in enumerate(players):
        info = subprocess.run(['playerctl', '-p', player, 'metadata', '--format', "({{ artist }} - {{ title }})"], capture_output=True, text=True).stdout[:-1]
        statusGet = subprocess.run(['playerctl', '-p', player, 'status'], capture_output=True, text=True).stdout[:-1]
        selected = '✅ ' if i == 0 else ''
        if statusGet == 'Playing':
            status = ""
        else:
            status = ""
        list.append( playersData(selected +  status + " " + player.split(".")[0] + " " + info, player.strip()) )
    
    # preparing menu
    menuArray = []
    for obj in list:
        menuArray.append(obj.display)
    c = '"'+"\n".join(menuArray)+'"'
    
    # displaying menu
    choice = os.popen('echo ' + c + ' | rofi -dmenu -i -p "Select Players" ' + rofiOption).read()[:-1]
    
    for i, obj in enumerate(list):
        if obj.display == choice:
            for j in range(i):
                os.system("playerctld shift")
    

    I hope it is useful!

    opened by marcbenedi 1
Owner
null
Rofi script to minimize / unminimize multiple windows in qtile

Qminimize Rofi script to minimize / unminimize multiple windows in qtile Additional requirements : EWMH module fuzzywuzzy module How to use it : - Clo

null 9 Sep 18, 2022
A script where you execute a script that generates a base project for your gdextension

GDExtension Project Creator this is a script (currently only for linux) where you execute a script that generates a base project for your gdextension,

Unknown 11 Nov 17, 2022
NotesToCommands - a fully customizable notes / command template program, allowing users to instantly execute terminal commands

NotesToCommands is a fully customizable notes / command template program, allowing users to instantly execute terminal commands with dynamic arguments grouped into sections in their notes/files. It was originally created for pentesting uses, to avoid the needed remembrance and retyping of sets of commands for various attacks.

zxro 5 Jul 2, 2022
Notifies server owners of mod updates, also notifies of player deaths and player joins through Discord.

ProjectZomboid-ServerAssistant Notifies server owners of mod updates, also notifies of player deaths and player joins through Discord. A Python based

null 3 Sep 30, 2022
A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv

poetry-exec-plugin A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv Installat

null 38 Jan 6, 2023
Islam - This is a simple python script.In this script I have written all the suras of Al Quran. As a result, by using this script, you can know the number of any sura at the moment.

Introduction: If you want to know sura number of al quran by just typing the name of sura than you can use this script. Usage in termux: $ pkg install

Fazle Rabbi 1 Jan 2, 2022
Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.

Quiz Application Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends. When they would a

Atharva Parkhe 1 Feb 23, 2022
Get the stats of a (or more) Hypixel player(s)

Hypixel_Stats Get the statistics of a (or more) Hypixel player(s) Who needs this? Everyone who plays a lot of Minecraft and often plays on mc.hypixel.

Finnomator 1 Feb 12, 2022
Python: Wrangled and unpivoted gaming datasets. Tableau: created dashboards - Market Beacon and Player’s Shopping Guide.

Created two information products for GameStop. Using Python, wrangled and unpivoted datasets, and created Tableau dashboards.

Zinaida Dvoskina 2 Jan 29, 2022
Prometheus exporter for chess.com player data

chess-exporter Prometheus exporter for chess.com player data implemented via chess.com's published data API and Prometheus Python Client Example use c

Mário Uhrík 7 Feb 28, 2022