From 78827d833d4a407e08546339230e40bb92fa1667 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 17 Jul 2014 18:18:40 +0400 Subject: [PATCH] added completions removed wpa_actiond dependency --- CHANGELOG | 1 + PKGBUILD | 1 - README.md | 1 - sources/gui/CMakeLists.txt | 2 + sources/gui/bash-completions | 99 +++++++++++++++ sources/gui/src/main.cpp | 12 +- sources/gui/src/mainwindow.cpp | 3 - sources/gui/src/settingswindow.cpp | 18 --- sources/gui/src/settingswindow.h | 1 - sources/gui/src/settingswindow.ui | 55 ++------- sources/gui/zsh-completions | 93 ++++++++++++++ sources/resources/translations/en.ts | 2 +- sources/resources/translations/netctl-gui.ts | 120 +++++++++---------- sources/resources/translations/ru.ts | 26 ++-- 14 files changed, 284 insertions(+), 150 deletions(-) create mode 100644 sources/gui/bash-completions create mode 100644 sources/gui/zsh-completions diff --git a/CHANGELOG b/CHANGELOG index 402e239..bca35cb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ Ver.1.2.0: + [gui] added about window + [gui] more command line options + [gui] added workaround for wireless-wep example ++ [gui] added shell completions + [lib] detached backend from frontend + [lib] added error checking + [lib] added doxygen documentation diff --git a/PKGBUILD b/PKGBUILD index 2aeeffd..db024d4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -12,7 +12,6 @@ makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools') optdepends=('kdebase-runtime: sudo support' 'kdeplasma-applets-netctl-gui: KDE widget' 'sudo: sudo support' - 'wpa_actiond: netctl-auto support' 'wpa_supplicant: wifi support') source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz") install="${pkgbase}.install" diff --git a/README.md b/README.md index 33aae31..1b5d3f1 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ Optional dependencies * kdebase-workspace (widget) * sudo (sudo support) -* wpa_actiond (netctl-auto support) * wpa_supplicant (WiFi support) Make dependencies diff --git a/sources/gui/CMakeLists.txt b/sources/gui/CMakeLists.txt index 4b17b55..47bafab 100644 --- a/sources/gui/CMakeLists.txt +++ b/sources/gui/CMakeLists.txt @@ -22,3 +22,5 @@ configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MA install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/) +install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME _${SUBPROJECT}) +install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT}) diff --git a/sources/gui/bash-completions b/sources/gui/bash-completions new file mode 100644 index 0000000..c16828d --- /dev/null +++ b/sources/gui/bash-completions @@ -0,0 +1,99 @@ +########################################################################### +# This file is part of netctl-gui # +# # +# netctl-gui is free software: you can redistribute it and/or # +# modify it under the terms of the GNU General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# netctl-gui is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with netctl-gui. If not, see http://www.gnu.org/licenses/ # +########################################################################### + + +# variables +_netctl_gui_arglist=( + '--about' + '--netctl-auto' + '--settings' + '-e' + '--essid' + '-o' + '--open' + '-s' + '--select' + '-c' + '--config' + '-d' + '--debug' + '--default' + '--set-opts' + '-t' + '--tab' + '-v' + '--version' + '-i' + '--info' + '-h' + '--help' +) + +_netctl_gui_settings=( + 'CTRL_DIR=' + 'CTRL_GROUP=' + 'IFACE_DIR=' + 'LANGUAGE=' + 'NETCTLAUTO_PATH=' + 'NETCTLAUTO_SERVICE=' + 'NETCTL_PATH=' + 'PID_FILE=' + 'PREFERED_IFACE=' + 'PROFILE_DIR=' + 'RFKILL_DIR=' + 'SUDO_PATH=' + 'SYSTEMCTL_PATH=' + 'WPAACTIOND_PATH=' + 'WPACLI_PATH=' + 'WPASUP_PATH=' + 'WPA_DRIVERS=' +) + +_netctl_gui_tabs=( + '1' + '2' + '3' +) + +_netctl_profiles=($(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")) + + +# work block +_netctl_gui() { + COMPREPLY=() + wantfiles='-@(c|-config)' + wantprofiles='-@(o|-open|s|-select)' + wantsettings='-@(-set-opts)' + wanttabs='-@(t|-tab)' + _get_comp_words_by_ref cur prev + + if [[ $prev = $wantfiles ]]; then + _filedir + elif [[ $prev = $wantprofiles ]]; then + COMPREPLY=($(compgen -W '${_netctl_profiles[@]}' -- "$cur")) + elif [[ $prev = $wantsettings ]]; then + COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur")) + elif [[ $prev = $wanttabs ]]; then + COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur")) + else + COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur")) + fi + + true +} + +complete -F _netctl_gui netctl-gui diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index cb02ec8..3f4215d 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -43,9 +43,9 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + // config path + QString configPath = QString(QDir::homePath() + QString("/.config/netctl-gui.conf")); // translation - QString configPath = QDir::homePath() + QDir::separator() + QString(".config") + - QDir::separator() + QString("netctl-gui.conf"); QString language = Language::defineLanguage(configPath); QTranslator translator; translator.load(QString(":/translations/") + language); @@ -103,8 +103,8 @@ int main(int argc, char *argv[]) } // additional functions // config path - else if (QString(argv[i]) == QString("--config")) { - configPath = QString(argv[i+1]); + else if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) { + configPath = QDir().absoluteFilePath(argv[i+1]); i++; } // debug @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n"); helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n"); helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n"); - helpMessage += QString(" [ --config FILE ] [ -d | --debug ] [ --default ]\n"); + helpMessage += QString(" [ -c FILE | --config FILE ] [ -d | --debug ] [ --default ]\n"); helpMessage += QString(" [ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]\n"); helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n"); helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:")); @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) .arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile)); // additional functions helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:")); - helpMessage += QString(" --config %1\n") + helpMessage += QString(" -c %1 --config %1\n") .arg(configPath, -10); helpMessage += QString(" - %1\n") .arg(QApplication::translate("MainWindow", "read configuration from this file")); diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index e6108de..fbee361 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -197,9 +197,6 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all")) commandLine.append(configuration[QString("WPACLI_PATH")]); commandLine.append(configuration[QString("WPASUP_PATH")]); } - if ((apps == QString("wpaact")) || (apps == QString("all"))) { - commandLine.append(configuration[QString("WPAACTIOND_PATH")]); - } QProcess command; if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QChar(' ')); command.start(commandLine.join(QChar(' '))); diff --git a/sources/gui/src/settingswindow.cpp b/sources/gui/src/settingswindow.cpp index ad0f0cd..e567269 100644 --- a/sources/gui/src/settingswindow.cpp +++ b/sources/gui/src/settingswindow.cpp @@ -65,7 +65,6 @@ void SettingsWindow::createActions() connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir())); connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath())); connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath())); - connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath())); connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath())); connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath())); } @@ -222,20 +221,6 @@ void SettingsWindow::selectSystemctlPath() } -void SettingsWindow::selectWpaActiondPath() -{ - if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaActiondPath]"; - - QString filename = QFileDialog::getOpenFileName( - this, - QApplication::translate("SettingsWindow", "Select wpa_actiond command"), - QString("/usr/bin/"), - QApplication::translate("SettingsWindow", "All files (*)")); - if (!filename.isEmpty()) - ui->lineEdit_wpaActiondPath->setText(filename); -} - - void SettingsWindow::selectWpaCliPath() { if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]"; @@ -293,7 +278,6 @@ QMap SettingsWindow::readSettings() settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text(); settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text(); settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text(); - settings[QString("WPAACTIOND_PATH")] = ui->lineEdit_wpaActiondPath->text(); settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text(); settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text(); settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text(); @@ -325,7 +309,6 @@ void SettingsWindow::setSettings(const QMap settings) ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]); ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]); ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]); - ui->lineEdit_wpaActiondPath->setText(settings[QString("WPAACTIOND_PATH")]); ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]); ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]); ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]); @@ -353,7 +336,6 @@ QMap SettingsWindow::getDefault() settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/"); settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu"); settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl"); - settings[QString("WPAACTIOND_PATH")] = QString("/usr/bin/wpa_actiond"); settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli"); settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant"); settings[QString("WPA_DRIVERS")] = QString("nl80211,wext"); diff --git a/sources/gui/src/settingswindow.h b/sources/gui/src/settingswindow.h index 8ab7e66..dfe5a9a 100644 --- a/sources/gui/src/settingswindow.h +++ b/sources/gui/src/settingswindow.h @@ -57,7 +57,6 @@ private slots: void selectRfkillDir(); void selectSudoPath(); void selectSystemctlPath(); - void selectWpaActiondPath(); void selectWpaCliPath(); void selectWpaSupPath(); diff --git a/sources/gui/src/settingswindow.ui b/sources/gui/src/settingswindow.ui index 78537f6..8ae1024 100644 --- a/sources/gui/src/settingswindow.ui +++ b/sources/gui/src/settingswindow.ui @@ -6,8 +6,8 @@ 0 0 - 670 - 331 + 668 + 329 @@ -127,8 +127,8 @@ 0 0 - 454 - 270 + 452 + 268 @@ -194,8 +194,8 @@ 0 0 - 454 - 270 + 452 + 268 @@ -381,8 +381,8 @@ 0 0 - 454 - 270 + 452 + 268 @@ -451,8 +451,8 @@ 0 0 - 454 - 270 + 452 + 268 @@ -518,37 +518,6 @@ - - - - - - - 150 - 0 - - - - wpa_actiond path - - - - - - - Path to wpa_actiond - - - - - - - Browse - - - - - @@ -679,8 +648,8 @@ 0 0 - 454 - 270 + 436 + 103 diff --git a/sources/gui/zsh-completions b/sources/gui/zsh-completions new file mode 100644 index 0000000..f2087f4 --- /dev/null +++ b/sources/gui/zsh-completions @@ -0,0 +1,93 @@ +#compdef netctl-gui +########################################################################### +# This file is part of netctl-gui # +# # +# netctl-gui is free software: you can redistribute it and/or # +# modify it under the terms of the GNU General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# netctl-gui is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with netctl-gui. If not, see http://www.gnu.org/licenses/ # +########################################################################### + + +# variables +_netctl_gui_arglist=( + {'--about','--about'}'[show about window]' + {'--netctl-auto','--netctl-auto'}'[show netctl-auto window]' + {'--settings','--settings'}'[show settings window]' + {'(--essid)-e','(-e)--essid'}'[select ESSID]:essid:->essid' + {'(--open)-o','(-o)--open'}'[open profile]:filename:->profiles' + {'(--select)-s','(-s)--select'}'[select profile]:filename:->profiles' + {'(--config)-c','(-c)--config'}'[read configuration from this file]:filename:->files' + {'(--debug)-d','(-d)--debug'}'[print debug information]' + {'--default','--default'}'[start with default settings]' + {'--set-opts','--set-opts'}'[set options for this run, comma separated]:settings:->settings' + {'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:tab:->tab' + {'(--version)-v','(-v)--version'}'[show version and exit]' + {'(--info)-i','(-i)--info'}'[show build information and exit]' + {'(--help)-h','(-h)--help'}'[show help and exit]' +) + +_netctl_gui_settings=( + 'CTRL_DIR=' + 'CTRL_GROUP=' + 'IFACE_DIR=' + 'LANGUAGE=' + 'NETCTLAUTO_PATH=' + 'NETCTLAUTO_SERVICE=' + 'NETCTL_PATH=' + 'PID_FILE=' + 'PREFERED_IFACE=' + 'PROFILE_DIR=' + 'RFKILL_DIR=' + 'SUDO_PATH=' + 'SYSTEMCTL_PATH=' + 'WPAACTIOND_PATH=' + 'WPACLI_PATH=' + 'WPASUP_PATH=' + 'WPA_DRIVERS=' +) + +_netctl_gui_tabs=( + '1' + '2' + '3' +) + +_netctl_profiles=($(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")) + + +# work block +_netctl-gui() { + _arguments $_netctl_gui_arglist + case "$state" in + essid) + _message "netctl" + ;; + files) + _files + ;; + profiles) + _values 'profiles' $_netctl_profiles + ;; + settings) + _values -s , 'settings' $_netctl_gui_settings + ;; + tab) + _values 'tab' $_netctl_gui_tabs + ;; + esac +} + +case "$service" in + netctl-gui) + _netctl-gui "$@" && return 0 + ;; +esac diff --git a/sources/resources/translations/en.ts b/sources/resources/translations/en.ts index 39cc9cb..27f2633 100644 --- a/sources/resources/translations/en.ts +++ b/sources/resources/translations/en.ts @@ -1587,7 +1587,7 @@ Select wpa_actiond command - Select wpa_actiond command + Select wpa_actiond command systemctl path diff --git a/sources/resources/translations/netctl-gui.ts b/sources/resources/translations/netctl-gui.ts index bfda989..b31af0a 100644 --- a/sources/resources/translations/netctl-gui.ts +++ b/sources/resources/translations/netctl-gui.ts @@ -733,30 +733,30 @@ - - + + Name - + Description - - + + Status - - + + @@ -776,9 +776,9 @@ - - - + + + Start @@ -831,13 +831,13 @@ - + Signal - + Security @@ -878,35 +878,35 @@ - - - + + + Start profile - + Restart profile - - - + + + Enable profile - + Edit profile - + Remove profile @@ -938,72 +938,72 @@ - - - + + + Updated - - + + Stop profile - - + + Disable profile - - + + Stop WiFi - - - - - + + + + + Start WiFi - + + - - + + - - - - + + + + - Done - - - - - - - - - - - + + + + + + + + + + + Error - - + + Stop @@ -1919,7 +1919,6 @@ - All files (*) @@ -1950,16 +1949,11 @@ - Select wpa_actiond command - - - - Select wpa_cli command - + Select wpa_supplicant command diff --git a/sources/resources/translations/ru.ts b/sources/resources/translations/ru.ts index e224c55..f9f272e 100644 --- a/sources/resources/translations/ru.ts +++ b/sources/resources/translations/ru.ts @@ -1,6 +1,6 @@ - + AboutWindow @@ -194,7 +194,7 @@ Skip no carrier Пропустить отсутствие оператора - + Set to ‘yes’ to use 802.1x authentication Установить "да", чтобы использовать 802.1x авторизацию @@ -329,7 +329,7 @@ A command that is executed before a connection is brought down Команда, которая будет запущена перед отключением - + Set to ‘yes’ to force connecting even if the interface is up Установить "да", чтобы запустить соединение, даже если интерфейс уже поднят @@ -380,7 +380,7 @@ Add Добавить - + An array of IP addresses suffixed with ‘/<netmask>’ Массив IP адресов с суффиксом ‘/<netmask>’ @@ -460,7 +460,7 @@ Timeout DAD Таймаут DAD - + Set to ‘yes’ to release the DHCP lease when the profile is stopped Установить "да", чтобы оставить выделенный DHCP, когда профиль отключен @@ -520,7 +520,7 @@ DNS domain DNS домен - + A ‘domain’ line for /etc/resolv.conf Строка ‘domain’ в /etc/resolv.conf @@ -528,7 +528,7 @@ DNS search Поиск DNS - + A ‘search’ line for /etc/resolv.conf Строка ‘search’ в /etc/resolv.conf @@ -536,11 +536,11 @@ DNS options Опции DNS - + An array of ‘options’ lines for /etc/resolv.conf Массив строк ‘options’ в /etc/resolv.conf - + Maximum time, in seconds, to wait for IPv6’s Duplicate Address Detection to succeed Максимальное время в секундах для ожидания выполнения детектирования дубликации IPv6 адресов @@ -1309,7 +1309,7 @@ Idle timeout Таймаут простоя - + This option specifies the idle time (in seconds) after which ‘pppd’ should disconnect Указывает таймаут простоя в секундах, после чего 'pppd' будет отключен @@ -1349,7 +1349,7 @@ LCP echo interval LCP echo интервал - + These options override default LCP parameters from ‘/etc/ppp/options’ Эти опции заместят стандартные опции LCP из ‘/etc/ppp/options’ @@ -1586,7 +1586,7 @@ Select wpa_actiond command - Путь к команде wpa_actiond + Путь к команде wpa_actiond systemctl path @@ -1710,7 +1710,7 @@ tap tap - + Either ‘tun’, or ‘tap’ ‘tun’ или ‘tap’