Skip to content

Commit

Permalink
Merge branch 'master' into logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lasers authored Jan 10, 2025
2 parents 9d39101 + 5d73d00 commit 77b8960
Show file tree
Hide file tree
Showing 20 changed files with 397 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v1
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "11 1 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ python ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
36 changes: 36 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
version 3.61 (2024-12-05)
* argparsers: pgrep i3 with shmlog (#2272), by lasers
* modules: fix SyntaxWarning for python 3.12+ thx to @sdelafond (#2274)
* conky module: fix tempfile and ignore new output (#2273), by ntorresalberto
* mpris module: hide all non can_play players (#2267), by Valdur Kana
* playerctl module: gi.require_version notification fix (#2270), by Valdur Kana

version 3.60 (2024-10-24)
* THANKS to Valdur Kana and @lasers for their long and continued efforts in improving py3status!
* core: drop EOL python 3.8 and add new 3.13 to CI (#2266)
* external_script module: add composite placeholder (#2263), by lasers
* hddtemp module: remove deprecated telnetlib dependency (fixes #2261) (#2262), by Valdur Kana
* kdeconnector module: replace pydbus with dbus-python (#2264), by Valdur Kana
* mpris module: improve documentation (#2257), by Valdur Kana
* playerctl module: hide non-can-play players and use chrome and chromium as default value. (#2256), by Valdur Kana
* playerctl module: list python-gobject as dependency (#2258), by Joey Holtzman
* wwan module: replace pydbus with dbus-python (#2265), by Valdur Kana

version 3.59 (2024-08-02)
* core: strip whitespaces from OUTPUT, OUTPUT_PART events (#2245), by lasers
* ci(ruff): use new ruff check path command (#2253)
* external_script module: fix clicking on parts of message thx to @lasers (#2254)
* mpris module: kdeconnect mpris interface will skip identity cache, because mobile device can run different media players (#2251), by Valdur Kana

version 3.58 (2024-05-31)
* conky module: skip invalid conky errors (#2248), by lasers
* weather_owm module: switch to 3.0 API endpoint as 2.5 is deprecated (#2249)

version 3.57 (2024-03-26)
* docs: explain how to serve mkdocs locally (#2239), by Lujeni
* add CodeQL workflow for GitHub code scanning (#2159), by lgtm-com[bot]
* fmt: fix newer black
* backlight module: add brightnessctl support (#2233), by Gabriele Fioco
* conky module: workaround upstream issues/1479 (#2238), by ntorresalberto
* volume_status module: fix for default source with pamixer (#2240), by oceyral

version 3.56 (2024-01-28)
* remove audio modules in favor of playerctl (#2231), by lasers
* new module dexcom: display glucose readings from your Dexcom CGM system (#2229), by lasers
Expand Down
14 changes: 13 additions & 1 deletion docs/dev-guide/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Run setup.py to install
$ cd py3status

# install you may need to use sudo to have required permissions
$ python setup.py develop
$ pip install -e .
```

you can now run py3status and any changes to the code you make will be
Expand All @@ -120,6 +120,18 @@ available after a reload.

Starting with version 3.26, py3status will only run using python 3.

## Documentation

Documentation pages are located under the docs/ folder.

To run the documentation site locally (useful for previewing changes), use:

```bash
# you need to install hatch
# pip install --user hatch
hatch -e docs mkdocs serve
```

## tox

Py3status uses tox for testing. All submissions to the project must pass
Expand Down
2 changes: 1 addition & 1 deletion py3status/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_cli_args():

# get window manager
with Path(os.devnull).open("w") as devnull:
if subprocess.call(["pgrep", "-x", "i3"], stdout=devnull) == 0:
if subprocess.call(["pgrep", "^(i3|i3-with-shmlog)$"], stdout=devnull) == 0:
wm = "i3"
else:
wm = "sway"
Expand Down
2 changes: 1 addition & 1 deletion py3status/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_module_text(self, module_name, event):
partial_text = partial["full_text"]
else:
partial_text = full_text
return full_text, partial_text
return (x.strip() for x in (full_text, partial_text))

def on_click_dispatcher(self, module_name, event, command):
"""
Expand Down
2 changes: 1 addition & 1 deletion py3status/modules/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Py3status:
format = "{format_adapter}"
format_adapter = "{format_device}"
format_adapter_separator = " "
format_device = "\?if=connected&color=connected {alias}"
format_device = r"\?if=connected&color=connected {alias}"
format_device_separator = " "
thresholds = [(False, "bad"), (True, "good")]

Expand Down
17 changes: 14 additions & 3 deletions py3status/modules/conky.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,26 @@ def post_config_hook(self):
self.config.update({"out_to_x": False, "out_to_console": True})
self.separator = "|SEPARATOR|" # must be upper

# make an output.
# make an output
config = dumps(self.config, separators=(",", "=")).replace('"', "")
text = self.separator.join([f"${{{x}}}" for x in conky_placeholders])
tmp = f"conky.config = {config}\nconky.text = [[{text}]]"

# write tmp output to '/tmp/py3status-conky_*', make a command
self.tmpfile = NamedTemporaryFile(prefix="py3status_conky-", suffix=".conf", delete=False)
self.tmpfile = NamedTemporaryFile(
prefix="py3status_conky-", suffix=".conf", delete_on_close=False
)
self.tmpfile.write(str.encode(tmp))
self.tmpfile.close()
self.conky_command = f"conky -c {self.tmpfile.name}".split()

# skip invalid conky errors
self.ignored_conky_outputs = [
"conky: invalid setting of type 'table'",
"conky: FOUND:",
"x11 session running",
]

# thread
self.line = ""
self.error = None
Expand All @@ -384,7 +393,7 @@ def post_config_hook(self):

def _cleanup(self):
self.process.kill()
Path(self.tmpfile).unlink()
Path(self.tmpfile.name).unlink()
self.py3.update()

def _start_loop(self):
Expand All @@ -393,6 +402,8 @@ def _start_loop(self):
while True:
line = self.process.stdout.readline().decode()
if self.process.poll() is not None or "conky:" in line:
if any(x in line for x in self.ignored_conky_outputs):
continue
raise Exception(line)
if self.line != line:
self.line = line
Expand Down
10 changes: 7 additions & 3 deletions py3status/modules/external_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Format placeholders:
{lines} number of lines in the output
{output} output of script given by "script_path"
{composite} composite output of script given by "script_path"
Examples:
```
Expand Down Expand Up @@ -104,9 +105,12 @@ def external_script(self):
else:
output = ""

response["full_text"] = self.py3.safe_format(
self.format, {"output": output, "lines": len(output_lines)}
)
script_data = {
"output": output,
"lines": len(output_lines),
"composite": self.py3.safe_format(output),
}
response["full_text"] = self.py3.safe_format(self.format, script_data)
return response

def on_click(self, event):
Expand Down
12 changes: 10 additions & 2 deletions py3status/modules/hddtemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
Requires:
hddtemp: utility to monitor hard drive temperatures
nc: netcat / ncat is command-line utility for reading data from hddtemp
telnet interface
Bible of HDD failures:
Hard disk temperatures higher than 45°C led to higher failure rates.
Expand Down Expand Up @@ -108,7 +110,8 @@
"""

from string import printable
from telnetlib import Telnet

STRING_NOT_INSTALLED = "shell command {} not installed"


class Py3status:
Expand All @@ -130,12 +133,17 @@ class Py3status:
]

def post_config_hook(self):
if not self.py3.check_commands("hddtemp"):
raise Exception(STRING_NOT_INSTALLED.format("hddtemp"))
if not self.py3.check_commands("nc"):
raise Exception(STRING_NOT_INSTALLED.format("netcat / ncat"))

self.keys = ["path", "name", "temperature", "unit"]
self.cache_names = {}
self.thresholds_init = self.py3.get_color_names_list(self.format_hdd)

def hddtemp(self):
line = Telnet("localhost", 7634).read_all().decode("utf-8", "ignore")
line = self.py3.command_output("nc localhost 7634")
new_data = []

for chunk in line[1:-1].split("||"):
Expand Down
Loading

0 comments on commit 77b8960

Please sign in to comment.