Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 791  / 1 Year ago, wed, may 3, 2023, 11:55:11

Is there a way to set a hotkey for toggling connection through a network cable:



enter image description here






Also if I have a command in command-line that can do this or a piece of C++ code that does this I can set a hotkey for it.


More From » networking

 Answers
3

Control of the NetworkManger



The NetworkManger can be controlled from the commandline:



man nmcli:



NAME
nmcli – command‐line tool for controlling NetworkManager

SYNOPSIS
nmcli [ OPTIONS ] OBJECT { COMMAND | help }
...


The man page on the net: http://manpages.ubuntu.com/manpages/saucy/man1/nmcli.1.html



With the dbus:





Example - working at here:



Disconnecting from the current network connection and staying disconnected:



qdbus --system --literal  org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/0 org.freedesktop.NetworkManager.Device.Disconnect


Connecting the network with th UUID:



1) Reading the UUID:



nmcli -p c


At here the UUID is 81540c01-2377-4d79-9763-d0f3104c81f3



2) Activating the connection:



nmcli c up uuid 81540c01-2377-4d79-9763-d0f3104c81f3


Hotkeys



One way to add the shortcuts/hotkeys is to use the KDE menu editor.



enter image description here



The command can be added to the KDE menu with a shortcut to run the command.



The KDE document can be found: K-Menu > Applications > Help ...



The KDE menu editor handbook on the net: http://docs.kde.org/development/en/kde-workspace/kmenuedit/index.html


[#27839] Thursday, May 4, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aclavadoug

Total Points: 317
Total Questions: 103
Total Answers: 125

Location: Bangladesh
Member since Wed, Mar 24, 2021
3 Years ago
;