mirror of https://github.com/aristocratos/bpytop
Added: Set terminal title at start
parent
8fcf638d83
commit
e6bcc9d65f
13
bpytop.py
13
bpytop.py
|
@ -547,6 +547,11 @@ class Term:
|
||||||
new_attr = [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
|
new_attr = [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
|
||||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, new_attr)
|
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, new_attr)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def title(text: str = "") -> str:
|
||||||
|
if text: text = f' {text}'
|
||||||
|
return f'\033]0;{os.environ.get("TERMINAL_TITLE", "")}{text}\a'
|
||||||
|
|
||||||
class Fx:
|
class Fx:
|
||||||
"""Text effects
|
"""Text effects
|
||||||
* trans(string: str): Replace whitespace with escape move right to not overwrite background behind whitespace.
|
* trans(string: str): Replace whitespace with escape move right to not overwrite background behind whitespace.
|
||||||
|
@ -3955,13 +3960,13 @@ def now_sleeping(signum, frame):
|
||||||
"""Reset terminal settings and stop background input read before putting to sleep"""
|
"""Reset terminal settings and stop background input read before putting to sleep"""
|
||||||
Key.stop()
|
Key.stop()
|
||||||
Collector.stop()
|
Collector.stop()
|
||||||
Draw.now(Term.clear, Term.normal_screen, Term.show_cursor, Term.mouse_off, Term.mouse_direct_off)
|
Draw.now(Term.clear, Term.normal_screen, Term.show_cursor, Term.mouse_off, Term.mouse_direct_off, Term.title())
|
||||||
Term.echo(True)
|
Term.echo(True)
|
||||||
os.kill(os.getpid(), signal.SIGSTOP)
|
os.kill(os.getpid(), signal.SIGSTOP)
|
||||||
|
|
||||||
def now_awake(signum, frame):
|
def now_awake(signum, frame):
|
||||||
"""Set terminal settings and restart background input read"""
|
"""Set terminal settings and restart background input read"""
|
||||||
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on)
|
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on, Term.title("BpyTOP"))
|
||||||
Term.echo(False)
|
Term.echo(False)
|
||||||
Key.start()
|
Key.start()
|
||||||
Term.refresh()
|
Term.refresh()
|
||||||
|
@ -3986,7 +3991,7 @@ def clean_quit(errcode: int = 0, errmsg: str = "", thread: bool = False):
|
||||||
Key.stop()
|
Key.stop()
|
||||||
Collector.stop()
|
Collector.stop()
|
||||||
if not errcode: CONFIG.save_config()
|
if not errcode: CONFIG.save_config()
|
||||||
Draw.now(Term.clear, Term.normal_screen, Term.show_cursor, Term.mouse_off, Term.mouse_direct_off)
|
Draw.now(Term.clear, Term.normal_screen, Term.show_cursor, Term.mouse_off, Term.mouse_direct_off, Term.title())
|
||||||
Term.echo(True)
|
Term.echo(True)
|
||||||
if errcode == 0:
|
if errcode == 0:
|
||||||
errlog.info(f'Exiting. Runtime {timedelta(seconds=round(time() - SELF_START, 0))} \n')
|
errlog.info(f'Exiting. Runtime {timedelta(seconds=round(time() - SELF_START, 0))} \n')
|
||||||
|
@ -4268,7 +4273,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
||||||
#? Switch to alternate screen, clear screen, hide cursor, enable mouse reporting and disable input echo
|
#? Switch to alternate screen, clear screen, hide cursor, enable mouse reporting and disable input echo
|
||||||
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on)
|
Draw.now(Term.alt_screen, Term.clear, Term.hide_cursor, Term.mouse_on, Term.title("BpyTOP"))
|
||||||
Term.echo(False)
|
Term.echo(False)
|
||||||
Term.refresh()
|
Term.refresh()
|
||||||
if CONFIG.update_check: UpdateChecker.run()
|
if CONFIG.update_check: UpdateChecker.run()
|
||||||
|
|
Loading…
Reference in New Issue