added completions

removed wpa_actiond dependency
This commit is contained in:
arcan1s
2014-07-17 18:18:40 +04:00
parent c0207a108e
commit 78827d833d
14 changed files with 284 additions and 150 deletions

View File

@ -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})

View File

@ -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

View File

@ -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"));

View File

@ -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(' ')));

View File

@ -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<QString, QString> 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<QString, QString> 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<QString, QString> 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");

View File

@ -57,7 +57,6 @@ private slots:
void selectRfkillDir();
void selectSudoPath();
void selectSystemctlPath();
void selectWpaActiondPath();
void selectWpaCliPath();
void selectWpaSupPath();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>670</width>
<height>331</height>
<width>668</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
@ -127,8 +127,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>452</width>
<height>268</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -194,8 +194,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>452</width>
<height>268</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -381,8 +381,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>452</width>
<height>268</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@ -451,8 +451,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>452</width>
<height>268</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@ -518,37 +518,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaActiondPath">
<item>
<widget class="QLabel" name="label_wpaActiondPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_actiond path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaActiondPath">
<property name="toolTip">
<string>Path to wpa_actiond</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaActiondPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pid">
<item>
@ -679,8 +648,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>436</width>
<height>103</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">

View File

@ -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