Closed HeCodes2Much closed 2 years ago
if this is easy enough to have as a custom module please can you show an example how i could do this if it doesn't need to be part of the base project please :)
# -*- coding: utf-8 -*-
"""
Example module that demonstrates status string placeholders
Configuration parameters:
format: Initial format to use
(default '{button}')
format_clicked: Display format to use when we are clicked
(default '{button}')
Format placeholders:
{button} The button that was pressed
"""
import os
class Py3status:
format = '{button}'
format_clicked = '{button}'
def __init__(self):
output = os.popen("pgrep -x picom").read()
if not output:
self.button = "UnLoaded"
else:
self.button = "Loaded"
def picom(self):
if self.button:
data = {'button': self.button}
full_text = self.py3.safe_format(self.format_clicked, data)
else:
data = {'button': self.button}
full_text = self.py3.safe_format(self.format, format)
return {
'full_text': full_text,
'cached_until': self.py3.CACHE_FOREVER
}
def on_click(self, event):
output = os.popen("pgrep -x picom").read()
if not output:
self.button = "Loaded"
os.popen(self.command_start)
else:
self.button = "UnLoaded"
os.popen(self.command_end)
picom {
format = "<span background='#6C77BB'> </span><span background='#C4C7C5'> {button} </span>"
format_clicked = "<span background='#6C77BB'> </span><span background='#C4C7C5'> {button} </span>"
command_start = "picom -CGb --experimental-backend --config ~/.config/i3/picom.conf"
command_end = "killall picom"
}
Untested. Alternative. Slightly different.
process_status picom {
format = "<span background='#6C77BB'> </span><span background='#C4C7C5'> {icon} </span>"
full = True
cache_timeout = 60
icon_on = "Loaded"
icon_off = "UnLoaded"
on_click 1 = "picom -CGb --experimental-backend --config ~/.config/i3/picom.conf"
on_click 2 = "killall picom"
}
that works like a charm :) cheers
does the 1 and 2 mean different buttons or does that mean depending on the status?
# button numbers
1 = left click
2 = middle click
3 = right click
4 = scroll up
5 = scroll down
https://py3status.readthedocs.io/en/latest/user-guide/configuration/#custom-click-events
EDIT: You also could point a single button to your script too.
Is your feature request related to a problem? Please describe. No its not about an issue with anything.
Your py3status version py3status version 3.40 (python 3.9.9) on i3
Describe the solution you'd like a module that can check if picom is running on the system or not and have a click event to enable or disable it using 'on_click'
Describe alternatives you've considered
with the scripts being
picom.sh
picom-toggle.sh
Additional context if this can be done easier with just a script please let me know in the comments as this doesn't seem to work after being clicked it takes 15 seconds to reload