From 1b7ce2fc5303157b85557d0b2df472787604f768 Mon Sep 17 00:00:00 2001
From: janinainfa <60750633+janinainfa@users.noreply.github.com>
Date: Tue, 9 Jul 2024 17:13:19 +0200
Subject: [PATCH] fixed (I hope) config handle
---
.idea/workspace.xml | 26 +++++++++++--------
.../config.ini => create_config.py | 19 ++++++++++++--
deb-package/DEBIAN/postint | 20 --------------
main.py | 6 +++++
4 files changed, 38 insertions(+), 33 deletions(-)
rename deb-package/home/user/mexassistant/config.ini => create_config.py (62%)
delete mode 100644 deb-package/DEBIAN/postint
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7323744..85779be 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,11 @@
-
+
+
+
+
+
@@ -13,8 +17,8 @@
@@ -156,14 +160,6 @@
1716649644053
-
-
- 1716675752607
-
-
-
- 1716675752607
-
1716703226467
@@ -548,7 +544,15 @@
1720535984740
-
+
+
+ 1720536373622
+
+
+
+ 1720536373622
+
+
diff --git a/deb-package/home/user/mexassistant/config.ini b/create_config.py
similarity index 62%
rename from deb-package/home/user/mexassistant/config.ini
rename to create_config.py
index 0600f09..4f847a0 100644
--- a/deb-package/home/user/mexassistant/config.ini
+++ b/create_config.py
@@ -1,4 +1,9 @@
-[DEFAULT]
+import os
+
+homeDir = os.path.expanduser("~")
+
+
+configContent = '''[DEFAULT]
voice_lang = pl-PL
[otwórz terminal]
@@ -29,5 +34,15 @@
[następna piosenka]
type = terminal
-command = playerctl next
+command = playerctl next'''
+
+def createConfig():
+ try:
+ os.mkdir(homeDir + "/mexassistant")
+ except:
+ pass
+ finally:
+ with open(homeDir + "/mexassistant/config.ini", 'w') as f:
+ f.write(configContent)
+
diff --git a/deb-package/DEBIAN/postint b/deb-package/DEBIAN/postint
deleted file mode 100644
index 861b83e..0000000
--- a/deb-package/DEBIAN/postint
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-
-# Pobierz nazwę użytkownika, który uruchomił instalację pakietu
-USER=$(logname)
-
-# Ścieżki do katalogu domowego
-HOME_DIR="/home/$USER"
-DEST_DIR="$HOME_DIR/mexassistant"
-
-# Utwórz katalog, jeśli nie istnieje
-mkdir -p "$DEST_DIR"
-
-# Skopiuj pliki do katalogu domowego
-cp /home/user/mexassistant/user_config.cfg "$DEST_DIR/"
-
-# Ustaw odpowiednie uprawnienia
-chown -R "$USER:$USER" "$DEST_DIR"
-
-exit 0
diff --git a/main.py b/main.py
index 2e3e0ea..5afa76d 100644
--- a/main.py
+++ b/main.py
@@ -1,7 +1,13 @@
import main_window
import process_command as pc
+import os
+import create_config
if __name__ == "__main__":
print("Uruchamianie...")
+ try:
+ open(os.path.expanduser("~") + "/mexassistant/config.ini")
+ except:
+ create_config.createConfig()
commandProcessing = pc.CommandProcessing()
main_window.buildApp(commandProcessing)
\ No newline at end of file