knetfix - Version 1.00 -KDE KNetworkManager Fix for Wireless Connection Problems

I have put together a script file to automate the process of removing the files used by KNetworkManager/KWallet as recommended by knurpht here in one of his very fine messages. I have used this on two different Laptops who’s wireless did work with ifup, but not with KNetworkManager. I followed the suggestions by knurpht and low and behold, KNetworkManager started working. Since these commands were so successful, I decided they should be placed into a script file for all to use. Here is the output of the script file text.

Kde NetworkManager Fixer - Version 1.00 - Removes all KNetworkManager Settings
Desktop Loaded: KDE4 KNetworkManager Running: Yes KWalletManager Loaded: Yes

knetfix will run the following Terminal Commands:
sudo /etc/init.d/network stop, requires root password
sudo killall -9 kwalletemanager, if running
sudo killall -9 knetworkmanager, if running
rm -rf ~/.kde4/share/config/networkmanagementrc
rm -rf ~/.kde4/share/apps/networkmanagement
rm -rf ~/.kde4/share/config/kwalletrc
rm -rf ~/.kde4/share/apps/kwallet
You should reboot your computer when complete, then…

Load Required Programs using: YaST for KNetworkManager & KDE menu for Kwallet

You Must run: YaST / Network Devices / Network Settings / Global Options Tab
and select the bullet option for: User Controlled with NetworkManager
To use Kwallet open: KDE Menu / System / Desktop Applet / KwalletManager

If You Can Not get your wireless connection working using the ‘Traditional
Method with ifup’, it is very likely this Knetfix script file will not help
you out. Make sure that your wireless hardware is working first.

Do you wish to perform the above commands? (y/N)
To create knetfix, copy and past the text in the code window below as the text file knetfix in your home area bin folder (~/bin/knetfix).

#!/bin/bash

#: Title       : /home/james/bin/knetfix
#: Date Created: Sun Nov 28 10:18:13 CST 2010
#: Last Edit   : Sun Nov 28 10:18:13 CST 2010
#: Author      : J. McDaniel
#: Version     : 1.00
#: Description : 
#: Options     : 

TITLE="Kde NetworkManager Fixer - Version 1.00 - Removes all KNetworkManager Settings"

#
# Section 1, Function Code Blocks go here *************************************
#

#
#Display One or More Line(s) with different foreground and background colors
# $1=foreground color $2=background color 
# $3=Number of Lines to Display 
# $4 and higher are lines text to display
#    * 0: Black
#    * 1: Blue
#    * 2: Green
#    * 3: Cyan
#    * 4: Red
#    * 5: Magenta
#    * 6: Yellow
#    * 7: White
#
function print_color {
  fgrd=$1
  bgrd=$2
  maxnum=$3
  counter=1
  while  $(( counter )) -lt $(( maxnum + 1 )) ] ; do
  tput bold
  tput setf $(( fgrd ))
  tput setb $(( bgrd ))
    echo "$4$(tput sgr0)"
    let counter=counter+1
    shift
  done
}

#
# Prompt for user input in bold while, set $CHOICE for use if needed
#
function enter_prompt {
  echo
  tput bold
  tput setf 7
  echo -n "$1$(tput sgr0)"
  read CHOICE
  echo
}

if  "$DESKTOP_SESSION" != "kde4" ] ; then
  echo "knetfix only works with KDE4, Sorry!"
  exit 1
else
  KDE="KDE4"
fi

kwallet="$(pidof kwalletmanager)"
knetwork="$(pidof knetworkmanager)"

if  "$kwallet" == "" ] ; then
  kwalletloaded="No "
else
  kwalletloaded="Yes"
fi

if  "$knetwork" == "" ] ; then
  knetworkloaded="No "
else
  knetworkloaded="Yes"
fi

tput clear

print_color 7 2 1 "$TITLE"

l1="Desktop Loaded: $KDE  KNetworkManager Running: $knetworkloaded  KWalletManager Loaded: $kwalletloaded"
l2=""
print_color 7 2 2 "$l1" "$l2"

print_color 7 1 1 "knetfix will run the following Terminal Commands:      " 

l1=" sudo /etc/init.d/network stop, requires root password "
l2=" sudo killall -9 kwalletemanager, if running           "
l3=" sudo killall -9 knetworkmanager, if running           "
l4=" rm -rf ~/.kde4/share/config/networkmanagementrc       "
l5=" rm -rf ~/.kde4/share/apps/networkmanagement           "
l6=" rm -rf ~/.kde4/share/config/kwalletrc                 "
l7=" rm -rf ~/.kde4/share/apps/kwallet                     "
print_color 7 0 7 "$l1" "$l2" "$l3" "$l4" "$l5" "$l6" "$l7"

print_color 7 1 2 " You should reboot your computer when complete, then..." ""

l1="Load Required Programs using: YaST for KNetworkManager & KDE menu for Kwallet "
l2=""
print_color 7 0 2 "$l1" "$l2"

l1=" You Must run: YaST / Network Devices / Network Settings / Global Options Tab "
l2=" and select the bullet option for: User Controlled with NetworkManager        " 
l3=" To use Kwallet open:  KDE Menu / System / Desktop Applet / KwalletManager    "
l4=""
print_color 7 1 4 "$l1" "$l2" "$l3" "$l4"

l1=" If You Can Not get your wireless connection working using the 'Traditional   "
l2=" Method with ifup', it is very likely this Knetfix script file will not help  "
l3=" you out.  Make sure that your wireless hardware is working first.            "
print_color 7 4 3 "$l1" "$l2" "$l3"

#
# Determine if you wish to perform the listed commands
#

enter_prompt "Do you wish to perform the above commands? (y/N)"

if  "$CHOICE" == "y" ] ||  "$CHOICE" == "Y" ] ; then

  sudo /etc/init.d/network stop

  if  "$kwallet" != "" ] ; then
    sudo killall -9 kwalletmanager
  fi

  if  "$knetwork" != "" ] ; then
    sudo killall -9 knetworkmanager
  fi

  rm -rf ~/.kde4/share/config/networkmanagementrc
  rm -rf ~/.kde4/share/apps/networkmanagement
  rm -rf ~/.kde4/share/config/kwalletrc
  rm -rf ~/.kde4/share/apps/kwallet

  print_color 7 4 2 " The Commands as listed above were performed, please restart openSUSE now!" ""

else

  print_color 7 4 2 " As Requested, No Changes Were made to your KNetworkManager Settings. " ""

fi

exit 0

# End Of Script

knetfix must be marked executable to be used. Open up a terminal session and run the following command:

chmod +x ~/bin/knetfix

To use knetfix, open another terminal session and run the terminal command:

knetfix

knetfix requires that you be running KDE4, that you already know your wireless hardware works in ifup and that for what ever reason, you can not get your wireless working in KNetworkManager.

Thank You,

I’m not really happy with the name of your script.

Considering this here

rm -rf ~/.kde4/share/apps/kwallet

how about “K-delete_all_my-previously-stored-stuff-from-KDE-wallet-including-some-of-my-precious-passwords”?

Not very catchy, but certainly more to the point, what it really does.

Facepalm

I’m not really happy with the name of your script.

Considering this here

 Code:
 rm -rf ~/.kde4/share/apps/kwallet 

how about “K-delete_all_my-previously-stored-stuff-from-KDE-wallet-including-some-of-my-precious-passwords”?

Not very catchy, but certainly more to the point, what it really does.

Facepalm
You are very correct in your assumptions. Of course, I assume you have a problem with KNetworkManager working if you decide to use the script, perhaps you are not spending all that much time online, your have the source code and could remove that line AND, you are given one more chance, after you are told what the script will do, to abort the process. I can say that if the consensus is that removing the kWallet files are never required to get KNetworkManager working, I could post a new script without this command or provide some other warning I suppose.

I am always open to suggestions here.

Thank You,