mirror of
https://github.com/HorlogeSkynet/archey4
synced 2025-04-16 16:00:13 +02:00
562 lines
25 KiB
Python
Executable File
562 lines
25 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Archey4
|
|
#
|
|
# -- Archey is a simple system information tool written in Python.
|
|
#
|
|
# Copyright 2010 Melik Manukyan <melik@archlinux.us>
|
|
# Copyright 2010 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>
|
|
#
|
|
# ASCII art by Brett Bohnenkamper <kittykatt@silverirc.com>
|
|
# Changes Jerome Launay <jerome@projet-libre.org>
|
|
# Fedora support by YeOK <yeok@henpen.org>
|
|
#
|
|
# Currently maintained by Samuel FORESTIER <https://horlogeskynet.github.io/>
|
|
#
|
|
# Distributed under the terms of the GNU General Public License v3.
|
|
# See http://www.gnu.org/licenses/gpl.txt for the full license text.
|
|
|
|
|
|
import re
|
|
|
|
from math import floor
|
|
from os import getenv, getuid
|
|
from collections import OrderedDict
|
|
from subprocess import Popen, PIPE, check_output
|
|
|
|
|
|
# -------------- Dictionaries -------------- #
|
|
|
|
colorDict = {
|
|
'Arch Linux': ['\x1b[0;34m', '\x1b[1;34m'],
|
|
'BunsenLabs': ['\x1b[1;37m', '\x1b[1;33m', '\x1b[0;33m'],
|
|
'CrunchBang': ['\x1b[1;37m', '\x1b[1;37m'],
|
|
'Debian': ['\x1b[0;31m', '\x1b[1;31m'],
|
|
'Fedora': ['\x1b[1;37m', '\x1b[0;34m'],
|
|
'Gentoo': ['\x1b[1;37m', '\x1b[1;35m'],
|
|
'Kali': ['\x1b[1;37m', '\x1b[1;34m'],
|
|
'ManjaroLinux': ['\x1b[0;32m', '\x1b[1;32m'],
|
|
'Linux': ['\x1b[1;33m', '\x1b[1;37m'],
|
|
'LinuxMint': ['\x1b[1;32m', '\x1b[1;37m'],
|
|
'openSUSE': ['\x1b[1;37m', '\x1b[1;32m'],
|
|
'Red Hat': ['\x1b[1;37m', '\x1b[1;31m', '\x1b[0;31m'],
|
|
'Ubuntu': ['\x1b[0;31m', '\x1b[1;31m', '\x1b[0;33m'],
|
|
'Sensors': ['\x1b[0;31m', '\x1b[0;32m', '\x1b[0;33m'],
|
|
'Clear': ['\x1b[0m']
|
|
}
|
|
|
|
deDict = {
|
|
'cinnamon': 'Cinnamon',
|
|
'gnome-session': 'GNOME',
|
|
'gnome-shell': 'GNOME',
|
|
'mate-session': 'MATE',
|
|
'ksmserver': 'KDE',
|
|
'xfce4-session': 'Xfce',
|
|
'fur-box-session': 'Fur Box',
|
|
'lxsession': 'LXDE',
|
|
'lxqt-session': 'LXQt'
|
|
}
|
|
|
|
wmDict = {
|
|
'awesome': 'Awesome',
|
|
'beryl': 'Beryl',
|
|
'blackbox': 'Blackbox',
|
|
'bspwm': 'bspwm',
|
|
'cinnamon': 'Cinnamon',
|
|
'compiz': 'Compiz',
|
|
'dwm': 'DWM',
|
|
'enlightenment': 'Enlightenment',
|
|
'herbstluftwm': 'herbstluftwm',
|
|
'fluxbox': 'Fluxbox',
|
|
'fvwm': 'FVWM',
|
|
'i3': 'i3',
|
|
'icewm': 'IceWM',
|
|
'kwin': 'KWin',
|
|
'metacity': 'Metacity',
|
|
'musca': 'Musca',
|
|
'nemo': 'Nemo',
|
|
'openbox': 'Openbox',
|
|
'pekwm': 'PekWM',
|
|
'qtile': 'QTile',
|
|
'ratpoison': 'ratpoison',
|
|
'scrotwm': 'ScrotWM',
|
|
'stumpwm': 'StumpWM',
|
|
'subtle': 'Subtle',
|
|
'monsterwm': 'MonsterWM',
|
|
'wingo': 'Wingo',
|
|
'wmaker': 'Window Maker',
|
|
'wmfs': 'Wmfs',
|
|
'wmii': 'wmii',
|
|
'xfwm4': 'Xfwm',
|
|
'xmonad': 'xmonad'
|
|
}
|
|
|
|
logosDict = {
|
|
'Arch Linux': """
|
|
{color[1]} + {results[0]}
|
|
{color[1]} # {results[1]}
|
|
{color[1]} ### {results[2]}
|
|
{color[1]} ##### {results[3]}
|
|
{color[1]} ###### {results[4]}
|
|
{color[1]} ; #####; {results[5]}
|
|
{color[1]} +##.##### {results[6]}
|
|
{color[1]} +########## {results[7]}
|
|
{color[1]} ######{color[0]}#####{color[1]}##; {results[8]}
|
|
{color[1]} ###{color[0]}############{color[1]}+ {results[9]}
|
|
{color[1]} #{color[0]}###### ####### {results[10]}
|
|
{color[0]} .######; ;###;`\". {results[11]}
|
|
{color[0]} .#######; ;#####. {results[12]}
|
|
{color[0]} #########. .########` {results[13]}
|
|
{color[0]} ######' '###### {results[14]}
|
|
{color[0]} ;#### ####; {results[15]}
|
|
{color[0]} ##' '## {results[16]}
|
|
{color[0]} #' `# {results[17]}
|
|
""",
|
|
'Debian': """
|
|
{color[1]} {results[0]}
|
|
{color[1]} _sudZUZ#Z#XZo=_ {results[1]}
|
|
{color[1]} _jmZZ2!!~---~!!X##wx {results[2]}
|
|
{color[1]} .<wdP~~ -!YZL, {results[3]}
|
|
{color[1]} .mX2' _xaaa__ XZ[. {results[4]}
|
|
{color[1]} oZ[ _jdXY!~?S#wa ]Xb; {results[5]}
|
|
{color[1]} _#e' .]X2( ~Xw| )XXc {results[6]}
|
|
{color[1]} .2Z` ]X[. xY| ]oZ( {results[7]}
|
|
{color[1]} .2#; )3k; _s!~ jXf` {results[8]}
|
|
{color[0]} 1Z> -]Xb/ ~ __#2( {results[9]}
|
|
{color[0]} -Zo; +!4ZwerfgnZZXY' {results[10]}
|
|
{color[0]} *#[, ~-?!!!!!!-~ {results[11]}
|
|
{color[0]} XUb;. {results[12]}
|
|
{color[0]} )YXL,, {results[13]}
|
|
{color[0]} +3#bc, {results[14]}
|
|
{color[0]} -)SSL,, {results[15]}
|
|
{color[0]} ~~~~~ {results[16]}
|
|
{color[0]} {results[17]}
|
|
""",
|
|
'Ubuntu': """
|
|
{color[0]} .oyhhs: {results[0]}
|
|
{color[1]} ..--.., {color[0]}shhhhhh- {results[1]}
|
|
{color[1]} -+++++++++`:{color[0]}yyhhyo` {results[2]}
|
|
{color[2]} .-- {color[1]}-++++++++/-.-{color[0]}::-` {results[3]}
|
|
{color[2]} .::::- {color[1]}:-----:/+++/++/. {results[4]}
|
|
{color[2]} -:::::-. {color[1]}.:++++++: {results[5]}
|
|
{color[1]} ,,, {color[2]}.:::::-` {color[1]}.++++++- {results[6]}
|
|
{color[1]} ./+++/-{color[2]}`-::- {color[1]}./////: {results[7]}
|
|
{color[1]} +++++++ {color[2]}.::- {results[8]}
|
|
{color[1]} ./+++/-`{color[2]}-::- {color[0]}:yyyyyo {results[9]}
|
|
{color[1]} ``` `{color[2]}-::::-` {color[0]}:yhhhhh: {results[10]}
|
|
{color[2]} -:::::-. {color[0]}`-ohhhhhh+ {results[11]}
|
|
{color[2]} .::::-` {color[0]}-o+///+oyhhyyyhy: {results[12]}
|
|
{color[2]} `.-- {color[0]}/yhhhhhhhy+{color[2]},.... {results[13]}
|
|
{color[0]} /hhhhhhhhh{color[2]}-.-:::; {results[14]}
|
|
{color[0]} `.:://::- {color[2]}-:::::; {results[15]}
|
|
{color[2]} `.-:-' {results[16]}
|
|
{color[2]} {results[17]}
|
|
""",
|
|
'CrunchBang': """
|
|
{color[0]} ___ ___ _ {results[0]}
|
|
{color[0]} / / / / | | {results[1]}
|
|
{color[0]} / / / / | | {results[2]}
|
|
{color[0]} / / / / | | {results[3]}
|
|
{color[0]} _______/ /______/ /______ | | {results[4]}
|
|
{color[0]} /______ _______ _______/ | | {results[5]}
|
|
{color[0]} / / / / | | {results[6]}
|
|
{color[0]} / / / / | | {results[7]}
|
|
{color[0]} / / / / | | {results[8]}
|
|
{color[0]} ______/ /______/ /______ | | {results[9]}
|
|
{color[0]} /_____ _______ _______/ | | {results[10]}
|
|
{color[0]} / / / / | | {results[11]}
|
|
{color[0]} / / / / |_| {results[12]}
|
|
{color[0]} / / / / _ {results[13]}
|
|
{color[0]} / / / / | | {results[14]}
|
|
{color[0]} /__/ /__/ |_| {results[15]}
|
|
{color[0]} {results[16]}
|
|
{color[0]} {results[17]}
|
|
""",
|
|
'Fedora': """
|
|
{color[1]} :/------------:// {results[0]}
|
|
{color[1]} :------------------:// {results[1]}
|
|
{color[1]} :-----------{color[0]}/shhdhyo/{color[1]}-:// {results[2]}
|
|
{color[1]} /-----------{color[0]}omMMMNNNMMMd/{color[1]}-:/ {results[3]}
|
|
{color[1]} :-----------{color[0]}sMMMdo:/{color[1]} -:/ {results[4]}
|
|
{color[1]} :-----------{color[0]}:MMMd{color[1]}------- --:/ {results[5]}
|
|
{color[1]} /-----------{color[0]}:MMMy{color[1]}------- ---/ {results[6]}
|
|
{color[1]} :------ --{color[0]}/+MMMh/{color[1]}-- ---: {results[7]}
|
|
{color[1]} :--- {color[0]}oNMMMMMMMMMNho{color[1]} -----: {results[8]}
|
|
{color[1]} :-- {color[0]}+shhhMMMmhhy++{color[1]} ------: {results[9]}
|
|
{color[1]} :- -----{color[0]}:MMMy{color[1]}--------------/ {results[10]}
|
|
{color[1]} :- ------{color[0]}/MMMy{color[1]}-------------: {results[11]}
|
|
{color[1]} :- ----{color[0]}/hMMM+{color[1]}------------: {results[12]}
|
|
{color[1]} :--{color[0]}:dMMNdhhdNMMNo{color[1]}-----------: {results[13]}
|
|
{color[1]} :---{color[0]}:sdNMMMMNds:{color[1]}----------: {results[14]}
|
|
{color[1]} :------{color[0]}:://:{color[1]}-----------:// {results[15]}
|
|
{color[1]} :--------------------:// {results[16]}
|
|
{color[1]} {results[17]}
|
|
""",
|
|
'Gentoo': """
|
|
{color[1]} -/oyddmdhs+:. {results[0]}
|
|
{color[1]} -o{color[0]}dNMMMMMMMMNNmhy+{color[1]}-` {results[1]}
|
|
{color[1]} -y{color[0]}NMMMMMMMMMMMNNNmmdhy{color[1]}+- {results[2]}
|
|
{color[1]} `o{color[0]}mMMMMMMMMMMMMNmdmmmmddhhy{color[1]}/` {results[3]}
|
|
{color[1]} om{color[0]}MMMMMMMMMMMN{color[1]}hhyyyo{color[0]}hmdddhhhd{color[1]}o` {results[4]}
|
|
{color[1]} .y{color[0]}dMMMMMMMMMMd{color[1]}hs++so/s{color[0]}mdddhhhhdm{color[1]}+` {results[5]}
|
|
{color[1]} oy{color[0]}hdmNMMMMMMMN{color[1]}dyooy{color[0]}dmddddhhhhyhN{color[1]}d. {results[6]}
|
|
{color[1]} :o{color[0]}yhhdNNMMMMMMMNNNmmdddhhhhhyym{color[1]}Mh {results[7]}
|
|
{color[1]} .:{color[0]}+sydNMMMMMNNNmmmdddhhhhhhmM{color[1]}my {results[8]}
|
|
{color[1]} /m{color[0]}MMMMMMNNNmmmdddhhhhhmMNh{color[1]}s: {results[9]}
|
|
{color[1]} `o{color[0]}NMMMMMMMNNNmmmddddhhdmMNhs{color[1]}+` {results[10]}
|
|
{color[1]} `s{color[0]}NMMMMMMMMNNNmmmdddddmNMmhs{color[1]}/. {results[11]}
|
|
{color[1]} /N{color[0]}MMMMMMMMNNNNmmmdddmNMNdso{color[1]}:` {results[12]}
|
|
{color[1]} +M{color[0]}MMMMMMNNNNNmmmmdmNMNdso{color[1]}/- {results[13]}
|
|
{color[1]} yM{color[0]}MNNNNNNNmmmmmNNMmhs+/{color[1]}-` {results[14]}
|
|
{color[1]} /h{color[0]}MMNNNNNNNNMNdhs++/{color[1]}-` {results[15]}
|
|
{color[1]} `/{color[0]}ohdmmddhys+++/:{color[1]}.` {results[16]}
|
|
{color[1]} `-//////:--. {results[17]}
|
|
""",
|
|
'BunsenLabs': """
|
|
{color[0]} .{color[1]}..{color[0]}+hhy+-` \0
|
|
{color[0]} `+hd{color[1]}-{color[0]}+dddd{color[2]}hyso{color[0]}+//: \0
|
|
{color[0]} `+dddd{color[1]}:-{color[0]}sdh/. {results[0]}
|
|
{color[0]} -hdddddh{color[1]}-.{color[2]}/:{color[0]} {results[1]}
|
|
{color[0]} /ddddddddd{color[1]}:```{color[0]} {results[2]}
|
|
{color[0]} :ddddddddddd/ {results[3]}
|
|
{color[0]} `hdddddddddddd+ {results[4]}
|
|
{color[0]} /dddddddddddddd: {results[5]}
|
|
{color[0]} odddds..sddddddh {results[6]}
|
|
{color[0]} oddd/ /dddddd: {results[7]}
|
|
{color[0]} +dd+ +ddddd+ {results[8]}
|
|
{color[0]} .dd` `ddddd+ {results[9]}
|
|
{color[0]} oh ydddd: {results[10]}
|
|
{color[0]} `o sdddh` {results[11]}
|
|
{color[0]} yddd: {results[12]}
|
|
{color[0]} `dddo {results[13]}
|
|
{color[0]} :s :dds {results[14]}
|
|
{color[0]} yd/ yd+ {results[15]}
|
|
{color[0]} `sddy :h- {results[16]}
|
|
{color[0]} `sddys` :` {results[17]}
|
|
{color[0]} -hdy+`y+yo./+/:- \0
|
|
{color[0]} ... .o++oso+/ \0
|
|
""",
|
|
'Kali': """
|
|
{color[0]} ,..... \0
|
|
{color[0]} ----` `..,;:ccc,. \0
|
|
{color[0]} ......''';lxO. {results[0]}
|
|
{color[0]}.....''''..........,:ld; {results[1]}
|
|
{color[0]} .';;;:::;,,.x, {results[2]}
|
|
{color[0]} ..'''. 0Xxoc:,. ... {results[3]}
|
|
{color[0]} .... ,ONkc;,;cokOdc',. {results[4]}
|
|
{color[0]} . OMo ':{color[1]}d{color[0]}o. {results[5]}
|
|
{color[0]} dMc :OO; {results[6]}
|
|
{color[0]} 0M. .:o. {results[7]}
|
|
{color[0]} ;Wd {results[8]}
|
|
{color[0]} ;XO, {results[9]}
|
|
{color[0]} ,d0Odlc;,.. {results[10]}
|
|
{color[0]} ..',;:cdOOd::,. {results[11]}
|
|
{color[0]} .:d;.':;. {results[12]}
|
|
{color[0]} 'd, .' {results[13]}
|
|
{color[0]} ;l .. {results[14]}
|
|
{color[0]} .o {results[15]}
|
|
{color[0]} c {results[16]}
|
|
{color[0]} .' {results[17]}
|
|
{color[0]} . \0
|
|
""",
|
|
'Manjaro': """
|
|
{color[0]} $$$$$$$$$$$$$$$$ $$$$$$$ {results[0]}
|
|
{color[0]} M77777777777777M M77777M {results[1]}
|
|
{color[0]} M77777777777777M M77777M {results[2]}
|
|
{color[0]} M77777MMMMMMMMMM M77777M {results[3]}
|
|
{color[0]} M77777M M77777M {results[4]}
|
|
{color[0]} M77777M $$$$$$$ M77777M {results[5]}
|
|
{color[0]} MMMMMMM M77777M M77777M {results[6]}
|
|
{color[0]} M77777M M77777M {results[7]}
|
|
{color[0]} $$$$$$$ M77777M M77777M {results[8]}
|
|
{color[0]} M77777M M77777M M77777M {results[9]}
|
|
{color[0]} M77777M M77777M M77777M {results[10]}
|
|
{color[0]} M77777M M77777M M77777M {results[11]}
|
|
{color[0]} M77777M M77777M M77777M {results[12]}
|
|
{color[0]} M77777M M77777M M77777M {results[13]}
|
|
{color[0]} M77777M M77777M M77777M {results[14]}
|
|
{color[0]} M77777M M77777M M77777M {results[15]}
|
|
{color[0]} M77777M M77777M M77777M {results[16]}
|
|
{color[0]} MMMMMMM MMMMMMM MMMMMMM {results[17]}
|
|
""",
|
|
'openSUSE': """
|
|
{color[0]} .;ldkO0000Okdl;. {results[0]}
|
|
{color[0]} .;d00xl:^''''''^:ok00d;. {results[1]}
|
|
{color[0]} .d00l' 'o00d. {results[2]}
|
|
{color[0]} .d0Kd' {color[1]}Okxol:;,.{color[0]} :O0d. {results[3]}
|
|
{color[0]} .OK{color[1]}KKK0kOKKKKKKKKKKOxo:,{color[0]} lKO. {results[4]}
|
|
{color[0]} ,0K{color[1]}KKKKKKKKKKKKKKK0P^{color[0]},,,{color[1]}^dx:{color[0]} ;00, {results[5]}
|
|
{color[0]} .OK{color[1]}KKKKKKKKKKKKKKKk'{color[0]}.oOPPb.{color[1]}'0k.{color[0]} cKO. {results[6]}
|
|
{color[0]} :KK{color[1]}KKKKKKKKKKKKKKK: {color[0]}kKx..dd{color[1]} lKd{color[0]} 'OK: {results[7]}
|
|
{color[0]} dKK{color[1]}KKKKKKKKKOx0KKKd {color[0]}^0KKKO'{color[1]} kKKc{color[0]} dKd {results[8]}
|
|
{color[0]} dKK{color[1]}KKKKKKKKKK;.;oOKx,..{color[0]}^{color[1]}..;kKKK0.{color[0]} dKd {results[9]}
|
|
{color[0]} :KK{color[1]}KKKKKKKKKK0o;...^cdxxOK0O/^^'{color[0]} .0K: {results[10]}
|
|
{color[0]} kKK{color[1]}KKKKKKKKKKKKK0x;,,......,;od{color[0]} lKk {results[11]}
|
|
{color[0]} '0K{color[1]}KKKKKKKKKKKKKKKKKKKK00KKOo^{color[0]} c00' {results[12]}
|
|
{color[0]} 'kK{color[1]}KKOxddxkOO00000Okxoc;''{color[0]} .dKk' {results[13]}
|
|
{color[0]} l0Ko. .c00l' {results[14]}
|
|
{color[0]} 'l0Kk:. .;xK0l' {results[15]}
|
|
{color[0]} 'lkK0xl:;,,,,;:ldO0kl' {results[16]}
|
|
{color[0]} '^:ldxkkkkxdl:^' {results[17]}
|
|
""",
|
|
'LinuxMint': """
|
|
{color[1]} {results[0]}
|
|
{color[1]} MMMMMMMMMMMMMMMMMMMMMMMMMmds+. {results[1]}
|
|
{color[1]} MMm----::-://////////////oymNMd+` {results[2]}
|
|
{color[1]} MMd {color[0]}/++ {color[1]}-sNMd: {results[3]}
|
|
{color[1]} MMNso/` {color[0]}dMM `.::-. .-::.` {color[1]}.hMN: {results[4]}
|
|
{color[1]} ddddMMh {color[0]}dMM :hNMNMNhNMNMNh: `{color[1]}NMm {results[5]}
|
|
{color[1]} NMm {color[0]}dMM .NMN/-+MMM+-/NMN` {color[1]}dMM {results[6]}
|
|
{color[1]} NMm {color[0]}dMM -MMm `MMM dMM. {color[1]}dMM {results[7]}
|
|
{color[1]} NMm {color[0]}dMM -MMm `MMM dMM. {color[1]}dMM {results[8]}
|
|
{color[1]} NMm {color[0]}dMM .mmd `mmm yMM. {color[1]}dMM {results[9]}
|
|
{color[1]} NMm {color[0]}dMM` ..` ... ydm. {color[1]}dMM {results[10]}
|
|
{color[1]} hMM- {color[0]}+MMd/-------...-:sdds {color[1]}MMM {results[11]}
|
|
{color[1]} -NMm- {color[0]}:hNMNNNmdddddddddy/` {color[1]}dMM {results[12]}
|
|
{color[1]} -dMNs-``{color[0]}-::::-------.`` {color[1]}dMM {results[13]}
|
|
{color[1]} `/dMNmy+/:-------------:/yMMM {results[14]}
|
|
{color[1]} ./ydNMMMMMMMMMMMMMMMMMMMMM {results[15]}
|
|
{color[1]} {results[16]}
|
|
{color[1]} {results[17]}
|
|
""",
|
|
'Red Hat': """
|
|
{color[2]} {results[0]}
|
|
{color[2]} \`.-..........\` {results[1]}
|
|
{color[2]} \`////////::.\`-/. {results[2]}
|
|
{color[2]} -: ....-////////. {results[3]}
|
|
{color[2]} //:-::///////////\` {results[4]}
|
|
{color[2]} \`--::: \`-://////////////: {results[5]}
|
|
{color[2]} //////- \`\`.-:///////// .\` {results[6]}
|
|
{color[2]} \`://////:-.\` :///////::///:\` {results[7]}
|
|
{color[2]} .-/////////:---/////////////: {results[8]}
|
|
{color[2]} .-://////////////////////. {results[9]}
|
|
{color[0]} yMN+\`.-${color[2]}::///////////////-\` {results[10]}
|
|
{color[0]} .-\`:NMMNMs\` \`..-------..\` {results[11]}
|
|
{color[0]} MN+/mMMMMMhoooyysshsss {results[12]}
|
|
{color[0]} MMM MMMMMMMMMMMMMMyyddMMM+ {results[13]}
|
|
{color[0]} MMMM MMMMMMMMMMMMMNdyNMMh\` hyhMMM {results[14]}
|
|
{color[0]} MMMMMMMMMMMMMMMMyoNNNMMM+. MMMMMMMM {results[15]}
|
|
{color[0]} MMNMMMNNMMMMMNM+ mhsMNyyyyMNMMMMsMM {results[16]}
|
|
{color[0]} {results[17]}
|
|
""",
|
|
'Linux': """
|
|
{color[1]} {results[0]}
|
|
{color[1]} a8888b. {results[1]}
|
|
{color[1]} d888888b. {results[2]}
|
|
{color[1]} 8P"YP"Y88 {results[3]}
|
|
{color[1]} 8|o||o|88 {results[4]}
|
|
{color[1]} 8{color[0]}\\vvvv/{color[1]}88 {results[5]}
|
|
{color[1]} 8{color[0]} \\vv/ {color[1]}Y8. {results[6]}
|
|
{color[1]} d/ {color[0]}`'{color[1]} \8b. {results[7]}
|
|
{color[1]} .dP . Y8b. {results[8]}
|
|
{color[1]} d8:' " `::88b. {results[9]}
|
|
{color[1]} d8" `Y88b {results[10]}
|
|
{color[1]} :8P ' :888 {results[11]}
|
|
{color[1]} 8a. : _a88P {results[12]}
|
|
{color[1]} {color[0]}._/"{color[1]}Yaa_ : .{color[0]}| {color[1]}88P{color[0]}|{color[1]} {results[13]}
|
|
{color[1]} {color[0]}\++++{color[1]}YP" `{color[0]}| {color[1]}8P{color[0]}++\.{color[1]} {results[14]}
|
|
{color[1]} {color[0]}/+++++\.{color[1]}_____.d{color[0]}|+++++/{color[1]} {results[15]}
|
|
{color[1]} {color[0]}\++++++){color[1]}888888P{color[0]}\+++/{color[1]} {results[16]}
|
|
{color[1]} {results[17]}
|
|
"""
|
|
}
|
|
|
|
processes = str(check_output(('ps', '-u', str(getuid()), '-o', 'comm', '--no-headers')), encoding='utf-8').rstrip('\n').split('\n')
|
|
|
|
|
|
# -------------- Classes -------------- #
|
|
|
|
class Output:
|
|
def __init__(self):
|
|
self.results = []
|
|
self.distribution = Popen(['lsb_release', '-i', '-s'], stdout=PIPE).communicate()[0].decode('utf-8').rstrip('\n')
|
|
|
|
if self.distribution not in logosDict.keys():
|
|
self.distribution = 'Linux'
|
|
|
|
def append(self, key, value):
|
|
self.results.append('{0}{1}:{2} {3}'.format(colorDict[self.distribution][1], key, colorDict['Clear'][0], value))
|
|
|
|
def output(self):
|
|
results = []
|
|
results.extend([''] * floor((18 - len(self.results)) / 2))
|
|
results.extend(self.results[:])
|
|
|
|
if len(results) < 18:
|
|
results.extend([''] * (18 - len(results)))
|
|
|
|
print(logosDict[self.distribution].format(color=colorDict[self.distribution], results=results))
|
|
|
|
|
|
class User:
|
|
def __init__(self):
|
|
self.value = getenv('USER')
|
|
|
|
|
|
class Hostname:
|
|
def __init__(self):
|
|
self.value = Popen(['uname', '-n'], stdout=PIPE).communicate()[0].decode('utf-8').rstrip('\n')
|
|
|
|
|
|
class Model:
|
|
def __init__(self):
|
|
with open('/sys/devices/virtual/dmi/id/product_name') as file:
|
|
model = file.read().rstrip('\n')
|
|
file.close()
|
|
|
|
self.value = model
|
|
|
|
|
|
class Distro:
|
|
def __init__(self):
|
|
self.value = Popen(['lsb_release', '-d', '-s'], stdout=PIPE).communicate()[0].decode('utf-8').rstrip('\n') + ' ' + Popen(['uname', '-m'], stdout=PIPE).communicate()[0].decode('utf-8').rstrip('\n')
|
|
|
|
|
|
class Kernel:
|
|
def __init__(self):
|
|
self.value = Popen(['uname', '-r'], stdout=PIPE).communicate()[0].decode('utf-8').rstrip('\n')
|
|
|
|
|
|
class Uptime:
|
|
def __init__(self):
|
|
with open('/proc/uptime') as file:
|
|
fuptime = int(file.read().split('.')[0])
|
|
file.close()
|
|
|
|
day = int(fuptime / 86400)
|
|
fuptime = fuptime % 86400
|
|
hour = int(fuptime / 3600)
|
|
fuptime = fuptime % 3600
|
|
minute = int(fuptime / 60)
|
|
|
|
uptime = ''
|
|
uptime += ((str(day) + ' day' + ('s' if day > 1 else '') + ('' if minute == 0 and hour == 0 else (' and ' if (minute != 0 and hour == 0) or (minute == 0 and hour != 0) else ', '))) if day >= 1 else '')
|
|
uptime += ((str(hour) + ' hour' + ('s' if hour > 1 else '') + (' and ' if minute != 0 else '')) if hour >= 1 else '')
|
|
uptime += ((str(minute) + ' minute' + ('s' if minute > 1 else '')) if minute >= 1 else ('< 1 minute' if day == 0 and hour == 0 else ''))
|
|
|
|
self.value = uptime
|
|
|
|
|
|
class WindowManager:
|
|
def __init__(self):
|
|
wm = 'None'
|
|
|
|
try:
|
|
wm = re.search('(?<=Name: ).*', Popen(['wmctrl', '-m'], stdout=PIPE).communicate()[0].decode('utf-8')).group(0)
|
|
|
|
except FileNotFoundError:
|
|
for key in wmDict.keys():
|
|
if key in processes:
|
|
wm = wmDict[key]
|
|
break
|
|
|
|
self.value = wm
|
|
|
|
|
|
class DesktopEnvironment:
|
|
def __init__(self):
|
|
de = 'None'
|
|
for key in deDict.keys():
|
|
if key in processes:
|
|
de = deDict[key]
|
|
break
|
|
|
|
self.value = de
|
|
|
|
|
|
class Shell:
|
|
def __init__(self):
|
|
self.value = getenv('SHELL')
|
|
|
|
|
|
class Terminal:
|
|
def __init__(self):
|
|
self.value = getenv('TERM')
|
|
|
|
|
|
class Packages:
|
|
def __init__(self):
|
|
packagesTools = [['pacman', '-Q'], ['dnf', 'list', 'installed'], ['dpkg', '--list'], ['zypper', 'search', '--installed-only'], ['emerge', '-ep', 'world']]
|
|
for packagesTool in packagesTools:
|
|
try:
|
|
p1 = Popen(packagesTool, stdout=PIPE).communicate()[0].decode('utf-8')
|
|
break
|
|
|
|
except:
|
|
pass
|
|
|
|
self.value = len(p1.rstrip('\n').split('\n'))
|
|
|
|
|
|
class CPU:
|
|
def __init__(self):
|
|
with open('/proc/cpuinfo') as file:
|
|
cpuinfo = re.sub(' +', ' ', file.readlines()[4].replace('model name\t: ', '').rstrip('\n'))
|
|
file.close()
|
|
|
|
self.value = cpuinfo
|
|
|
|
|
|
class GPU:
|
|
def __init__(self):
|
|
gpuinfo = Popen(['grep', '-E', 'VGA|3D'], stdout=PIPE, stdin=Popen(['lspci'], stdout=PIPE).stdout).communicate()[0].decode('utf-8').split(': ')[1].rstrip('\n')
|
|
|
|
self.value = (re.findall('.{1,37}(?:\W|$)', gpuinfo)[0] + '[...]' if len(gpuinfo) > 40 else gpuinfo)
|
|
|
|
|
|
class RAM:
|
|
def __init__(self):
|
|
try:
|
|
ram = ''.join(filter(re.compile('M').search, Popen(['free', '-mw'], stdout=PIPE, env={'LANG': 'C'}).communicate()[0].decode('utf-8').split('\n'))).split()
|
|
used = ram[2]
|
|
total = ram[1]
|
|
usedpercent = (float(used) / float(total)) * 100
|
|
|
|
except IndexError:
|
|
with open('/proc/meminfo') as file:
|
|
ram = file.read().split('\n')
|
|
file.close()
|
|
total = float(ram[0].split(':')[1].strip(' ').rstrip(' kB')) / 1024
|
|
used = total - ((float(ram[1].split(':')[1].strip(' ').rstrip(' kB')) + float(ram[3].split(':')[1].strip(' ').rstrip(' kB')) + float(ram[4].split(':')[1].strip(' ').rstrip(' kB')) + float(ram[22].split(':')[1].strip(' ').rstrip(' kB'))) / 1024)
|
|
usedpercent = (float(used) / float(total)) * 100
|
|
|
|
self.value = '{0}{1} MB{2} / {3} MB'.format(colorDict['Sensors'][1 if usedpercent <= 33 else (0 if usedpercent >= 67 else 2)], int(used), colorDict['Clear'][0], int(total))
|
|
|
|
|
|
class Disk:
|
|
def __init__(self):
|
|
p1 = Popen(['df', '-Tlh', '-B', 'GB', '--total', '-t', 'ext4', '-t', 'ext3', '-t', 'ext2', '-t', 'reiserfs', '-t', 'jfs', '-t', 'ntfs', '-t', 'fat32', '-t', 'btrfs', '-t', 'fuseblk', '-t', 'xfs', '-t', 'simfs', '-t', 'tmpfs', '-t', 'zfs'], stdout=PIPE).communicate()[0].decode('utf-8')
|
|
total = re.sub(',', '.', p1.splitlines()[-1]).split()
|
|
usedpercent = float(total[5][:-1])
|
|
|
|
self.value = '{0}{1}{2} / {3}'.format(colorDict['Sensors'][1 if usedpercent <= 33 else (0 if usedpercent >= 67 else 2)], re.sub('GB', ' GB', total[3]), colorDict['Clear'][0], re.sub('GB', ' GB', total[2]))
|
|
|
|
|
|
classes = OrderedDict([
|
|
('User', User),
|
|
('Hostname', Hostname),
|
|
('Model', Model),
|
|
('Distro', Distro),
|
|
('Kernel', Kernel),
|
|
('Uptime', Uptime),
|
|
('WindowManager', WindowManager),
|
|
('DesktopEnvironment', DesktopEnvironment),
|
|
('Shell', Shell),
|
|
('Terminal', Terminal),
|
|
('Packages', Packages),
|
|
('CPU', CPU),
|
|
('GPU', GPU),
|
|
('RAM', RAM),
|
|
('Disk', Disk)
|
|
])
|
|
|
|
|
|
# -------------- Main -------------- #
|
|
|
|
if __name__ == '__main__':
|
|
|
|
output = Output()
|
|
for key in classes.keys():
|
|
output.append(key, classes[key]().value)
|
|
output.output()
|