Skip to content

Commit

Permalink
Merge pull request #40 from felipealfonsog/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
felipealfonsog authored Jul 23, 2024
2 parents 902a7d9 + b91fd51 commit 7565249
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 31 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,40 @@ You can find ConnWifiMaster App in your program menu!

#


#### Installation (Python/PyQT5 version for Arch Linux)*
#### Via AUR using YAY

[![AUR](https://img.shields.io/aur/version/connmaster-py)](https://aur.archlinux.org/packages/connmaster-py)

<!--
[![AUR](https://img.shields.io/aur/version/connmaster-py.svg)](https://aur.archlinux.org/packages/connmaster-py)
-->

<!--
https://aur.archlinux.org/packages/connmaster-py
-->

ConnWifiMaster Python/PyQT5 (connmaster on AUR) is available on AUR (Arch User Repository), and it can be installed using the `yay` package manager. Follow the steps below to install:

1. Make sure you have `yay` installed. If not, you can install it with the following command:

```
sudo pacman -S yay
```
Once yay is installed, you can install it by running the following command:

```
yay -S connmaster-py
```
This command will automatically fetch the package from AUR and handle the installation process for you.
You can find ConnWifiMaster App in your program menu!


#



#### Bash Installer 🚀

[![Bash Version](https://img.shields.io/badge/Bash%20Version-Available-brightgreen)](#)
Expand Down
39 changes: 39 additions & 0 deletions src/py/AUR/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Maintainer: Felipe Alfonso Gonzalez <f.alfonso@res-ear.ch>
pkgname=connmaster-py
pkgver=0.0.6
pkgrel=1
pkgdesc="ConnWifiMaster is a Python / PyQT5 app - designed for Arch Linux systems that use ConnMan for network management."
arch=('x86_64')
url="https://github.com/felipealfonsog/ConnWifiMaster"
license=('BSD-3-Clause')
depends=('python' 'python-pyqt5')
source=("https://github.com/felipealfonsog/ConnWifiMaster/archive/refs/tags/v.${pkgver}.tar.gz")
sha256sums=('a37fbd47489a066868294adfdabd4d3e9876dc89fb6a1a71ff7ac664f224a89e')

prepare() {
cd "$srcdir"
tar xf "v.${pkgver}.tar.gz"
mv "ConnWifiMaster-v.${pkgver}" "ConnWifiMaster"
}

build() {
# No compilation needed for Python scripts
return 0
}

package() {
cd "$srcdir/ConnWifiMaster"

# Install the Python script to /usr/local/bin
install -Dm755 "src/py/main.py" "${pkgdir}/usr/local/bin/connmaster-py"

# Create a symlink in /usr/bin pointing to /usr/local/bin/connmaster-py
ln -sf "/usr/local/bin/connmaster-py" "${pkgdir}/usr/bin/connmaster-py"

# Optionally install any icons or .desktop files if needed
# Install the icon
install -Dm644 "${srcdir}/ConnWifiMaster/src/py/connmaster-py-iconlogo.png" "${pkgdir}/usr/share/pixmaps/connmaster-py.png"

# Install the .desktop file
install -Dm644 "${srcdir}/ConnWifiMaster/src/py/connmaster-py.desktop" "${pkgdir}/usr/share/applications/connmaster-py.desktop"
}
File renamed without changes.
Binary file added src/py/connmaster-py-iconlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/py/connmaster-py.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=ConnWifiMaster PyQT5
Comment=ConnWifiMaster PyQT5 version - ConnMan for network management.
Exec=connmaster-py
Icon=connmaster-py
Terminal=false
Categories=Utility;Network;
39 changes: 8 additions & 31 deletions src/py/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import subprocess
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QPushButton, QMessageBox,
QInputDialog, QTextEdit, QLineEdit)
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QPushButton,
QInputDialog, QTextEdit, QLineEdit, QMessageBox)
from PyQt5.QtGui import QClipboard
from PyQt5.QtCore import Qt

Expand Down Expand Up @@ -83,7 +83,6 @@ def connect_network(self):
# Check if already connected
status = self.run_command(f"connmanctl services | grep '{network_id}'")
if "Connected" in status:
QMessageBox.information(self, 'Connect to Network', 'Already connected to this network.')
return

# Try to connect without a password
Expand All @@ -98,23 +97,13 @@ def connect_network(self):
result = self.run_command(f"connmanctl tether wifi {network_id} {password}")
else:
result = self.run_command(f"connmanctl connect {network_id}")

# Check if the operation was successful
if "success" in result.lower() or "connected" in result.lower():
QMessageBox.information(self, 'Connect to Network', 'Operation successful.')
else:
QMessageBox.warning(self, 'Connect to Network', 'Operation not successful. ' + result)

def disconnect_network(self):
network_id, ok = QInputDialog.getText(self, 'Disconnect from Network', 'Enter Network ID:')
if not ok or not network_id:
return
command = f"connmanctl disconnect {network_id}"
result = self.run_command(command)
if "success" in result.lower():
QMessageBox.information(self, 'Disconnect from Network', 'Operation successful.')
else:
QMessageBox.warning(self, 'Disconnect from Network', 'Operation not successful. ' + result)
self.run_command(command)

def configure_autoconnect(self):
network_id, ok = QInputDialog.getText(self, 'Configure Autoconnect', 'Enter Network ID:')
Expand All @@ -126,7 +115,6 @@ def configure_autoconnect(self):
status_result = self.run_command(status_command)

if network_id not in status_result:
QMessageBox.warning(self, 'Configure Autoconnect', f'Network ID {network_id} not found.')
return

# Extract current autoconnect status
Expand All @@ -138,7 +126,6 @@ def configure_autoconnect(self):
current_status = 'yes'
break

# Prompt for new autoconnect status
autoconnect, ok = QInputDialog.getItem(self, 'Configure Autoconnect', 'Set Autoconnect:', ['yes', 'no'], current_status == 'yes', editable=False)
if not ok:
return
Expand All @@ -148,30 +135,20 @@ def configure_autoconnect(self):

# Run the command to configure autoconnect
command = f"connmanctl config {network_id} --autoconnect {autoconnect_value}"
result = self.run_command(command)

# Check if the operation was successful
if "success" in result.lower() or "configured" in result.lower():
QMessageBox.information(self, 'Configure Autoconnect', 'Operation successful.')
else:
QMessageBox.warning(self, 'Configure Autoconnect', f'Operation not successful. Command result: {result}')

self.run_command(command)

def connect_saved_network(self):
command = "while IFS=, read -r network_id password; do if [ -z \"$network_id\" ]; then continue; fi; connmanctl connect \"$network_id\" || connmanctl tether wifi \"$network_id\" \"$password\"; done < ~/.connman_networks"
result = self.run_command(command)
if "success" in result.lower():
QMessageBox.information(self, 'Connect to Saved Network', 'Operation successful.')
else:
QMessageBox.warning(self, 'Connect to Saved Network', 'Operation not successful. ' + result)
# Check if any network was successfully connected
if "success" in result.lower() or "connected" in result.lower():
QMessageBox.information(self, 'Connect to Saved Network', 'Connected to a network successfully.')

def copy_to_clipboard(self):
selected_text = self.text_edit.textCursor().selectedText()
if selected_text:
clipboard = QApplication.clipboard()
clipboard.setText(selected_text)
QMessageBox.information(self, 'Copied to Clipboard', 'Network ID copied to clipboard.')
else:
QMessageBox.warning(self, 'No Selection', 'No text selected to copy.')

def display_credits(self):
credits = (
Expand Down

0 comments on commit 7565249

Please sign in to comment.