Skip to content

Commit 3abeab2

Browse files
committed
mise à jour de l'application
1 parent 8c3f73e commit 3abeab2

File tree

16 files changed

+782
-152
lines changed

16 files changed

+782
-152
lines changed

.github/workflows/build-ui.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ jobs:
3131
# choose separator for add-data
3232
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then SEP=';'; else SEP=':'; fi
3333
python -m PyInstaller --name ok_computer_ui-${{ matrix.os }} --onefile \
34+
--noconsole \
3435
--add-data "ui/templates${SEP}templates" \
3536
--add-data "ui/static${SEP}static" \
3637
--collect-submodules flask \
3738
--hidden-import socket \
39+
--hidden-import webview \
40+
--hidden-import webview.platforms.cocoa \
41+
--hidden-import webview.platforms.winforms \
3842
ui/app.py
3943
shell: bash
4044

src/import_installed.sh

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Colors for output
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
BLUE='\033[0;34m'
9+
NC='\033[0m' # No Color
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
13+
# Load .env.local if available
14+
if [ -f "${SCRIPT_DIR}/../.env.local" ]; then
15+
# shellcheck disable=SC1091
16+
source "${SCRIPT_DIR}/../.env.local"
17+
fi
18+
19+
# Determine path to packages.conf file
20+
if [ -n "${PACKAGES_CONF_DIR:-}" ] && [ -f "${PACKAGES_CONF_DIR}/packages.conf" ]; then
21+
PACKAGES_CONF="${PACKAGES_CONF_DIR}/packages.conf"
22+
elif [ -f "${SCRIPT_DIR}/packages.conf" ]; then
23+
PACKAGES_CONF="${SCRIPT_DIR}/packages.conf"
24+
else
25+
PACKAGES_CONF="${SCRIPT_DIR}/packages.conf.example"
26+
fi
27+
28+
echo -e "${BLUE}Using config file:${NC} ${PACKAGES_CONF}"
29+
30+
# Check availability functions (simplified versions of app.sh)
31+
check_homebrew_api() {
32+
local app=$1
33+
local type=$2
34+
35+
if [ "$type" = "cask" ]; then
36+
curl -s -f -o /dev/null "https://formulae.brew.sh/api/cask/${app}.json"
37+
else
38+
curl -s -f -o /dev/null "https://formulae.brew.sh/api/formula/${app}.json"
39+
fi
40+
}
41+
42+
check_chocolatey_api() {
43+
local app=$1
44+
curl -s -f "https://community.chocolatey.org/api/v2/Packages()?%24filter=tolower(Id)%20eq%20tolower('${app}')" | grep -q "${app}"
45+
}
46+
47+
# Detect operating system
48+
OS="$(uname -s)"
49+
case "${OS}" in
50+
Darwin*) MACHINE=Mac;;
51+
CYGWIN*|MINGW*|MSYS*) MACHINE=Windows;;
52+
*) MACHINE=Linux;;
53+
esac
54+
55+
echo -e "${BLUE}Detected System:${NC} ${MACHINE}"
56+
57+
# Function to check if package exists in config
58+
package_exists_in_config() {
59+
local name=$1
60+
if [ ! -f "$PACKAGES_CONF" ]; then
61+
return 1
62+
fi
63+
# Check if name appears in column 2 (Mac) or 3 (Win)
64+
# Format: TYPE|MAC|WIN|DESC
65+
if grep -qE "^[^|]+\|${name}\|" "$PACKAGES_CONF" || grep -qE "^[^|]+\|[^|]+\|${name}\|" "$PACKAGES_CONF"; then
66+
return 0
67+
fi
68+
return 1
69+
}
70+
71+
count=0
72+
73+
process_package() {
74+
local name="$1"
75+
local type="$2"
76+
local origin="$3"
77+
78+
if package_exists_in_config "$name"; then
79+
# echo "Skipping $name (already configured)"
80+
return
81+
fi
82+
83+
echo -e "${GREEN}Found new package:${NC} $name ($type)"
84+
85+
local mac_name="-"
86+
local win_name="-"
87+
local desc="Imported from $origin"
88+
89+
if [ "$MACHINE" = "Mac" ]; then
90+
mac_name="$name"
91+
# Try to find match on Windows
92+
echo -n " Checking duplicate on Windows... "
93+
if check_chocolatey_api "$name"; then
94+
win_name="$name"
95+
echo "found ($name)"
96+
else
97+
echo "not found"
98+
fi
99+
elif [ "$MACHINE" = "Windows" ]; then
100+
win_name="$name"
101+
# Try to find match on Mac
102+
echo -n " Checking duplicate on macOS... "
103+
if check_homebrew_api "$name" "cask"; then
104+
mac_name="$name"
105+
type="cask"
106+
echo "found (cask)"
107+
elif check_homebrew_api "$name" "brew"; then
108+
mac_name="$name"
109+
if [ "$type" != "cask" ]; then type="brew"; fi
110+
echo "found (brew)"
111+
else
112+
echo "not found"
113+
fi
114+
fi
115+
116+
echo "${type}|${mac_name}|${win_name}|${desc}" >> "$PACKAGES_CONF"
117+
((count++))
118+
}
119+
120+
if [ "$MACHINE" = "Mac" ]; then
121+
if command -v brew &>/dev/null; then
122+
echo -e "\n${BLUE}Searching Homebrew Formulas...${NC}"
123+
# using leaves to avoid dependencies
124+
for pkg in $(brew leaves); do
125+
process_package "$pkg" "brew" "macOS"
126+
done
127+
128+
echo -e "\n${BLUE}Searching Homebrew Casks...${NC}"
129+
for pkg in $(brew list --cask); do
130+
process_package "$pkg" "cask" "macOS"
131+
done
132+
fi
133+
134+
if command -v mas &>/dev/null; then
135+
echo -e "\n${BLUE}Searching Mac App Store...${NC}"
136+
# mas list output: "123456 App Name"
137+
# But config format is usually brew|mas|-|Desc ??
138+
# Actually existing config has 'brew|mas|-|Mac App Store CLI' which refers to the mas tool itself.
139+
# ok_computer doesn't seem to have explicit 'mas' generic support in install logic yet?
140+
# src/init_conf_macOs.sh usually handles 'mas' lines.
141+
# Let's verify src/init_conf_macOs.sh logic.
142+
# Assuming format 'mas|app_id|name|desc' or 'type|mac_name|...' where mac_name is id?
143+
# Let's stick to brew/cask for now to be safe unless we verify mas support.
144+
# Skipping 'mas' for now to avoid breaking config with IDs.
145+
echo "Skipping MAS apps (auto-import not fully supported yet)"
146+
fi
147+
148+
elif [ "$MACHINE" = "Windows" ]; then
149+
if command -v choco &>/dev/null; then
150+
echo -e "\n${BLUE}Searching Chocolatey packages...${NC}"
151+
# choco list -lo -r returns "name|version"
152+
# use -r for pipe delimited
153+
choco list --local-only --limit-output | while IFS='|' read -r name ver; do
154+
# Filter out chocolatey itself or common lib packages?
155+
if [ "$name" = "chocolatey" ]; then continue; fi
156+
157+
# Heuristic for type: default to brew (CLI) or cask (GUI)?
158+
# Hard to know. Let's assume 'cask' for everything on Windows default as usually people install tools.
159+
# OR check if it exists as a cask on mac?
160+
process_package "$name" "brew" "Windows"
161+
done
162+
else
163+
echo "Chocolatey not found."
164+
fi
165+
else
166+
echo "Linux import not implemented yet."
167+
fi
168+
169+
echo -e "\n${GREEN}Done!${NC} Added $count new packages to $PACKAGES_CONF"

src/wifi_from_keychain.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,18 @@ add_entry_to_kp() {
8888
log "[dry-run] would add entry: ${ssid}"
8989
return 0
9090
fi
91-
# Attempt to add entry: keepassxc-cli add DB GROUP TITLE --username "" --password "..."
92-
# If a key file is provided, pass --key-file
91+
92+
# Construct the command array
93+
local cmd=(keepassxc-cli add "${DB_FILE}" "${GROUP}" "${ssid}" --username "" --password "${pw}" --comment "imported from macOS keychain")
9394
if [ -n "${KEY_FILE}" ]; then
94-
keepassxc-cli add --key-file "${KEY_FILE}" "${DB_FILE}" "${GROUP}" "${ssid}" --username "" --password "${pw}" --comment "imported from macOS keychain"
95+
cmd=(keepassxc-cli add --key-file "${KEY_FILE}" "${DB_FILE}" "${GROUP}" "${ssid}" --username "" --password "${pw}" --comment "imported from macOS keychain")
96+
fi
97+
98+
# Execute with password pipe if KEEPASS_DB_PASS is set, otherwise interactive
99+
if [ -n "${KEEPASS_DB_PASS:-}" ]; then
100+
echo "${KEEPASS_DB_PASS}" | "${cmd[@]}"
95101
else
96-
keepassxc-cli add "${DB_FILE}" "${GROUP}" "${ssid}" --username "" --password "${pw}" --comment "imported from macOS keychain"
102+
"${cmd[@]}"
97103
fi
98104
}
99105

ui/README.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)