From 71c4458858165aa98506bd144f1a7a156f367717 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 30 Mar 2020 18:13:32 +0200 Subject: [PATCH 01/15] not needed --- pwnagotchi/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py index 3c0dbc6..aca62a6 100644 --- a/pwnagotchi/__init__.py +++ b/pwnagotchi/__init__.py @@ -66,8 +66,6 @@ def mem_usage(): kb_mem_total = int(line.split()[1]) if line.startswith("MemFree:"): kb_mem_free = int(line.split()[1]) - if line.startswith("MemAvailable:"): - kb_mem_available = int(line.split()[1]) if line.startswith("Buffers:"): kb_main_buffers = int(line.split()[1]) if line.startswith("Cached:"): From 4aa05bb83429a6a8d40ade68af7d2f959e67d637 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 30 Mar 2020 18:14:04 +0200 Subject: [PATCH 02/15] /proc/stat contains the cpu ticks since boot --- pwnagotchi/__init__.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py index aca62a6..185312a 100644 --- a/pwnagotchi/__init__.py +++ b/pwnagotchi/__init__.py @@ -76,18 +76,27 @@ def mem_usage(): return 0 -def cpu_load(): +def _cpu_stat(): + """ + Returns the splitted first line of the /proc/stat file + """ with open('/proc/stat', 'rt') as fp: - for line in fp: - line = line.strip() - if line.startswith('cpu '): - parts = list(map(int, line.split()[1:])) - user_n = parts[0] - sys_n = parts[2] - idle_n = parts[3] - tot = user_n + sys_n + idle_n - return (user_n + sys_n) / tot - return 0 + return list(map(int,fp.readline().split()[1:])) + + +def cpu_load(): + """ + Returns the current cpuload + """ + parts0 = _cpu_stat() + time.sleep(0.1) + parts1 = _cpu_stat() + parts_diff = [p1 - p0 for (p0, p1) in zip(parts0, parts1)] + user, nice, sys, idle, iowait, irq, softirq, steal, _guest, _guest_nice = parts_diff + idle_sum = idle + iowait + non_idle_sum = user + nice + sys + irq + softirq + steal + total = idle_sum + non_idle_sum + return non_idle_sum / total def temperature(celsius=True): From 76b71f5c3f63b9a4b7ea42ac2a43cd0fab779907 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 30 Mar 2020 18:30:02 +0200 Subject: [PATCH 03/15] fixes import error --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d2ec1d4..a3b31f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ spidev==3.4 gast==0.2.2 flask==1.0.2 flask-cors==3.0.7 -flask-wtf==0.14.2 +flask-wtf==0.14.3 dbus-python==1.2.12 toml==0.10.0 python-dateutil==2.8.1 From 9a22321799a7dfe53ea679522582e6722c8264bb Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 1 Apr 2020 08:17:22 +0200 Subject: [PATCH 04/15] save in dotted format --- bin/pwnagotchi | 4 ++- pwnagotchi/__init__.py | 1 + pwnagotchi/plugins/__init__.py | 11 ++++++++- pwnagotchi/plugins/default/webcfg.py | 9 +++---- pwnagotchi/utils.py | 37 ++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 5b93d3f..0b547ec 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -17,6 +17,7 @@ from pwnagotchi.agent import Agent from pwnagotchi.ui.display import Display from pwnagotchi import restart from pwnagotchi import fs +from pwnagotchi.utils import DottedTomlEncoder def do_clear(display): @@ -122,9 +123,10 @@ if __name__ == '__main__': config = utils.load_config(args) if args.print_config: - print(toml.dumps(config)) + print(toml.dumps(config, encoder=DottedTomlEncoder())) sys.exit(0) + pwnagotchi.config = config fs.setup_mounts(config) log.setup_logging(args, config) diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py index 185312a..58e7702 100644 --- a/pwnagotchi/__init__.py +++ b/pwnagotchi/__init__.py @@ -10,6 +10,7 @@ from pwnagotchi import fs from pwnagotchi._version import __version__ _name = None +config = None def set_name(new_name): diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index c8a70c6..5c2a662 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -5,6 +5,9 @@ import threading import importlib, importlib.util import logging from pwnagotchi.ui import view +from pwnagotchi import config +from pwnagotchi.utils import save_config + default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default") loaded = {} @@ -36,11 +39,17 @@ def toggle_plugin(name, enable=True): returns True if changed, otherwise False """ - global loaded, database + global loaded, database, config + + if config: + config['main']['plugins'][name] = enable + save_config(config, '/etc/pwnagotchi/config.toml') + if not enable and name in loaded: if getattr(loaded[name], 'on_unload', None): loaded[name].on_unload(view.ROOT) del loaded[name] + return True if enable and name in database and name not in loaded: diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index d870953..ba79078 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -2,8 +2,8 @@ import logging import json import toml import _thread -import pwnagotchi.plugins as plugins -from pwnagotchi import restart +from pwnagotchi import restart, plugins +from pwnagotchi.utils import save_config from flask import abort from flask import render_template_string @@ -500,9 +500,8 @@ class WebConfig(plugins.Plugin): if path == "save-config": try: parsed_toml = toml.loads(request.get_json()) - with open('/etc/pwnagotchi/config.toml') as config_file: - toml.dump(parsed_toml, config_file) - + save_config(parsed_toml, '/etc/pwnagotchi/config.toml') + _thread.start_new_thread(restart, (self.mode,)) return "success" except Exception as ex: diff --git a/pwnagotchi/utils.py b/pwnagotchi/utils.py index 17bd79f..92a42e0 100644 --- a/pwnagotchi/utils.py +++ b/pwnagotchi/utils.py @@ -10,11 +10,43 @@ import json import shutil import toml import sys +import re import pwnagotchi +from toml.encoder import TomlEncoder, _dump_str from pwnagotchi.fs import ensure_write +class DottedTomlEncoder(TomlEncoder): + """ + Dumps the toml into the dotted-key format + """ + + def __init__(self, _dict=dict): + super(DottedTomlEncoder, self).__init__(_dict) + + def dump_sections(self, o, sup): + retstr = "" + pre = "" + + if sup: + pre = sup + "." + + for section, value in o.items(): + section = str(section) + qsection = section + if not re.match(r'^[A-Za-z0-9_-]+$', section): + qsection = _dump_str(section) + if value is not None: + if isinstance(value, dict): + toadd, _ = self.dump_sections(value, pre + qsection) + retstr += toadd + else: + retstr += (pre + qsection + " = " + + str(self.dump_value(value)) + '\n') + return (retstr, self._dict()) + + # https://stackoverflow.com/questions/823196/yaml-merge-in-python def merge_config(user, default): if isinstance(user, dict) and isinstance(default, dict): @@ -44,6 +76,11 @@ def keys_to_str(data): return converted_dict +def save_config(config, target): + with open(target, 'wt') as fp: + fp.write(toml.dumps(config, encoder=DottedTomlEncoder())) + return True + def load_config(args): default_config_path = os.path.dirname(args.config) if not os.path.exists(default_config_path): From d10bf6bf1ddbf87ea3674ff5574ec04bb15c767c Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 1 Apr 2020 09:40:22 +0200 Subject: [PATCH 05/15] we dont want this in the repo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 58560b2..c32c48e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ dist pwnagotchi.egg-info *backup*.tgz *backup*.gz +.vscode From 03c014f41406c981122b2bb1d677da08336d5a50 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 1 Apr 2020 18:20:12 +0200 Subject: [PATCH 06/15] fix webcfg --- pwnagotchi/plugins/default/webcfg.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index ba79078..c8f1e04 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -499,12 +499,11 @@ class WebConfig(plugins.Plugin): elif request.method == "POST": if path == "save-config": try: - parsed_toml = toml.loads(request.get_json()) + parsed_toml = json.loads(request.get_json()) save_config(parsed_toml, '/etc/pwnagotchi/config.toml') - _thread.start_new_thread(restart, (self.mode,)) return "success" except Exception as ex: logging.error(ex) - return "config error" + return "config error", 500 abort(404) From 9a1565813cc113a7bef963026abc8a38e438ceb8 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 1 Apr 2020 18:21:12 +0200 Subject: [PATCH 07/15] cant import --- pwnagotchi/plugins/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 5c2a662..6616be6 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -4,8 +4,8 @@ import _thread import threading import importlib, importlib.util import logging +import pwnagotchi from pwnagotchi.ui import view -from pwnagotchi import config from pwnagotchi.utils import save_config @@ -39,11 +39,11 @@ def toggle_plugin(name, enable=True): returns True if changed, otherwise False """ - global loaded, database, config + global loaded, database - if config: - config['main']['plugins'][name] = enable - save_config(config, '/etc/pwnagotchi/config.toml') + if pwnagotchi.config: + pwnagotchi.config['main']['plugins'][name]['enabled'] = enable + save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml') if not enable and name in loaded: if getattr(loaded[name], 'on_unload', None): From 60167fb8fe3ca1febef22d6257436b63d196db79 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 1 Apr 2020 18:21:44 +0200 Subject: [PATCH 08/15] use latest version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a3b31f5..bd8d63f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ pycryptodome==3.9.4 requests==2.21.0 -PyYAML==5.1 +PyYAML==5.3.1 scapy==2.4.3 gym==0.14.0 scipy==1.3.1 From 54ffbbcb0b143d90e5f750d3b59b63adb0a223c8 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 18:08:30 +0200 Subject: [PATCH 09/15] used @k0uj1k's translation --- pwnagotchi/locale/jp/LC_MESSAGES/voice.mo | Bin 3708 -> 5657 bytes pwnagotchi/locale/jp/LC_MESSAGES/voice.po | 145 ++++++++++++++-------- 2 files changed, 92 insertions(+), 53 deletions(-) diff --git a/pwnagotchi/locale/jp/LC_MESSAGES/voice.mo b/pwnagotchi/locale/jp/LC_MESSAGES/voice.mo index 2ff6027b53b8d9356b6d4ece30b93f7ff048d582..536f891a10c2359da90c2c4a12ac4589cebf4a7d 100644 GIT binary patch literal 5657 zcmbW3ZHyG<9l%GlwcXlU(Y~mCdA8IS3VYlkSU6Bbp?Vb*0c$i(&D`$X?RdL0mz`Oz z%jJ@rT~rVd6agtBrO4YM(E0}D&6wDvjcHBO4}LJVHqY&G*EY3Z{Lq&){r#Vry*){= zO(#41n`h>E{?Gq?=J%5?*=lht;`|Ed{7IH&!|z|hAIJNju&htRKf*7-Kf|f;qEA}Z z7vVJcO?W$$_1*9@a1E6Co8jl-e)x5G9DWtP17-e)a1NY&sbwj6H@p%S;AA)mMa~xZ zS$GJ32_8@QHoS`QIe0nz7vyJM_NjQ^tKdn-*TL)I`%vUwiczBfHBiQFP~<FvUxp7R z&r4ADTL)8c50rgggtE_Rn1*jcnKuH(u75)XuVv9RI3L~!^HA)63W`0)pxAo`%DUe| z1^)^~zsqr^@OminZ-FxZes~RZq3E*)vc!4@UI%x>i{UTe74TQ^bMReA2(3Rs3Gv^O z@rRI5SpS4#*QCqhaSF=#3MhWM8j76h@V<*IYaUdLH)4$NC~Svs!)sxR$+y7k;SDec z#lIVp@jm!9#=nMb@Gns8{TfEK!r5>k?1JBb2cgJ)E8#hqW_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&MALk!{z436`JRdoUM-{bcowH&TtuAmEj~}x~&VV^&^uDS76bpg^N`R00nkjMb%$n zztVwy7i4%`20v4N!V4|5Ha()8x<Dd=5uA@6Rtpi<ncCI!^CMTF1lpwk#)=(_)oSfJ z5=fGk&LIZUzaWF)u4P0?FVv?{7h@{KII0b&n4ogzU!R0BdQ+)rqiC%j+|b3*(6>zB zf30aB>SxZ?ufBy$E}TXAHEOS!gXl9%&b{_iC44CeQ7yqBs^CUlBCCu3>)1bcdtxc2 z{$z}$qn&f_-dG$(@K4Rn{;1(uqt;b%{_kyz)liu-Nlr%w)@I&ph60YUg-dTEyedBz z=YCP0zj=ykmFoD43}>U$(m$!L2HguC4BVNhL?L<ZHj;}HJppqU>HeT}mGkOe>NDXb z8IF>~P~Fl-HkM07nxN+l<+5>uWH>`-R$f@BB!6T$BEu;q5?2m3>sz<%%ssysbMGFn zk4@3dm_`L()Aiy{*C(orm*1dN(W<U&)CcUwbFpc$G8HpN)tx-1uWz#qYVUo2DH6-? z0)1%ci-2zps_FCxvno5yfHvhv0@araTcZphvdwQ@INSJRr>@KdOdOX1Zh(4MCuFs% n|JP`_d#N$5PO$oTfV4GG8$QaY&rhFH{T?<%cIrQhD+=vDte$zc diff --git a/pwnagotchi/locale/jp/LC_MESSAGES/voice.po b/pwnagotchi/locale/jp/LC_MESSAGES/voice.po index 52acd38..efaabc4 100644 --- a/pwnagotchi/locale/jp/LC_MESSAGES/voice.po +++ b/pwnagotchi/locale/jp/LC_MESSAGES/voice.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR 24534649+wytshadow@users.noreply.github.com, 2019. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-10-16 15:05+0200\n" +"POT-Creation-Date: 2020-01-25 21:57+0900\n" "PO-Revision-Date: 2019-10-16 15:05+0200\n" "Last-Translator: wytshadow <24534649+wytshadow@users.noreply.github.com>\n" "Language-Team: pwnagotchi <24534649+wytshadow@users.noreply.github.com>\n" @@ -21,170 +20,207 @@ msgid "ZzzzZZzzzzZzzz" msgstr "すやすや〜" msgid "Hi, I'm Pwnagotchi! Starting ..." -msgstr "こんにちは、ポウナゴッチです!始めている。。。" +msgstr "僕、 ポーナゴッチです!" msgid "New day, new hunt, new pwns!" -msgstr "" +msgstr "ポーンしようよ。" msgid "Hack the Planet!" msgstr "ハックザプラネット!" msgid "AI ready." -msgstr "人工知能の準備ができました。" +msgstr "AIの準備ができました。" msgid "The neural network is ready." -msgstr "ニューラルネットワークの準備ができました。" +msgstr "ニューラルネットワークの\n準備ができました。" + +msgid "Generating keys, do not turn off ..." +msgstr "鍵生成をしてます。\n電源を落とさないでね。" #, python-brace-format msgid "Hey, channel {channel} is free! Your AP will say thanks." -msgstr "ねえ、チャンネル{channel}は無料です! キミのAPは感謝を言います。" +msgstr "チャンネル\n {channel} \nはfreeだよ。ありがとうね。" + +msgid "Reading last session logs ..." +msgstr "session log を読んでます。" + +#, python-brace-format +msgid "Read {lines_so_far} log lines so far ..." +msgstr "{lines_so_far} 行目長いよぉ。" msgid "I'm bored ..." -msgstr "退屈です。。。" +msgstr "退屈だぁ。。。" msgid "Let's go for a walk!" -msgstr "散歩に行きましょう!" +msgstr "散歩に行こうよ!" msgid "This is the best day of my life!" -msgstr "今日は私の人生で最高の日です!" +msgstr "人生最高の日だよ!" msgid "Shitty day :/" -msgstr "" +msgstr "がっかりな日だよ。orz" msgid "I'm extremely bored ..." -msgstr "とても退屈です。" +msgstr "退屈だね。" msgid "I'm very sad ..." -msgstr "とても悲しいです。。。" +msgstr "あ~悲しいよぉ。" msgid "I'm sad" -msgstr "悲しいです。" +msgstr "悲しいね。" + +msgid "Leave me alone ..." +msgstr "ひとりぼっちだよ。" + +msgid "I'm mad at you!" +msgstr "怒っちゃうよ。" msgid "I'm living the life!" -msgstr "人生を生きている!" +msgstr "わくわくするね。" msgid "I pwn therefore I am." -msgstr "" +msgstr "ポーンしてこそのオレ。" msgid "So many networks!!!" -msgstr "たくさんネットワークがある!!!" +msgstr "たくさん\nWiFiが飛んでるよ!" msgid "I'm having so much fun!" -msgstr "とても楽しんでいます!" +msgstr "楽しいよぉ!" msgid "My crime is that of curiosity ..." -msgstr "" +msgstr "APに興味津々..." #, python-brace-format -msgid "Hello {name}! Nice to meet you. {name}" -msgstr "こんにちは{name}!初めまして。{name}" +msgid "Hello {name}! Nice to meet you." +msgstr "こんにちは{name}!\n初めまして。{name}" #, python-brace-format -msgid "Unit {name} is nearby! {name}" -msgstr "" +msgid "Yo {name}! Sup?" +msgstr "ねぇねぇ、\n{name} どうしたの?" + +#, python-brace-format +msgid "Hey {name} how are you doing?" +msgstr "{name} こんにちは" + +#, python-brace-format +msgid "Unit {name} is nearby!" +msgstr "{name} が近くにいるよ。" #, python-brace-format msgid "Uhm ... goodbye {name}" -msgstr "ええと。。。さようなら{name}" +msgstr "じゃあね、さようなら {name}" #, python-brace-format msgid "{name} is gone ..." -msgstr "{name}がなくなった。。。" +msgstr "{name}\nがいなくなったよ。" #, python-brace-format msgid "Whoops ... {name} is gone." -msgstr "おっと。。。{name}がなくなった。" +msgstr "あらら、\n{name}\nがいなくなったね。" #, python-brace-format msgid "{name} missed!" -msgstr "{name}逃した!" +msgstr "{name} が逃げた!" msgid "Missed!" -msgstr "逃した!" +msgstr "残念、逃した!" + +msgid "Good friends are a blessing!" +msgstr "良い仲間にめぐりあえたよ。" + +msgid "I love my friends!" +msgstr "友達は大好きだよ。" msgid "Nobody wants to play with me ..." -msgstr "誰も僕と一緒にプレーしたくない。。。" +msgstr "誰も僕と一緒に\nあそんでくれない。" msgid "I feel so alone ..." -msgstr "僕は孤独を感じる。。。" +msgstr "ひとりぼっちだよ。" msgid "Where's everybody?!" -msgstr "みんなどこ?!" +msgstr "みんなどこにいるの?!" #, python-brace-format msgid "Napping for {secs}s ..." -msgstr "{secs}寝ている。" +msgstr "{secs}秒 寝ます。" msgid "Zzzzz" -msgstr "すや〜" +msgstr "ぐぅ〜" #, python-brace-format msgid "ZzzZzzz ({secs}s)" -msgstr "すやすや〜 ({secs})" +msgstr "すやすや〜 ({secs}秒)" msgid "Good night." -msgstr "お休みなさい。" +msgstr "おやすみなさい。" msgid "Zzz" -msgstr "す〜" +msgstr "ぐぅ~" #, python-brace-format msgid "Waiting for {secs}s ..." -msgstr "{secs}を待っている。。。" +msgstr "{secs}秒 待ちです。" #, python-brace-format msgid "Looking around ({secs}s)" -msgstr "{secs}を探している。" +msgstr "{secs}秒 探してます。" #, python-brace-format msgid "Hey {what} let's be friends!" -msgstr "ちょっと{what}友だちになりましょう!" +msgstr "ねぇねぇ\n{what} \n友だちになろうよ。" #, python-brace-format msgid "Associating to {what}" -msgstr "" +msgstr "{what} \nとつながるかな?" #, python-brace-format msgid "Yo {what}!" -msgstr "よー{what}!" +msgstr "ねぇねぇ\n{what}" #, python-brace-format msgid "Just decided that {mac} needs no WiFi!" -msgstr "" +msgstr "{mac}\nはWiFiじゃないのね。" #, python-brace-format msgid "Deauthenticating {mac}" -msgstr "" +msgstr "{mac}\nの認証取得中..." #, python-brace-format msgid "Kickbanning {mac}!" -msgstr "" +msgstr "{mac}\nに拒否られた。" #, python-brace-format msgid "Cool, we got {num} new handshake{plural}!" -msgstr "よし、{num}新しいハンドシェイクがある!" +msgstr "おぉ、\n{num}回\nハンドシェイクがあったよ!" -msgid "Oops, something went wrong ... Rebooting ..." -msgstr "おっと!何かが間違っていた。。。リブートしている。。。" +#, python-brace-format +msgid "You have {count} new message{plural}!" +msgstr "おぉ、\n{count}個メッセージがあるよ!" + +msgid "Ops, something went wrong ... Rebooting ..." +msgstr "何か間違った。\nリブートしている。" #, python-brace-format msgid "Kicked {num} stations\n" -msgstr "" +msgstr "{num}回拒否された。\n" + +msgid "Made >999 new friends\n" +msgstr "1000人以上友達ができた。\n" #, python-brace-format msgid "Made {num} new friends\n" -msgstr "{num}人の新しい友達を作りました\n" +msgstr "{num}人友達ができた。\n" #, python-brace-format msgid "Got {num} handshakes\n" -msgstr "{num}ハンドシェイクがある。\n" +msgstr "{num}回ハンドシェイクした。\n" msgid "Met 1 peer" -msgstr "1人の仲間を会いました。" +msgstr "1人 仲間に会いました。" #, python-brace-format msgid "Met {num} peers" -msgstr "{num}人の仲間を会いました。" +msgstr "{num}人 仲間に会いました。" #, python-brace-format msgid "" @@ -192,6 +228,9 @@ msgid "" "{associated} new friends and ate {handshakes} handshakes! #pwnagotchi " "#pwnlog #pwnlife #hacktheplanet #skynet" msgstr "" +"{duration}中{deauted}のAPに拒否されたけど、{associated}回チャンスがあって" +"{handshakes}回ハンドシェイクがあったよ。。 #pownagotchi #pwnlog #pwnlife " +"#hacktheplanet #skynet" msgid "hours" msgstr "時間" @@ -203,7 +242,7 @@ msgid "seconds" msgstr "秒" msgid "hour" -msgstr "時間" +msgstr "時" msgid "minute" msgstr "分" From 305f837486dbe875d015cf5b5d264118d8240490 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 19:06:28 +0200 Subject: [PATCH 10/15] more fonts --- bin/pwnagotchi | 2 ++ builder/pwnagotchi.yml | 1 + pwnagotchi/defaults.toml | 1 + pwnagotchi/ui/fonts.py | 44 +++++++++++++++++++--------- pwnagotchi/ui/hw/dfrobot.py | 2 +- pwnagotchi/ui/hw/inky.py | 2 +- pwnagotchi/ui/hw/lcdhat.py | 2 +- pwnagotchi/ui/hw/oledhat.py | 2 +- pwnagotchi/ui/hw/papirus.py | 2 +- pwnagotchi/ui/hw/spotpear24inch.py | 2 +- pwnagotchi/ui/hw/waveshare1.py | 4 +-- pwnagotchi/ui/hw/waveshare144lcd.py | 2 +- pwnagotchi/ui/hw/waveshare154inch.py | 2 +- pwnagotchi/ui/hw/waveshare2.py | 4 +-- pwnagotchi/ui/hw/waveshare213bc.py | 2 +- pwnagotchi/ui/hw/waveshare213d.py | 2 +- pwnagotchi/ui/hw/waveshare27inch.py | 2 +- pwnagotchi/ui/hw/waveshare29inch.py | 2 +- 18 files changed, 50 insertions(+), 30 deletions(-) diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 0b547ec..6e3ab4a 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -14,6 +14,7 @@ from pwnagotchi import plugins from pwnagotchi import log from pwnagotchi.identity import KeyPair from pwnagotchi.agent import Agent +from pwnagotchi.ui import fonts from pwnagotchi.ui.display import Display from pwnagotchi import restart from pwnagotchi import fs @@ -129,6 +130,7 @@ if __name__ == '__main__': pwnagotchi.config = config fs.setup_mounts(config) log.setup_logging(args, config) + fonts.init(config) pwnagotchi.set_name(config['main']['name']) diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml index 8dd1379..b821632 100644 --- a/builder/pwnagotchi.yml +++ b/builder/pwnagotchi.yml @@ -104,6 +104,7 @@ - python3-flask - python3-flask-cors - python3-flaskext.wtf + - fonts-ipaexfont-gothic tasks: - name: change hostname diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml index a3e058e..3b1f24b 100644 --- a/pwnagotchi/defaults.toml +++ b/pwnagotchi/defaults.toml @@ -148,6 +148,7 @@ personality.sad_num_epochs = 25 personality.bond_encounters_factor = 20000 ui.fps = 0.0 +ui.font = "DejaVuSansMono" # for japanese: fonts-japanese-gothic ui.faces.look_r = "( ⚆_⚆)" ui.faces.look_l = "(☉_☉ )" diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py index ca616d3..9b44f92 100644 --- a/pwnagotchi/ui/fonts.py +++ b/pwnagotchi/ui/fonts.py @@ -1,18 +1,34 @@ from PIL import ImageFont -PATH = '/usr/share/fonts/truetype/dejavu/DejaVuSansMono' - -Bold = ImageFont.truetype("%s-Bold.ttf" % PATH, 10) -BoldSmall = ImageFont.truetype("%s-Bold.ttf" % PATH, 8) -BoldBig = ImageFont.truetype("%s-Bold.ttf" % PATH, 25) -Medium = ImageFont.truetype("%s.ttf" % PATH, 10) -Small = ImageFont.truetype("%s.ttf" % PATH, 9) -Huge = ImageFont.truetype("%s-Bold.ttf" % PATH, 25) +FONT_NAME = None +Bold = None +BoldSmall = None +BoldBig = None +Medium = None +Small = None +Huge = None -def setup(bold, bold_small, medium, huge): - global PATH, Bold, BoldSmall, Medium, Huge - Bold = ImageFont.truetype("%s-Bold.ttf" % PATH, bold) - BoldSmall = ImageFont.truetype("%s-Bold.ttf" % PATH, bold_small) - Medium = ImageFont.truetype("%s.ttf" % PATH, medium) - Huge = ImageFont.truetype("%s-Bold.ttf" % PATH, huge) +def init(config): + global FONT_NAME + FONT_NAME = config['ui']['font'] + setup(10, 8, 10, 25, 25, 9) + + +def setup(bold, bold_small, medium, huge, bold_big, small): + global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME + + Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small) + Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium) + + try: + BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small) + Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold) + BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big) + Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge) + except OSError: + BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small) + Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold) + BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big) + Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge) + diff --git a/pwnagotchi/ui/hw/dfrobot.py b/pwnagotchi/ui/hw/dfrobot.py index b79c7fa..756e727 100644 --- a/pwnagotchi/ui/hw/dfrobot.py +++ b/pwnagotchi/ui/hw/dfrobot.py @@ -9,7 +9,7 @@ class DFRobot(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 250 self._layout['height'] = 122 self._layout['face'] = (0, 40) diff --git a/pwnagotchi/ui/hw/inky.py b/pwnagotchi/ui/hw/inky.py index 7ae3327..afa6de5 100644 --- a/pwnagotchi/ui/hw/inky.py +++ b/pwnagotchi/ui/hw/inky.py @@ -10,7 +10,7 @@ class Inky(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 8, 10, 28) + fonts.setup(10, 8, 10, 28, 25, 9) self._layout['width'] = 212 self._layout['height'] = 104 self._layout['face'] = (0, 37) diff --git a/pwnagotchi/ui/hw/lcdhat.py b/pwnagotchi/ui/hw/lcdhat.py index 92e45a7..9170a2a 100644 --- a/pwnagotchi/ui/hw/lcdhat.py +++ b/pwnagotchi/ui/hw/lcdhat.py @@ -10,7 +10,7 @@ class LcdHat(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 240 self._layout['height'] = 240 self._layout['face'] = (0, 40) diff --git a/pwnagotchi/ui/hw/oledhat.py b/pwnagotchi/ui/hw/oledhat.py index 3673630..6386d58 100644 --- a/pwnagotchi/ui/hw/oledhat.py +++ b/pwnagotchi/ui/hw/oledhat.py @@ -10,7 +10,7 @@ class OledHat(DisplayImpl): self._display = None def layout(self): - fonts.setup(8, 8, 8, 8) + fonts.setup(8, 8, 8, 8, 25, 9) self._layout['width'] = 128 self._layout['height'] = 64 self._layout['face'] = (0, 32) diff --git a/pwnagotchi/ui/hw/papirus.py b/pwnagotchi/ui/hw/papirus.py index 8da13be..aa3a297 100644 --- a/pwnagotchi/ui/hw/papirus.py +++ b/pwnagotchi/ui/hw/papirus.py @@ -11,7 +11,7 @@ class Papirus(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 8, 10, 23) + fonts.setup(10, 8, 10, 23, 25, 9) self._layout['width'] = 200 self._layout['height'] = 96 self._layout['face'] = (0, 24) diff --git a/pwnagotchi/ui/hw/spotpear24inch.py b/pwnagotchi/ui/hw/spotpear24inch.py index e93b071..b276d76 100644 --- a/pwnagotchi/ui/hw/spotpear24inch.py +++ b/pwnagotchi/ui/hw/spotpear24inch.py @@ -11,7 +11,7 @@ class Spotpear24inch(DisplayImpl): self._display = None def layout(self): - fonts.setup(12, 10, 12, 70) + fonts.setup(12, 10, 12, 70, 25, 9) self._layout['width'] = 320 self._layout['height'] = 240 self._layout['face'] = (35, 50) diff --git a/pwnagotchi/ui/hw/waveshare1.py b/pwnagotchi/ui/hw/waveshare1.py index 40ecc3f..ceff5cf 100644 --- a/pwnagotchi/ui/hw/waveshare1.py +++ b/pwnagotchi/ui/hw/waveshare1.py @@ -11,7 +11,7 @@ class WaveshareV1(DisplayImpl): def layout(self): if self.config['color'] == 'black': - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 250 self._layout['height'] = 122 self._layout['face'] = (0, 40) @@ -31,7 +31,7 @@ class WaveshareV1(DisplayImpl): 'max': 20 } else: - fonts.setup(10, 8, 10, 25) + fonts.setup(10, 8, 10, 25, 25, 9) self._layout['width'] = 212 self._layout['height'] = 104 self._layout['face'] = (0, 26) diff --git a/pwnagotchi/ui/hw/waveshare144lcd.py b/pwnagotchi/ui/hw/waveshare144lcd.py index d1d2044..79fc888 100644 --- a/pwnagotchi/ui/hw/waveshare144lcd.py +++ b/pwnagotchi/ui/hw/waveshare144lcd.py @@ -10,7 +10,7 @@ class Waveshare144lcd(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 8, 10, 18) + fonts.setup(10, 8, 10, 18, 25, 9) self._layout['width'] = 128 self._layout['height'] = 128 self._layout['face'] = (0, 43) diff --git a/pwnagotchi/ui/hw/waveshare154inch.py b/pwnagotchi/ui/hw/waveshare154inch.py index fc9cfa7..52c48f9 100644 --- a/pwnagotchi/ui/hw/waveshare154inch.py +++ b/pwnagotchi/ui/hw/waveshare154inch.py @@ -10,7 +10,7 @@ class Waveshare154inch(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 200 self._layout['height'] = 200 self._layout['face'] = (0, 40) diff --git a/pwnagotchi/ui/hw/waveshare2.py b/pwnagotchi/ui/hw/waveshare2.py index 5065f65..1b90c87 100644 --- a/pwnagotchi/ui/hw/waveshare2.py +++ b/pwnagotchi/ui/hw/waveshare2.py @@ -11,7 +11,7 @@ class WaveshareV2(DisplayImpl): def layout(self): if self.config['color'] == 'black': - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 250 self._layout['height'] = 122 self._layout['face'] = (0, 40) @@ -31,7 +31,7 @@ class WaveshareV2(DisplayImpl): 'max': 20 } else: - fonts.setup(10, 8, 10, 25) + fonts.setup(10, 8, 10, 25, 25, 9) self._layout['width'] = 212 self._layout['height'] = 104 self._layout['face'] = (0, 26) diff --git a/pwnagotchi/ui/hw/waveshare213bc.py b/pwnagotchi/ui/hw/waveshare213bc.py index 70309a8..cf5a912 100644 --- a/pwnagotchi/ui/hw/waveshare213bc.py +++ b/pwnagotchi/ui/hw/waveshare213bc.py @@ -10,7 +10,7 @@ class Waveshare213bc(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 8, 10, 25) + fonts.setup(10, 8, 10, 25, 25, 9) self._layout['width'] = 212 self._layout['height'] = 104 self._layout['face'] = (0, 26) diff --git a/pwnagotchi/ui/hw/waveshare213d.py b/pwnagotchi/ui/hw/waveshare213d.py index 9aa8ff8..7171c28 100644 --- a/pwnagotchi/ui/hw/waveshare213d.py +++ b/pwnagotchi/ui/hw/waveshare213d.py @@ -10,7 +10,7 @@ class Waveshare213d(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 8, 10, 25) + fonts.setup(10, 8, 10, 25, 25, 9) self._layout['width'] = 212 self._layout['height'] = 104 self._layout['face'] = (0, 26) diff --git a/pwnagotchi/ui/hw/waveshare27inch.py b/pwnagotchi/ui/hw/waveshare27inch.py index 0cbc168..30f76f3 100644 --- a/pwnagotchi/ui/hw/waveshare27inch.py +++ b/pwnagotchi/ui/hw/waveshare27inch.py @@ -10,7 +10,7 @@ class Waveshare27inch(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 264 self._layout['height'] = 176 self._layout['face'] = (66, 27) diff --git a/pwnagotchi/ui/hw/waveshare29inch.py b/pwnagotchi/ui/hw/waveshare29inch.py index cabbee9..31aac43 100644 --- a/pwnagotchi/ui/hw/waveshare29inch.py +++ b/pwnagotchi/ui/hw/waveshare29inch.py @@ -10,7 +10,7 @@ class Waveshare29inch(DisplayImpl): self._display = None def layout(self): - fonts.setup(10, 9, 10, 35) + fonts.setup(10, 9, 10, 35, 25, 9) self._layout['width'] = 296 self._layout['height'] = 128 self._layout['face'] = (0, 40) From 3b9aacdd161615a6faaf000690277a3cfae18249 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 19:24:52 +0200 Subject: [PATCH 11/15] faces use dejavu --- pwnagotchi/defaults.toml | 3 ++- pwnagotchi/ui/fonts.py | 35 ++++++++++++++++++++++------------- pwnagotchi/ui/view.py | 4 ++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml index 3b1f24b..3d5c69d 100644 --- a/pwnagotchi/defaults.toml +++ b/pwnagotchi/defaults.toml @@ -148,7 +148,8 @@ personality.sad_num_epochs = 25 personality.bond_encounters_factor = 20000 ui.fps = 0.0 -ui.font = "DejaVuSansMono" # for japanese: fonts-japanese-gothic +ui.font.name = "DejaVuSansMono" # for japanese: fonts-japanese-gothic +ui.font.size_offset = 0 # will be added to the font size ui.faces.look_r = "( ⚆_⚆)" ui.faces.look_l = "(☉_☉ )" diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py index 9b44f92..e362072 100644 --- a/pwnagotchi/ui/fonts.py +++ b/pwnagotchi/ui/fonts.py @@ -1,34 +1,43 @@ from PIL import ImageFont FONT_NAME = None +FONT_NAME_FACES = 'DejaVuSansMono' + +SIZE_OFFSET = 0 Bold = None BoldSmall = None BoldBig = None Medium = None Small = None Huge = None +FaceHuge = None +FaceBold = None def init(config): - global FONT_NAME - FONT_NAME = config['ui']['font'] + global FONT_NAME, SIZE_OFFSET + FONT_NAME = config['ui']['font']['name'] + SIZE_OFFSET = config['ui']['font']['size_offset'] setup(10, 8, 10, 25, 25, 9) def setup(bold, bold_small, medium, huge, bold_big, small): - global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME + global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, + FONT_NAME, SIZE_OFFSET - Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small) - Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium) + Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small + SIZE_OFFSET) + Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium, + SIZE_OFFSET) + FaceHuge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, huge) + FaceBold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, bold) try: - BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small) - Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold) - BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big) - Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge) + BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small + SIZE_OFFSET) + Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold + SIZE_OFFSET) + BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big + SIZE_OFFSET) + Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge + SIZE_OFFSET) except OSError: - BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small) - Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold) - BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big) - Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge) + BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small + SIZE_OFFSET) + Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold + SIZE_OFFSET) + BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big + SIZE_OFFSET) + Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge + SIZE_OFFSET) diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 974a968..bc7f191 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -54,9 +54,9 @@ class View(object): 'line1': Line(self._layout['line1'], color=BLACK), 'line2': Line(self._layout['line2'], color=BLACK), - 'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge), + 'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.FaceHuge), - 'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK), + 'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.FaceBold, color=BLACK), 'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall, color=BLACK), From 5bac678771af95fa4cda6763990bcd2ad8de9444 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 19:30:22 +0200 Subject: [PATCH 12/15] typo --- pwnagotchi/ui/fonts.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py index e362072..226856d 100644 --- a/pwnagotchi/ui/fonts.py +++ b/pwnagotchi/ui/fonts.py @@ -22,11 +22,10 @@ def init(config): def setup(bold, bold_small, medium, huge, bold_big, small): - global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, - FONT_NAME, SIZE_OFFSET + global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, FONT_NAME, FONT_NAME_FACES, SIZE_OFFSET Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small + SIZE_OFFSET) - Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium, + SIZE_OFFSET) + Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium + SIZE_OFFSET) FaceHuge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, huge) FaceBold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, bold) From 0dedd0974f5c22561f393acaed7715d218384867 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 20:10:07 +0200 Subject: [PATCH 13/15] update --- pwnagotchi/ui/fonts.py | 42 +++++++++++++--------------- pwnagotchi/ui/hw/base.py | 2 +- pwnagotchi/ui/hw/dfrobot.py | 4 +-- pwnagotchi/ui/hw/inky.py | 2 +- pwnagotchi/ui/hw/lcdhat.py | 2 +- pwnagotchi/ui/hw/oledhat.py | 2 +- pwnagotchi/ui/hw/papirus.py | 2 +- pwnagotchi/ui/hw/spotpear24inch.py | 2 +- pwnagotchi/ui/hw/waveshare1.py | 4 +-- pwnagotchi/ui/hw/waveshare144lcd.py | 2 +- pwnagotchi/ui/hw/waveshare154inch.py | 2 +- pwnagotchi/ui/hw/waveshare2.py | 4 +-- pwnagotchi/ui/hw/waveshare213bc.py | 2 +- pwnagotchi/ui/hw/waveshare213d.py | 2 +- pwnagotchi/ui/hw/waveshare27inch.py | 2 +- pwnagotchi/ui/hw/waveshare29inch.py | 2 +- pwnagotchi/ui/view.py | 4 +-- 17 files changed, 39 insertions(+), 43 deletions(-) diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py index 226856d..52263b2 100644 --- a/pwnagotchi/ui/fonts.py +++ b/pwnagotchi/ui/fonts.py @@ -1,42 +1,38 @@ from PIL import ImageFont -FONT_NAME = None -FONT_NAME_FACES = 'DejaVuSansMono' +# should not be changed +FONT_NAME = 'DejaVuSansMono' +# can be changed +STATUS_FONT_NAME = None SIZE_OFFSET = 0 + Bold = None BoldSmall = None BoldBig = None Medium = None Small = None Huge = None -FaceHuge = None -FaceBold = None def init(config): - global FONT_NAME, SIZE_OFFSET - FONT_NAME = config['ui']['font']['name'] + global STATUS_FONT_NAME, SIZE_OFFSET + STATUS_FONT_NAME = config['ui']['font']['name'] SIZE_OFFSET = config['ui']['font']['size_offset'] setup(10, 8, 10, 25, 25, 9) +def status_font(old_font): + global STATUS_FONT_NAME, SIZE_OFFSET + return old_font.font_variant(font=STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET) + + def setup(bold, bold_small, medium, huge, bold_big, small): - global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, FONT_NAME, FONT_NAME_FACES, SIZE_OFFSET - - Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small + SIZE_OFFSET) - Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium + SIZE_OFFSET) - FaceHuge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, huge) - FaceBold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, bold) - - try: - BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small + SIZE_OFFSET) - Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold + SIZE_OFFSET) - BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big + SIZE_OFFSET) - Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge + SIZE_OFFSET) - except OSError: - BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small + SIZE_OFFSET) - Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold + SIZE_OFFSET) - BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big + SIZE_OFFSET) - Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge + SIZE_OFFSET) + global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME + Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small) + Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium) + BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small) + Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold) + BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big) + Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge) diff --git a/pwnagotchi/ui/hw/base.py b/pwnagotchi/ui/hw/base.py index e3e0db0..72793b0 100644 --- a/pwnagotchi/ui/hw/base.py +++ b/pwnagotchi/ui/hw/base.py @@ -22,7 +22,7 @@ class DisplayImpl(object): # status is special :D 'status': { 'pos': (0, 0), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium), 'max': 20 } } diff --git a/pwnagotchi/ui/hw/dfrobot.py b/pwnagotchi/ui/hw/dfrobot.py index 756e727..1d9c8ee 100644 --- a/pwnagotchi/ui/hw/dfrobot.py +++ b/pwnagotchi/ui/hw/dfrobot.py @@ -25,7 +25,7 @@ class DFRobot(DisplayImpl): self._layout['mode'] = (225, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium), 'max': 20 } return self._layout @@ -40,4 +40,4 @@ class DFRobot(DisplayImpl): self._display.display(buf) def clear(self): - self._display.Clear(0xFF) \ No newline at end of file + self._display.Clear(0xFF) diff --git a/pwnagotchi/ui/hw/inky.py b/pwnagotchi/ui/hw/inky.py index afa6de5..bb02fd7 100644 --- a/pwnagotchi/ui/hw/inky.py +++ b/pwnagotchi/ui/hw/inky.py @@ -26,7 +26,7 @@ class Inky(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (102, 18), - 'font': fonts.Small, + 'font': fonts.status_font(fonts.Small), 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/lcdhat.py b/pwnagotchi/ui/hw/lcdhat.py index 9170a2a..1e76799 100644 --- a/pwnagotchi/ui/hw/lcdhat.py +++ b/pwnagotchi/ui/hw/lcdhat.py @@ -26,7 +26,7 @@ class LcdHat(DisplayImpl): self._layout['mode'] = (215, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium), 'max': 20 } diff --git a/pwnagotchi/ui/hw/oledhat.py b/pwnagotchi/ui/hw/oledhat.py index 6386d58..1e66a2a 100644 --- a/pwnagotchi/ui/hw/oledhat.py +++ b/pwnagotchi/ui/hw/oledhat.py @@ -26,7 +26,7 @@ class OledHat(DisplayImpl): self._layout['mode'] = (103, 10) self._layout['status'] = { 'pos': (30, 18), - 'font': fonts.Small, + 'font': fonts.status_font(fonts.Small), 'max': 18 } return self._layout diff --git a/pwnagotchi/ui/hw/papirus.py b/pwnagotchi/ui/hw/papirus.py index aa3a297..02004fe 100644 --- a/pwnagotchi/ui/hw/papirus.py +++ b/pwnagotchi/ui/hw/papirus.py @@ -27,7 +27,7 @@ class Papirus(DisplayImpl): self._layout['mode'] = (175, 86) self._layout['status'] = { 'pos': (85, 14), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 16 } return self._layout diff --git a/pwnagotchi/ui/hw/spotpear24inch.py b/pwnagotchi/ui/hw/spotpear24inch.py index b276d76..73f4b9b 100644 --- a/pwnagotchi/ui/hw/spotpear24inch.py +++ b/pwnagotchi/ui/hw/spotpear24inch.py @@ -27,7 +27,7 @@ class Spotpear24inch(DisplayImpl): self._layout['mode'] = (280, 220) self._layout['status'] = { 'pos': (80, 160), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium), 'max': 20 } diff --git a/pwnagotchi/ui/hw/waveshare1.py b/pwnagotchi/ui/hw/waveshare1.py index ceff5cf..e1f64b9 100644 --- a/pwnagotchi/ui/hw/waveshare1.py +++ b/pwnagotchi/ui/hw/waveshare1.py @@ -27,7 +27,7 @@ class WaveshareV1(DisplayImpl): self._layout['mode'] = (225, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } else: @@ -47,7 +47,7 @@ class WaveshareV1(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare144lcd.py b/pwnagotchi/ui/hw/waveshare144lcd.py index 79fc888..0cef5f2 100644 --- a/pwnagotchi/ui/hw/waveshare144lcd.py +++ b/pwnagotchi/ui/hw/waveshare144lcd.py @@ -26,7 +26,7 @@ class Waveshare144lcd(DisplayImpl): self._layout['mode'] = (0, 117) self._layout['status'] = { 'pos': (65, 26), - 'font': fonts.Small, + 'font': fonts.status_font(fonts.Small), 'max': 12 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare154inch.py b/pwnagotchi/ui/hw/waveshare154inch.py index 52c48f9..0ff5610 100644 --- a/pwnagotchi/ui/hw/waveshare154inch.py +++ b/pwnagotchi/ui/hw/waveshare154inch.py @@ -26,7 +26,7 @@ class Waveshare154inch(DisplayImpl): self._layout['mode'] = (170, 187) self._layout['status'] = { 'pos': (5, 90), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare2.py b/pwnagotchi/ui/hw/waveshare2.py index 1b90c87..3c2ad27 100644 --- a/pwnagotchi/ui/hw/waveshare2.py +++ b/pwnagotchi/ui/hw/waveshare2.py @@ -27,7 +27,7 @@ class WaveshareV2(DisplayImpl): self._layout['mode'] = (225, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } else: @@ -48,7 +48,7 @@ class WaveshareV2(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 14 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare213bc.py b/pwnagotchi/ui/hw/waveshare213bc.py index cf5a912..d44cac4 100644 --- a/pwnagotchi/ui/hw/waveshare213bc.py +++ b/pwnagotchi/ui/hw/waveshare213bc.py @@ -26,7 +26,7 @@ class Waveshare213bc(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare213d.py b/pwnagotchi/ui/hw/waveshare213d.py index 7171c28..a8e5d0f 100644 --- a/pwnagotchi/ui/hw/waveshare213d.py +++ b/pwnagotchi/ui/hw/waveshare213d.py @@ -26,7 +26,7 @@ class Waveshare213d(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare27inch.py b/pwnagotchi/ui/hw/waveshare27inch.py index 30f76f3..c3b04c5 100644 --- a/pwnagotchi/ui/hw/waveshare27inch.py +++ b/pwnagotchi/ui/hw/waveshare27inch.py @@ -26,7 +26,7 @@ class Waveshare27inch(DisplayImpl): self._layout['mode'] = (239, 163) self._layout['status'] = { 'pos': (38, 93), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 40 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare29inch.py b/pwnagotchi/ui/hw/waveshare29inch.py index 31aac43..c52e047 100644 --- a/pwnagotchi/ui/hw/waveshare29inch.py +++ b/pwnagotchi/ui/hw/waveshare29inch.py @@ -26,7 +26,7 @@ class Waveshare29inch(DisplayImpl): self._layout['mode'] = (268, 114) self._layout['status'] = { 'pos': (130, 25), - 'font': fonts.Medium, + 'font': fonts.status_font(fonts.Medium) 'max': 28 } return self._layout diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index bc7f191..974a968 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -54,9 +54,9 @@ class View(object): 'line1': Line(self._layout['line1'], color=BLACK), 'line2': Line(self._layout['line2'], color=BLACK), - 'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.FaceHuge), + 'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge), - 'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.FaceBold, color=BLACK), + 'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK), 'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall, color=BLACK), From 58bbae89c2ef37232bc9a2aa2b1e21f1bde8e156 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 22:59:51 +0200 Subject: [PATCH 14/15] fix some bugs --- pwnagotchi/plugins/default/webcfg.py | 3 +-- pwnagotchi/ui/fonts.py | 14 +++++++------- pwnagotchi/ui/hw/papirus.py | 2 +- pwnagotchi/ui/hw/waveshare1.py | 4 ++-- pwnagotchi/ui/hw/waveshare154inch.py | 2 +- pwnagotchi/ui/hw/waveshare2.py | 4 ++-- pwnagotchi/ui/hw/waveshare213bc.py | 2 +- pwnagotchi/ui/hw/waveshare213d.py | 2 +- pwnagotchi/ui/hw/waveshare27inch.py | 2 +- pwnagotchi/ui/hw/waveshare29inch.py | 2 +- 10 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index c8f1e04..3907283 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -499,8 +499,7 @@ class WebConfig(plugins.Plugin): elif request.method == "POST": if path == "save-config": try: - parsed_toml = json.loads(request.get_json()) - save_config(parsed_toml, '/etc/pwnagotchi/config.toml') + save_config(request.get_json(), '/etc/pwnagotchi/config.toml') _thread.start_new_thread(restart, (self.mode,)) return "success" except Exception as ex: diff --git a/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py index 52263b2..36f35ea 100644 --- a/pwnagotchi/ui/fonts.py +++ b/pwnagotchi/ui/fonts.py @@ -24,15 +24,15 @@ def init(config): def status_font(old_font): global STATUS_FONT_NAME, SIZE_OFFSET - return old_font.font_variant(font=STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET) + return ImageFont.truetype(STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET) def setup(bold, bold_small, medium, huge, bold_big, small): global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME - Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small) - Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium) - BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small) - Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold) - BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big) - Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge) + Small = ImageFont.truetype(FONT_NAME, small) + Medium = ImageFont.truetype(FONT_NAME, medium) + BoldSmall = ImageFont.truetype("%s-Bold" % FONT_NAME, bold_small) + Bold = ImageFont.truetype("%s-Bold" % FONT_NAME, bold) + BoldBig = ImageFont.truetype("%s-Bold" % FONT_NAME, bold_big) + Huge = ImageFont.truetype("%s-Bold" % FONT_NAME, huge) diff --git a/pwnagotchi/ui/hw/papirus.py b/pwnagotchi/ui/hw/papirus.py index 02004fe..44d0500 100644 --- a/pwnagotchi/ui/hw/papirus.py +++ b/pwnagotchi/ui/hw/papirus.py @@ -27,7 +27,7 @@ class Papirus(DisplayImpl): self._layout['mode'] = (175, 86) self._layout['status'] = { 'pos': (85, 14), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 16 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare1.py b/pwnagotchi/ui/hw/waveshare1.py index e1f64b9..4716fc4 100644 --- a/pwnagotchi/ui/hw/waveshare1.py +++ b/pwnagotchi/ui/hw/waveshare1.py @@ -27,7 +27,7 @@ class WaveshareV1(DisplayImpl): self._layout['mode'] = (225, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } else: @@ -47,7 +47,7 @@ class WaveshareV1(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare154inch.py b/pwnagotchi/ui/hw/waveshare154inch.py index 0ff5610..a678121 100644 --- a/pwnagotchi/ui/hw/waveshare154inch.py +++ b/pwnagotchi/ui/hw/waveshare154inch.py @@ -26,7 +26,7 @@ class Waveshare154inch(DisplayImpl): self._layout['mode'] = (170, 187) self._layout['status'] = { 'pos': (5, 90), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare2.py b/pwnagotchi/ui/hw/waveshare2.py index 3c2ad27..fa00aaf 100644 --- a/pwnagotchi/ui/hw/waveshare2.py +++ b/pwnagotchi/ui/hw/waveshare2.py @@ -27,7 +27,7 @@ class WaveshareV2(DisplayImpl): self._layout['mode'] = (225, 109) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } else: @@ -48,7 +48,7 @@ class WaveshareV2(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (125, 20), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 14 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare213bc.py b/pwnagotchi/ui/hw/waveshare213bc.py index d44cac4..f889c9b 100644 --- a/pwnagotchi/ui/hw/waveshare213bc.py +++ b/pwnagotchi/ui/hw/waveshare213bc.py @@ -26,7 +26,7 @@ class Waveshare213bc(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare213d.py b/pwnagotchi/ui/hw/waveshare213d.py index a8e5d0f..0313081 100644 --- a/pwnagotchi/ui/hw/waveshare213d.py +++ b/pwnagotchi/ui/hw/waveshare213d.py @@ -26,7 +26,7 @@ class Waveshare213d(DisplayImpl): self._layout['mode'] = (187, 93) self._layout['status'] = { 'pos': (91, 15), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 20 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare27inch.py b/pwnagotchi/ui/hw/waveshare27inch.py index c3b04c5..29fbbbe 100644 --- a/pwnagotchi/ui/hw/waveshare27inch.py +++ b/pwnagotchi/ui/hw/waveshare27inch.py @@ -26,7 +26,7 @@ class Waveshare27inch(DisplayImpl): self._layout['mode'] = (239, 163) self._layout['status'] = { 'pos': (38, 93), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 40 } return self._layout diff --git a/pwnagotchi/ui/hw/waveshare29inch.py b/pwnagotchi/ui/hw/waveshare29inch.py index c52e047..2ae2b5a 100644 --- a/pwnagotchi/ui/hw/waveshare29inch.py +++ b/pwnagotchi/ui/hw/waveshare29inch.py @@ -26,7 +26,7 @@ class Waveshare29inch(DisplayImpl): self._layout['mode'] = (268, 114) self._layout['status'] = { 'pos': (130, 25), - 'font': fonts.status_font(fonts.Medium) + 'font': fonts.status_font(fonts.Medium), 'max': 28 } return self._layout From d39c849dafc202fa7a0bf57578afeeafe61bccb7 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Thu, 2 Apr 2020 23:06:39 +0200 Subject: [PATCH 15/15] github? you ok? --- pwnagotchi/plugins/default/webcfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index 3907283..4bf0538 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -499,7 +499,7 @@ class WebConfig(plugins.Plugin): elif request.method == "POST": if path == "save-config": try: - save_config(request.get_json(), '/etc/pwnagotchi/config.toml') + save_config(request.get_json(), '/etc/pwnagotchi/config.toml') # test _thread.start_new_thread(restart, (self.mode,)) return "success" except Exception as ex: