This commit is contained in:
Ezri Brimhall 2024-04-08 14:56:26 -06:00
parent b8d92c9d3c
commit 97441f275b
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
5 changed files with 59 additions and 23 deletions

View File

@ -212,9 +212,30 @@ def format_time(time: datetime) -> dict[str, str | int]:
# dbus_interface = dbus.Interface(dbus_object, "org.freedesktop.network1.Link")
# yield dbus_interface
last_default_route = None
last_ip_data = None
last_request = None
runtime_dir = os.environ.get("XDG_RUNTIME_DIR", "/tmp")
def load_last_data(var_name: str):
try:
if os.path.exists(f"{runtime_dir}/{var_name}.json"):
with open(f"{runtime_dir}/{var_name}.json", "r") as f:
return json.load(f), os.path.getmtime(f"{runtime_dir}/{var_name}.json")
except:
pass
return None, None
def store_last_data(var_name: str, data):
with open(f"{runtime_dir}/{var_name}.json", "w") as f:
json.dump(data, f)
last_default_route = load_last_data("default_route")[0]
last_ip_data, last_request = load_last_data("ip_data")
try:
last_first_hop = IPAddress(load_last_data("first_hop")[0])
except:
last_first_hop = None
while True:
@ -243,9 +264,13 @@ while True:
public_ip_data = None
else:
last_ip_data = public_ip_data
# Write the public IP data to a file
store_last_data("ip_data", public_ip_data)
last_default_route = default_route
store_last_data("default_route", default_route)
last_request = now()
last_first_hop = hop
store_last_data("first_hop", str(hop))
else:
public_ip_data = last_ip_data
if hop is not None:

View File

@ -16,7 +16,8 @@
{
"index": 8,
"name": "slack",
"exec": "slack -s",
"exec": "slack",
"args": ["-a"],
"program_name": "slack",
"memory_profile": {
"high": "800M",
@ -44,27 +45,24 @@
{
"index": 4,
"name": "project",
"exec": "firefox",
"exec": "firefox-beta",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
},
"environ": {},
"program_name": "firefox"
},
{
"index": 3,
"name": "internet",
"exec": "firefox",
"exec": "firefox-beta",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
},
"environ": {},
"program_name": "firefox"
},
{
"index": 2,
"name": "code",
"exec": "emacsclient -nc",
"exec": "emacsclient",
"args": ["-nc"],
"program_name": "emacsclient"
},
{
@ -91,21 +89,17 @@
{
"index": 13,
"name": "internet",
"exec": "firefox",
"exec": "firefox-beta",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
},
"environ": {},
"program_name": "firefox"
},
{
"index": 14,
"name": "project",
"exec": "firefox",
"exec": "firefox-beta",
"args": ["--new-window"],
"environ": {
"MOZ_ENABLE_WAYLAND": "0"
},
"environ": {},
"program_name": "firefox"
},
{

View File

@ -7,7 +7,7 @@ PartOf=graphical-session.target
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Environment=SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh
Environment=ASDF_DATA_DIR=/home/ezri/.local/share/asdf-vm
Restart=on-failure
Slice=session.slice

View File

@ -46,3 +46,14 @@ function ssh-clean() {
ssh -O exit -S $i -q _ 2>/dev/null
done
}
function lsssh() {
# List active ssh connections
for i in $(find ~/.ssh/cm/ -type s); do
fname=$(basename $i)
conn=$(echo $fname | cut -d- -f2-)
user=$(echo $conn | cut -d@ -f1)
host=$(echo $conn | cut -d@ -f2 | cut -d: -f1)
echo "$user@$host"
done
}

View File

@ -511,3 +511,9 @@ After installing the ~rust-analyzer~ program, the following can be used:
("C-c C-b" . obsidian-backlink-jump)
("C-c C-l" . obsidian-insert-wikilink)))
#+END_SRC
* TRAMP Customization
#+BEGIN_SRC emacs-lisp
(add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
(add-to-list 'tramp-default-proxies-alist (quote ((,(regexp-quote (system-name)) "\\`root\\'" nil))))
#+END_SRC