Here is a verbose solution as a python script. Not literally what you were asking for, but yet a solution:
# change the lines below to the correct paths
path_to_configfile = "path_to_configfile" # the real one in /etc/dhcp/dhclient.conf
path_toconfigfile_a = "path_toconfigfile_a"
path_toconfigfile_b = "path_toconfigfile_b"
# change the line to the default line in the config file (leave the \n)
old_line = "old_line\n"
# change to the line number to check as an indicator
line_number = 17 # first line = 1
# change to the messages you'd like to see
config1_message = "config 1 is activated"
config2_message = "config 2 is activated"
with open(path_to_configfile) as defaultconfig:
defaultconfig = defaultconfig.readlines()
if defaultconfig[line_number-1] == old_line:
os.system('gksudo cp '+"'"+path_toconfigfile_a+"'"+" "+"'"+path_to_configfile+"'")
os.system('zenity --info --text '+'"'+config1_message+'"')
os.system('gksudo cp '+"'"+path_toconfigfile_b+"'"+" "+"'"+path_to_configfile+"'")
os.system('zenity --info --text '+'"'+config2_message+'"')
To use it:
- create a folder in a secure directory to store the two versions of your config files.
- create a
- copy the code above into a file and call it toggle_config (or anything you like).
- change the lines in the headsection to the correct paths, line and messages you'd like to see when the settings are toggled
- save the file and make it executable. store it in
~/bin, or copy it to
/usr/bin for more security.
After logout / login you will be able to toggle between the two setting versions, by the command
You will be asked for your password, and you will see a message like this:
Alternatively, you can create a .desktop file with the command and lock it to the launcher for quick switching between the settings.