Added functionality to mantxt, formerly known as manshow

1 view
Skip to first unread message

B. Henry

unread,
Feb 21, 2016, 4:43:35 PM2/21/16
to Vinux Documentation, vinux-de...@googlegroups.com
Besides being easier for some folks to navigate and read with screenreaders mantext is useful in that it makes it easier for one to edit a manpage's
information for future refference.
Many people who use the application won't iknow that a textfile is in /tmp that they can copy to save for future use, and the file is overwritten next
use anyway...
To save a bit of typing I started saving a copy in my h home dir some time ago, but never went past my one line hack.
Yesterday I finally added the functionality in a way that's worth sharing/including on Vinux.
I may well add a few more tweaks to make the script more flexible, but I'll attach what I have in case I don't work on it more now.
You can just copy it in to your path for testing as It's called manshow like it was when Storm first wrote it.
Of course it'd need to be renamed back to mantext for official inclusion in Vinux.
If anyone has suggestions for improving it a bit more, plese let me know.
As it is if you modify the text copy of a manpage you open a copy is saved in your home dir prefixed with man- and with a .txt extension.
If you close the editor with out making any change then nothing is saved outside of the /tmp dir.

--
B.H.
Registerd Linux User 521886

manshow
signature.asc

B. Henry

unread,
Feb 23, 2016, 12:18:46 PM2/23/16
to Vinux Documentation, vinux-de...@googlegroups.com
I guess no one bothered with this, or did not run it from the GUI if they did.
There was a problem where the modification test was run before gedit was closed, thus no change was noted and the modification was not copied in to the
user's home dir.
I fixed this, and also changed the test to see whether mantext had been invoked from the CLI or GUI to make it more portable. Now it should work
correctly whether or not $COLORTERM exists, i.e. it should not matter what terminal emulator you use, nor which graphical desktop, nor which distro...
I also added a notification that Orca will read if you run mantext from your dash or any GUI run dialog.
Again, I may at some point add some more functionality, but would appreciate a tester or two to make sure I've not overlooked anything with the attached
version.
BTW, I changed the name from manshow to mantext on my production box, so will attach it as such instead of as manshow as the version I sent to these
lists a couple daze ago was called.
I think this is now ready for inclusion in Vinux, and also plan to make it available for ARch and perhaps other distros so please give it a quick
testdrive.
Thanks,

--
B.H.
Registerd Linux User 521886


B. Henry wrote:
Sun, Feb 21, 2016 at 03:39:32PM -0600
> #!/bin/bash
> #this script accepts 1 and only 1 argument, a man topic.
>
> ## Variable(s) and function(s)
> MF="man-$1.txt"
>
> ## Comparison function
> ## Check manpage .txt file for modification/Save a copy in $HOME if found
> DifTest() {
> BACK="$(stat -t /tmp/man.org|cut -d ' ' -f2)"
> WORK="$(stat -t /tmp/$MF|cut -d ' ' -f2)"
>
> if [[ $BACK != $WORK ]]; then
> cp /tmp/$MF $HOME/$MF
> echo "Your modified $1 manpage text has been written to
> $HOME/$MF"
> fi
> }
>
> ## *Go to work
> if [[ $# -ne "1" ]] ; then
> echo "Usage: manshow manpage"
> exit 1
> fi
>
> ## Write the manpage to a .txt file and make a backup copy
> ## for comparison in modification test
> man $1 > /tmp/$MF && cp /tmp/$MF /tmp/man.org
>
> ## check if the file has anything in it and open if so.
> if [[ -s /tmp/$MF ]] ; then
> #select gedit if it is available, if not use nano.
> #There's probably a much better way to do this.
> #For now we just check for the existance of the $COLOR term variable.
> if [[ -n $COLORTERM ]] ; then
> gedit /tmp/$MF&
> else
> nano /tmp/$MF
> wait
> fi
> DifTest
> fi
> exit=0



mantext
signature.asc
Reply all
Reply to author
Forward
0 new messages