Skip to content

Commit 93cea83

Browse files
committed
Fixed brew and changed default ssh keygen comment to username@host
1 parent c9144a1 commit 93cea83

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
lines changed

.github/workflows/brew.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929
brew --version
3030
brew config
3131
32+
- name: Install Python 3.13
33+
run: |
34+
brew install python@3.13
35+
python3 --version
36+
brew --prefix python@3.13
37+
3238
- name: Style check
3339
run: |
3440
brew style ./Formula/ssh-studio.rb

Formula/ssh-studio.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ def install
3131
ENV.prepend_path "PATH", libexec/"bin"
3232

3333
python3 = Formula["python@3.13"]
34-
python_bin = python3.opt_bin/"python3"
35-
36-
odie "Python 3.13 not found at #{python_bin}" unless python_bin.exist?
34+
python_bin = if (python3.opt_bin/"python3").exist?
35+
python3.opt_bin/"python3"
36+
elsif (python3.installed_prefix/"bin/python3").exist?
37+
python3.installed_prefix/"bin/python3"
38+
else
39+
prefix = `brew --prefix python@3.13`.strip
40+
Pathname.new("#{prefix}/bin/python3") if prefix && !prefix.empty?
41+
end
42+
43+
odie "Python 3.13 not found. Please ensure python@3.13 is installed: brew install python@3.13" unless python_bin&.exist?
3744

3845
ENV["PYTHON"] = python_bin.to_s
3946
system "meson", "setup", "build", *std_meson_args

data/ui/generate_key_dialog.blp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ template $GenerateKeyDialog: Adw.Dialog {
3434
}
3535
Adw.EntryRow comment_row {
3636
title: _("Comment");
37-
text: "ssh-studio";
3837
}
3938
Adw.PasswordEntryRow pass_row {
4039
title: _("Passphrase");

src/ui/generate_key_dialog.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from gi.repository import Gtk, Adw
66
from gettext import gettext as _
77

8+
try:
9+
from ssh_studio.utils import get_default_ssh_key_comment
10+
except ImportError:
11+
from utils import get_default_ssh_key_comment
12+
813

914
@Gtk.Template(
1015
resource_path="/io/github/BuddySirJava/SSH-Studio/ui/generate_key_dialog.ui"
@@ -28,6 +33,8 @@ def __init__(self, parent):
2833
self._populate_sizes()
2934
self._sync_size_visibility()
3035
self.type_row.connect("notify::selected-item", self._on_type_changed)
36+
default_comment = get_default_ssh_key_comment()
37+
self.comment_row.set_text(default_comment)
3138

3239
def _populate_types(self):
3340
store = Gtk.StringList.new(["ed25519", "rsa", "ecdsa"])
@@ -69,7 +76,7 @@ def get_options(self):
6976
else 2048
7077
)
7178
name = self.name_row.get_text() or "id_ed25519"
72-
comment = self.comment_row.get_text() or "ssh-studio"
79+
comment = self.comment_row.get_text() or get_default_ssh_key_comment()
7380
passphrase = self.pass_row.get_text() or ""
7481
return {
7582
"type": key_type,

src/ui/host_editor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import os
1717

1818
try:
19-
from ssh_studio.utils import copy_text_to_clipboard
19+
from ssh_studio.utils import copy_text_to_clipboard, get_default_ssh_key_comment
2020
except ImportError:
21-
from utils import copy_text_to_clipboard
21+
from utils import copy_text_to_clipboard, get_default_ssh_key_comment
2222

2323

2424
@Gtk.Template(resource_path="/io/github/BuddySirJava/SSH-Studio/ui/host_editor.ui")
@@ -1276,7 +1276,7 @@ def after_gen(*__):
12761276
name = f"{base}_{i}"
12771277
key_path = ssh_dir / name
12781278
key_type = (opts.get("type") or "ed25519").lower()
1279-
comment = opts.get("comment") or "ssh-studio"
1279+
comment = opts.get("comment") or get_default_ssh_key_comment()
12801280
passphrase = opts.get("passphrase") or ""
12811281
if key_type == "rsa":
12821282
size = int(opts.get("size") or 2048)

src/ui/ssh_key_manager_dialog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import subprocess
99

1010
try:
11-
from ssh_studio.utils import copy_text_to_clipboard
11+
from ssh_studio.utils import copy_text_to_clipboard, get_default_ssh_key_comment
1212
except ImportError:
13-
from utils import copy_text_to_clipboard
13+
from utils import copy_text_to_clipboard, get_default_ssh_key_comment
1414

1515

1616
@Gtk.Template(
@@ -264,7 +264,7 @@ def _generate_key_with_options(self, opts: dict):
264264
name = f"{base_name}_{j}"
265265
key_path = self._home_ssh / name
266266
key_type = (opts.get("type") or "ed25519").lower()
267-
comment = opts.get("comment") or "ssh-studio"
267+
comment = opts.get("comment") or get_default_ssh_key_comment()
268268
passphrase = opts.get("passphrase") or ""
269269
if key_type == "rsa":
270270
size = int(opts.get("size") or 2048)

src/utils.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import gi
2+
import os
3+
import socket
4+
import getpass
25

36
gi.require_version("Gtk", "4.0")
47
from gi.repository import Gdk, GLib
58
import subprocess
69

710

811
def copy_text_to_clipboard(text: str) -> bool:
9-
"""
10-
Copies the provided text to the clipboard using multiple backends.
11-
Tries GDK clipboard first, then falls back to command line tools.
12-
"""
1312
try:
1413
display = Gdk.Display.get_default()
1514
if not display:
@@ -66,3 +65,20 @@ def copy_text_to_clipboard(text: str) -> bool:
6665
except Exception:
6766
pass
6867
return False
68+
69+
70+
def get_default_ssh_key_comment() -> str:
71+
try:
72+
username = getpass.getuser()
73+
except Exception:
74+
try:
75+
username = os.getlogin()
76+
except Exception:
77+
username = os.environ.get("USER") or os.environ.get("USERNAME") or "user"
78+
79+
try:
80+
hostname = socket.gethostname()
81+
except Exception:
82+
hostname = "localhost"
83+
84+
return f"{username}@{hostname}"

0 commit comments

Comments
 (0)