Tint2 snippet for NFS
Posted on 2018-03-27 22:26:00 from Vincent in OpenBSD Desktop Tint2
As discussed in this blog, I'll detail my NFSs snippet for Tint2.
Context
I just remind you that this snippet for Tint2 allow me to display an icon on my status bar for all what concerns NFS.
As presented in this blog, there are several statuses for this icon.
In the following screenshots, the NFS icon is the 2nd one:
Details
Source code is available here
This NFS snippet for Tint2 allows me to quickly see if my NAS is mounted or not.
It will allow me to see quickly if I have files opens on my NAS.
On laptop, such quick look allow me to avoid troubles with NFS. Mainly when I put my machine on sleep mode when mounted to the NFS server and wake it up on an another network.
Automatic installation
There is no prerequisites for this script. It just use standard tools and commands.
For the installation, I provide you a Makefile doing the tasks for you. Just do:
make install
This script will modify your ~./config/tint2/tint2rc file !!!!.
Manual installation
If you prefer, you can do the installation manually by doing the following:
Add the following elements in your ~/.config/tint2/tint2rc file
#-------------------------------------
# Executor 2
execp = new
execp_command = ~/.config/tint2/check_nfs.sh
execp_interval = 3
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Nas status (click to toggle)
execp_lclick_command = ~/.config/tint2/toggle_mount_nas.sh
execp_rclick_command =
execp_mclick_command =
execp_uwheel_command =
execp_dwheel_command =
execp_font_color = #ff0018 100
execp_padding = 1 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 28
execp_icon_h = 0
In my case the NFS icon is located on the 2nd executor this explains the 1st line.
If you adapt the tint2rc file with an editor, do not forget to adapt the following element by Adding an "E" at the good place:
panel_items =
Finally perform some copies on ~/.config/tint2:
cp check_nfs.sh ~/.config/tint2
cp toggle_mount_nas.sh ~/.config/tint2
cp -r icons/* ~/.config/tint2/icons/
chmod +x ~/.config/tint2/check_nfs.sh
chmod +x ~/.config/tint2/toggle_mount-nas.sh
Parameters to adapt
In the check_nfs.sh script, you have to adapt the IP address of you NFS server.
NAS=192.168.3.4
Replace this IP with the one in your environment.
In the toggle_mountnas.sh script, you have to adapt your NAS mount point:
MOUNT_DIR=/net/nas
Replace the mount point with your path.
What does the NFS snippet ?
The check_nfs.sh script will be executed every 3 seconds (cfr execp_interval) and will return the path to the appropriate icon.
First, the script will check if your NAS is pingeable. This is useful for laptops moving on different networks.
Then, it will check if there is an NFS mount on you system (mount -t nfs)
Then, it will check if there are open files on your NFS mount (fstat).
On each of those tests, the associated icon will be different.
This will allow me to know:
- my NFS server is mounted or not mounted
- my NFS server has open files. In such case, do not put your machine in sleep or hibernate mode, this will create NFS issues.
Possible inter-actions
By clicking on the button, you will trigger the other script called "toggle_mount_nas.sh".
If the fstat command reports some open files, it will display them in a small xterm box.
If the fstat command is empty, it will toggle between mount and umount your NAS.