mirror of https://github.com/aristocratos/bpytop
Added theme install and path detection
parent
c6a3c4b3ec
commit
8109e9e890
|
@ -17,5 +17,6 @@ syntax: glob
|
||||||
.tox/
|
.tox/
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
__pycache__
|
||||||
.mypy_cache
|
.mypy_cache
|
||||||
.vscode
|
.vscode
|
|
@ -0,0 +1 @@
|
||||||
|
themes
|
44
bpytop.py
44
bpytop.py
|
@ -17,7 +17,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os, sys, threading, signal, re, subprocess, logging, logging.handlers
|
import os, sys, threading, signal, re, subprocess, logging, logging.handlers, site
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from time import time, sleep, strftime, localtime
|
from time import time, sleep, strftime, localtime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -186,7 +186,12 @@ if not os.path.isdir(CONFIG_DIR):
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
CONFIG_FILE: str = f'{CONFIG_DIR}/bpytop.conf'
|
CONFIG_FILE: str = f'{CONFIG_DIR}/bpytop.conf'
|
||||||
THEME_DIR: str = ""
|
THEME_DIR: str = ""
|
||||||
for td in ["local/", ""]:
|
for td in site.getsitepackages() + [site.getusersitepackages()]:
|
||||||
|
if os.path.isdir(f'{td}/bpytop-themes'):
|
||||||
|
THEME_DIR = f'{td}/bpytop-themes'
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
for td in ["local/", ""]:
|
||||||
if os.path.isdir(f'/usr/{td}share/bpytop/themes'):
|
if os.path.isdir(f'/usr/{td}share/bpytop/themes'):
|
||||||
THEME_DIR = f'/usr/{td}share/bpytop/themes'
|
THEME_DIR = f'/usr/{td}share/bpytop/themes'
|
||||||
break
|
break
|
||||||
|
@ -3811,6 +3816,9 @@ class Menu:
|
||||||
setattr(CONFIG, selected, input_val)
|
setattr(CONFIG, selected, input_val)
|
||||||
if selected.startswith("net_"):
|
if selected.startswith("net_"):
|
||||||
NetCollector.net_min = {"download" : -1, "upload" : -1}
|
NetCollector.net_min = {"download" : -1, "upload" : -1}
|
||||||
|
elif selected == "draw_clock":
|
||||||
|
Box.clock_on = True if len(CONFIG.draw_clock) > 0 else False
|
||||||
|
if not Box.clock_on: Draw.clear("clock", saved=True)
|
||||||
Term.refresh(force=True)
|
Term.refresh(force=True)
|
||||||
cls.resized = False
|
cls.resized = False
|
||||||
elif key == "backspace" and len(input_val) > 0:
|
elif key == "backspace" and len(input_val) > 0:
|
||||||
|
@ -3974,18 +3982,8 @@ class Init:
|
||||||
initbg_down: Graph
|
initbg_down: Graph
|
||||||
resized = False
|
resized = False
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def fail(err):
|
|
||||||
if CONFIG.show_init:
|
|
||||||
Draw.buffer("+init!", f'{Mv.restore}{Symbol.fail}')
|
|
||||||
sleep(2)
|
|
||||||
errlog.exception(f'{err}')
|
|
||||||
clean_quit(1, errmsg=f'Error during init! See {CONFIG_DIR}/error.log for more information.')
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def success(cls, start: bool = False):
|
def start(cls):
|
||||||
if not CONFIG.show_init or cls.resized: return
|
|
||||||
if start:
|
|
||||||
Draw.buffer("init", z=1)
|
Draw.buffer("init", z=1)
|
||||||
Draw.buffer("initbg", z=10)
|
Draw.buffer("initbg", z=10)
|
||||||
for i in range(51):
|
for i in range(51):
|
||||||
|
@ -4003,11 +4001,20 @@ class Init:
|
||||||
cls.initbg_up = Graph(Term.width, Term.height // 2, cls.initbg_colors, cls.initbg_data, invert=True)
|
cls.initbg_up = Graph(Term.width, Term.height // 2, cls.initbg_colors, cls.initbg_data, invert=True)
|
||||||
cls.initbg_down = Graph(Term.width, Term.height // 2, cls.initbg_colors, cls.initbg_data, invert=False)
|
cls.initbg_down = Graph(Term.width, Term.height // 2, cls.initbg_colors, cls.initbg_data, invert=False)
|
||||||
|
|
||||||
if start: return
|
@classmethod
|
||||||
|
def success(cls):
|
||||||
|
if not CONFIG.show_init or cls.resized: return
|
||||||
cls.draw_bg(5)
|
cls.draw_bg(5)
|
||||||
Draw.buffer("+init!", f'{Mv.restore}{Symbol.ok}\n{Mv.r(Term.width // 2 - 22)}{Mv.save}')
|
Draw.buffer("+init!", f'{Mv.restore}{Symbol.ok}\n{Mv.r(Term.width // 2 - 22)}{Mv.save}')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fail(err):
|
||||||
|
if CONFIG.show_init:
|
||||||
|
Draw.buffer("+init!", f'{Mv.restore}{Symbol.fail}')
|
||||||
|
sleep(2)
|
||||||
|
errlog.exception(f'{err}')
|
||||||
|
clean_quit(1, errmsg=f'Error during init! See {CONFIG_DIR}/error.log for more information.')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def draw_bg(cls, times: int = 5):
|
def draw_bg(cls, times: int = 5):
|
||||||
for _ in range(times):
|
for _ in range(times):
|
||||||
|
@ -4380,11 +4387,13 @@ def main():
|
||||||
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on, Term.title("BpyTOP"))
|
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on, Term.title("BpyTOP"))
|
||||||
Term.echo(False)
|
Term.echo(False)
|
||||||
Term.refresh(force=True)
|
Term.refresh(force=True)
|
||||||
|
|
||||||
|
#? Start a thread checking for updates while running init
|
||||||
if CONFIG.update_check: UpdateChecker.run()
|
if CONFIG.update_check: UpdateChecker.run()
|
||||||
|
|
||||||
#? Draw banner and init status
|
#? Draw banner and init status
|
||||||
if CONFIG.show_init:
|
if CONFIG.show_init and not Init.resized:
|
||||||
Init.success(start=True)
|
Init.start()
|
||||||
|
|
||||||
#? Load theme
|
#? Load theme
|
||||||
if CONFIG.show_init:
|
if CONFIG.show_init:
|
||||||
|
@ -4462,7 +4471,6 @@ def main():
|
||||||
else:
|
else:
|
||||||
Init.success()
|
Init.success()
|
||||||
|
|
||||||
|
|
||||||
Init.done()
|
Init.done()
|
||||||
Term.refresh()
|
Term.refresh()
|
||||||
Draw.out(clear=True)
|
Draw.out(clear=True)
|
||||||
|
|
|
@ -4,6 +4,7 @@ version = "1.0.16"
|
||||||
description = "Resource monitor that shows usage and stats for processor, memory, disks, network and processes."
|
description = "Resource monitor that shows usage and stats for processor, memory, disks, network and processes."
|
||||||
authors = ["Aristocratos <jakob@qvantnet.com>"]
|
authors = ["Aristocratos <jakob@qvantnet.com>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
include = ["bpytop-themes/*.theme"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.6"
|
python = "^3.6"
|
||||||
|
|
Loading…
Reference in New Issue