Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetchcord 3 release #229

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
996fb6c
Add parrot OS (#153)
BlivionIaG Jun 10, 2021
6731b70
fix windows scoop neofetch compatibility
BlivionIaG Jun 10, 2021
92264f9
Update version number
BlivionIaG Jun 10, 2021
919473c
Merge branch 'master' into testing
BlivionIaG Jun 10, 2021
e039354
Add more mobo support and os's
BlivionIaG Jun 10, 2021
6fb9ec7
Merge branch 'testing' of https://github.com/MrPotatoBobx/FetchCord i…
BlivionIaG Jun 10, 2021
f987ee3
Add mageia
BlivionIaG Jun 10, 2021
bb16e4a
Add elitedesk 800 g1
BlivionIaG Jun 10, 2021
b4ad426
Fix debug and add windows 11
BlivionIaG Jul 16, 2021
b950504
Add athlon silver & gold cpu support
BlivionIaG Jul 29, 2021
4f74c61
Prepare alt mobo detect
BlivionIaG Jul 29, 2021
b173700
[untested] motherboard fix
BlivionIaG Aug 8, 2021
76366db
Add some random acer laptop
BlivionIaG Aug 10, 2021
14957c2
Add elementary os support and thinkcenter
BlivionIaG Aug 19, 2021
ff5bdc3
Disable logger
BlivionIaG Aug 19, 2021
0e0d708
Revert "Disable logger"
BlivionIaG Aug 19, 2021
66c69f9
Disable logger file
BlivionIaG Aug 19, 2021
53f68ab
Add terminus / elementary os terminal
BlivionIaG Aug 19, 2021
819f7a8
Add windows terminal
BlivionIaG Aug 19, 2021
75dc95b
fix windows terminal detection
BlivionIaG Aug 22, 2021
5030351
Fix mobo detection on linux and host cycle
BlivionIaG Sep 19, 2021
fda8b8c
Add GUI frontend (#177)
TabulateJarl8 Nov 1, 2021
666f6ef
Black + flake8
BlivionIaG Nov 1, 2021
e124def
Fix for PRs #174, #178, #179, #181, #181 (#182)
luni-moon Nov 3, 2021
a6f1402
Fix #149 (#186)
SimPilotAdamT Dec 3, 2021
186f556
GUI Fixes (#184)
TabulateJarl8 Dec 3, 2021
404aa0e
Fixes syntax error caused by GitHub CoPilot (#187)
SimPilotAdamT Dec 4, 2021
4fda719
Update Computer.py (#188)
SimPilotAdamT Dec 4, 2021
fa7c2c5
Import gui stuff only when used
BlivionIaG Dec 4, 2021
de98dee
Fix the error preventing build (#191)
SimPilotAdamT Jan 4, 2022
eb11bf1
Fetchcord 3.0: Simpler code, less neofetch dependency on windows (#227)
BlivionIaG Apr 21, 2024
23cf857
README.md quick refactor
BlivionIaG May 7, 2024
b9163fb
Update README.md
BlivionIaG May 7, 2024
ebdb380
Split commands and cycle config
BlivionIaG May 7, 2024
5630e4e
Cleaning
BlivionIaG May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Examples/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include *.py
include */*.py
include */*/*.py
include */*/*/*.py
include resources/*.json
include resources/fetchcord_conf.yml
include resources/fetchcord_cmds.yml
include resources/default.conf
114 changes: 79 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
<a href="https://img.shields.io/badge/Compatible-MacOS%2FWindows%2FLinux-brightgreen?style=for-the-badge&logo=discord">
<img src="https://cdn.discordapp.com/attachments/695182849476657223/742064452421288077/FetchDis.png"
</a>

</a>
</p>

# Table of content

- [**Features**](#features)
- [**To-Do**](#to-do)
+ **Installing**
- [Install on (gnu/)linux](#installing-on-gnulinux)
- [Install on MacOS](#installing-on-macos)
- [Install on Windows](#installing-on-windows)
+ **Running**
- [Running on (gnu/)linux](#run)
- [Running on MacOS](#run-1)
- [Running on Windows](#run-2)
- [**Configuration**](#Configuration)
- **Installing**
- [Install on (gnu/)linux](#installing-on-gnulinux)
- [Install on MacOS](#installing-on-macos)
- [Install on Windows](#installing-on-windows)
- **Running**
- [Running on (gnu/)linux](#run-on-linux)
- [Running on MacOS](#run-on-macos)
- [Running on Windows](#run-on-windows)
- [**Configuration**](#configuration)
- [**Arguments**](#arguments)
- [**Website**](#website)
- [**Examples**](#examples)

+ [**Examples**](#examples)

### Features
## Features

- [x] Distribution detection

- [x] Distribution Version

- [x] Package detection
Expand All @@ -47,20 +47,23 @@

- [x] Detecting Window Manager/Desktop Environment

- [x] Detecting GPU/CPU and display it in a cycle (thanks to Hyper-KVM)
- [x] Detecting GPU/CPU and display it in a cycle

- [x] Flatpak support

- [x] Add Snap support

- [x] Add Windows support.

- [x] Detect Window Manager/Desktop Environment version

- [x] Periodic polling of info such as package count, RAM usage, etc.

## To be tested

- [ ] Snap support

- [ ] GUI Frontend

### To-Do
## To-Do

- [ ] Add more distributions (If your distro is not supported open an issue)

Expand All @@ -70,47 +73,68 @@

- [ ] More GPUs?


## Installing on (GNU/)Linux

NOTE: you need neofetch to be also installed for this to work.
#### Via AUR
On Arch Linux install this package for the git version: [fetchcord-git](https://aur.archlinux.org/packages/fetchcord-git/)

Do note that this version is directly from master, for the stable release use [pip](#via-pip)
#### Via Snap
On systems with snap installed, you can run `sudo snap install fetchcord --classic` to install fetchcord.
### Via pip (recommended)

Note that like the AUR version, this version is directly from master, for the stable release use [pip](#via-pip) <!-- remove this if you're not automatically deploying it -->
#### Via pip
To Install fetchcord via pip you can run `pip3 install fetchcord`
To install fetchcord via pip you can run `pip3 install fetchcord`

(experimental) To install fetchcord with the GUI requirements, run `pip3 install fetchcord[gui]`

If you want to remove FetchCord you can run `pip3 uninstall fetchcord`

### Run
### Via AUR

On Arch Linux for the git testing version (the less stable version): [fetchcord-testing](https://aur.archlinux.org/packages/fetchcord-testing/)

And the git version (synced with master): [fetchcord](https://aur.archlinux.org/packages/fetchcord/)

### Via Snap

On systems with snap installed, you can run `sudo snap install fetchcord --classic` to install fetchcord.

Note that like the AUR version, this version is directly from master, for the stable release use [pip](#via-pip-recommended) <!-- remove this if you're not automatically deploying it -->

### Run on Linux

Once installed, simply run `fetchcord`. The program is also daemonizable meaning you can start it on boot using any method you prefer.

If you get `fetchcord: command not found`,add `export PATH="$HOME/.local/bin:$PATH"` to your bashrc, or just run `python3 -m fetchcord`.
If you get `fetchcord: command not found`,add `export PATH="$HOME/.local/bin:$PATH"` to your bashrc, or just run `python3 -m fetch_cord`.

Optionally for systemd users there is a user-side `fetchcord.service` in this repo that can be installed to `~/.local/share/systemd/user/`, started and enabled on boot using `systemctl --user enable --now fetchcord`.

## Installing on MacOS

To install FetchCord, run `pip3 install FetchCord`

NOTE: you need neofetch to be also installed for this to work.

### Run
To install fetchcord via pip you can run `pip3 install fetchcord`

(experimental) To install fetchcord with the GUI requirements, run `pip3 install fetchcord[gui]`

If you want to remove FetchCord you can run `pip3 uninstall fetchcord`

### Run on MacOS

Once installed, simply run `fetchcord`. The program is also daemonizable meaning you can start it on boot using any method you prefer.

simply run `fetchcord`
If you get `fetchcord: command not found`,add `export PATH="$HOME/.local/bin:$PATH"` to your zshrc, or just run `python3 -m fetch_cord`.

## Installing on Windows

To install fetchcord on Windows run `python -m pip install fetchcord neofetch-win`. Alternatively, you can use the neofetch package from scoop as well (show more info at the expense of possible GPU detection, for now).
To install fetchcord on Windows run `pip3 install fetchcord` or `python3 -m pip install fetchcord`.

### Run on Windows

### Run
To run Fetchcord run `fetchcord`

If you get `fetchcord: command not found`, add your python scripts folder to your PATH or use `python3 -m fetch_cord`.

### GUI

The fetchcord GUI can be opened by running `fetchcord --gui` in a terminal. A desktop file may be added in a future version.

### Configuration

On Linux you can use the neofetch config file to:
Expand All @@ -132,6 +156,7 @@ And more
default config path should be `~/.config/neofetch/config.conf`

## Arguments

--nodistro, Don't show distro info.

--nohardware, Don't show hardware info.
Expand All @@ -154,14 +179,33 @@ default config path should be `~/.config/neofetch/config.conf`

--memtype, use GB or MB to show RAM.

--gui, open the fetchcord GUI

-h or --help, shows this information above.

## Website

Fetchcord now has a website! You can find this site over at https://fetchcord.github.io/ - please keep in mind this site is still currently work in progress though.

## Examples

### Operating Systems

![MacOS bigsur](Examples/mac.png) ![Windows 10](Examples/windows.png) ![Ubuntu](Examples/ubuntu.png)

### Terminals

![Konsole](Examples/konsole.png) ![Gnome terminal](Examples/gnometerm.png) ![Apple terminal](Examples/appleterm.png)

### Cpus

![Ryzen 9](Examples/ryzencpu.png) ![Intel i7](Examples/intelcpu.png) ![Intel pentium](Examples/pent.png)

### Hosts

![HP laptop](Examples/hp.png) ![TUF gaming laptop](Examples/tuf.png) ![Lenovo desktop](Examples/len.png)

### GUI

Note that the GUI version may look different depending on your OS and Qt theme.
![GUI](Examples/gui.png)
24 changes: 24 additions & 0 deletions fetch_cord/Config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3

from importlib import resources
import yaml


class Config(dict):
def __init__(self, config_name: str = "fetchcord_conf.yml") -> None:
super(Config, self).__init__(
self.get_config(self.get_resource_path("fetch_cord.resources", config_name))
)

def get_resource_path(self, package, resource: str):
with resources.path(package, resource) as path:
return path

def get_config(self, path: str):
with open(path, "r") as stream:
try:
return yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)

return None
89 changes: 80 additions & 9 deletions fetch_cord/Cycle.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,91 @@
from .computer.Computer import Computer
# 1/usr/bin/env python3


from threading import Event
from typing import Dict
from pypresence import Presence, exceptions
import psutil


class Cycle:
name: str

app_id: str = None
top_line: str = None
bottom_line: str = None
small_icon: str = None
time: str = None

debug: bool = False
rpc: Presence = None

stop: Event = None

def __init__(self, config: Dict, stop: Event = None):
if stop is None:
stop = Event()

for key in config:
setattr(self, key, config[key])
self.stop = stop

def __del__(self) -> None:
if self.rpc is not None:
self.rpc.close()

def setup(self, client_id: str) -> None:
self.rpc = Presence(int(client_id))

def try_connect(self) -> None:
while not self.stop.is_set():
try:
if self.debug:
print('try_connect(name="{}")'.format(self.name))
self.rpc.connect()
break
except ConnectionRefusedError:
print(
"""
RPC connection refused (is Discord open?); trying again in 30 seconds"""
)
self.wait(30)

def update(
self, client_id: str, app: str, bottom: str, top: str, icon: str, icon_id: str
):
try:
self.rpc.update(
int(client_id),
state=bottom,
details=top,
large_image="big",
large_text=app,
small_image=icon_id,
small_text=icon,
start=psutil.boot_time(),
)

self.wait(int(self.time))

self.rpc.close()
# ConnectionResetError is here to avoid crashing
# if Discord is still just starting
except (ConnectionResetError, exceptions.InvalidID):
pass

def wait(self, n: float, interval_duration: float = 0.05) -> None:
"""Wait for n seconds or until interrupted."""

def __init__(self, name: str, config: Dict[str, str], computer: Computer):
self.name = name
intervals = int(n / interval_duration)
for _ in range(intervals):
if self.stop.wait(interval_duration):
break

if "top_line" in config["top_line"]:
self.top_line = config["top_line"]
if "bottom_line" in config["bottom_line"]:
self.bottom_line = config["bottom_line"]
if "small_icon" in config["small_icon"]:
self.small_icon = config["small_icon"]
def __repr__(self) -> str:
return f"""
{{name = {self.name}, \
app_id = {self.app_id}, \
top_line = {self.top_line}, \
bottom_line = {self.bottom_line}, \
small_icon = {self.small_icon}, \
time = {self.time}}}"""
Loading