A comprehensive DMS (Dank Material Shell) plugin that displays both the current Kubernetes context and namespace in your bar, with the ability to switch between them directly from the UI.
- 🌐 Display Current Context: Shows the active Kubernetes context in the DankBar
- 📁 Display Current Namespace: Shows the active namespace for the current context
- 🔄 Quick Context Switching: Switch between contexts via popup menu
- 📂 Quick Namespace Switching: Switch between namespaces via popup menu
- ⚙️ Configurable Refresh Interval: Set how often to refresh (5-300 seconds)
- 🎨 Customizable Icons: Toggle context and namespace icons on/off
- 📝 Custom Kubeconfig Path: Support for custom kubeconfig file locations
- 🎯 Visual Indicators: Clear visual feedback for active context and namespace
- ⚡ Auto-close Popup: Popup closes automatically after selection
- Create the plugin directory:
mkdir -p ~/.config/DankMaterialShell/plugins/kube-context-namespace- Clone or copy the plugin files:
cd ~/.config/DankMaterialShell/plugins/
cp -r /home/rmysore/projects/test_plugin_dms_bar kube-context-namespaceOr clone directly:
cd ~/.config/DankMaterialShell/plugins/
git clone <your-repo-url> kube-context-namespace-
Enable the Plugin:
- Open DMS Settings:
Super + , - Go to the "Plugins" tab
- Enable the "Kube Context & Namespace" plugin
- Open DMS Settings:
-
Configure Settings (optional):
- Kubeconfig Path: Set custom path (default:
~/.kube/config) - Refresh Interval: Adjust refresh rate (default: 15 seconds)
- Show Context Icon: Toggle context icon display
- Show Namespace Icon: Toggle namespace icon display
- Kubeconfig Path: Set custom path (default:
-
Add to DankBar:
- Add the
kube-context-namespacewidget to your DankBar configuration
- Add the
| Setting | Description | Default | Range |
|---|---|---|---|
| Kubeconfig Path | Path to your Kubernetes config file | ~/.kube/config |
Any valid path |
| Refresh Interval | How often to refresh context/namespace | 15 seconds | 5-300 seconds |
| Show Context Icon | Display cloud icon next to context | true |
true/false |
| Show Namespace Icon | Display folder icon next to namespace | true |
true/false |
Horizontal Bar:
☁️ my-cluster / default
Vertical Bar:
☁️ my-cluster
📁 default
Popup Menu:
- Lists all available contexts (scrollable)
- Lists all available namespaces (scrollable)
- Click to switch
- Visual indicators for active selections
kube-context-namespace/
├── plugin.json # Plugin manifest and metadata
├── KubeWidget.qml # Main widget component
├── KubeSettings.qml # Settings interface
└── README.md # This file
This plugin requires:
settings_read- To read plugin configurationssettings_write- To save plugin configurations
- kubectl: Command-line tool must be installed and accessible in PATH
- Valid kubeconfig: A valid kubeconfig file at the configured path
- Cluster Access: Active connection to at least one Kubernetes cluster
The plugin uses kubectl commands to:
-
Get current context:
kubectl --kubeconfig ~/.kube/config config current-context -
Get current namespace:
kubectl --kubeconfig ~/.kube/config config view --minify --output jsonpath={..namespace} -
List all contexts:
kubectl --kubeconfig ~/.kube/config config get-contexts -o name -
List all namespaces:
kubectl --kubeconfig ~/.kube/config get namespaces -o jsonpath={.items[*].metadata.name}
-
Switch context:
kubectl --kubeconfig ~/.kube/config config use-context <context-name>
-
Switch namespace:
kubectl --kubeconfig ~/.kube/config config set-context --current --namespace=<namespace-name>
All commands respect the configured kubeconfig path.
This plugin extends the functionality of the original dms-kubernetes plugin by adding:
| Feature | dms-kubernetes | kube-context-namespace |
|---|---|---|
| Display Context | ✅ | ✅ |
| Display Namespace | ❌ | ✅ |
| Switch Context | ✅ | ✅ |
| Switch Namespace | ❌ | ✅ |
| List Namespaces | ❌ | ✅ |
| Dual Display | ❌ | ✅ |
| Separate Icons | ❌ | ✅ |
-
Verify
kubectlis installed:which kubectl
-
Check kubeconfig exists:
ls -la ~/.kube/config -
Test kubectl manually:
kubectl config current-context kubectl config view --minify --output jsonpath={..namespace}
- Check DMS logs for detailed error messages
- Verify kubeconfig path in plugin settings
- Ensure you have access to the cluster
- Verify you have permissions to list namespaces:
kubectl get namespaces
To modify this plugin:
- Edit the QML files in
~/.config/DankMaterialShell/plugins/kube-context-namespace/ - Reload DMS or restart the plugin
- Check DMS logs for any errors
MIT License - Feel free to modify and distribute
Created by rmysore
Inspired by psyreactor/dms-kubernetes