I'm now going to develop a program that will generate Shell Batch Files(*.sh), but I want to know some things:
It's possible to show GUIs using they?
How to do this?
This has been asked before:
How to make a GUI for bash scripts?
Summary of options:
dialog
Zenity
use a different scripting language like Perl, Python, Ruby, etc...
Gnome dialog may be of use Gnome Dialog Util
KDE has Kdialog Shell Scripting with KDE Dialogs
Related
I'm trying to make GUI specific settings in my .gvimrc.
How can I detect the GUI (gtk3, gnome, macvim, etc.) that vim is using?
Call has() to test if one of the GUI exists: if has("gui_gnome"), if has("gui_win32"), etc.
OK, the title is a bit(lot) cryptic, but that's the best one-line-summary I could come up with.
When developing, I prefer to develop CLI utilities, since they are much easier to write and test, and most of the programs I write don't really require a full blown interface.
Using the program is another story. My users don't like to use the shell, and they prefer a GUI with buttons, file pickers, text boxes, radio buttons and checkboxes.
Now, when I worked on windows, my solution was to write the program as a shell utility, and then use HTA to write a GUI. HTA was perfect for this, because creating a nice, simple interface with HTML is very easy, and using vbscript to run a shell command that calls the utility with the right arguments is also very easy.
Now, there is no HTA in linux, and I can't use regular html files because they can't use shell scripts(that would be a security issue). Is there any linux\cross-platform solution for writing quick GUI wrappers like the ones I described?
There's zenity. From the package info: "Zenity lets you display Gtk+ dialog boxes from the command line and through shell scripts. It is similar to gdialog, but is intended to be saner. It comes from the same family as dialog, Xdialog, and cdialog."
Update: If zenity is too simplistic then there is also Gtkdialog.
Update II: There appear to be some youtube videos on GUI interfacing with bash.
Tk comes to mind for GUIs, hosted in Tcl, Perl, or some other scripting language.
I have a gVIM script that parses current buffer and offers user to select one of multiple choices. It is implemented as console input, but since i'm using graphical version of gVIM, maybe it's possible to use graphical version of multiple choice dialog? I have tried to use python + Tkinter but it's very unstable and is not working on some NIX boxes :(. Any ideas?
GVim has, in its functions and settings, nothing that would enable showing GUI elements (with a few noble exceptions, like closing dialog and such.).
That being said, GVim is open source, and nothing stops you from downloading the source and messing with it.
After some research i have found a solution. VIM supports so-called "clientserver" mode and external application can send a command to it. So this task (and many others) can be solved with following technique (tested on Windows, OSX and Ubuntu):
VIMscript that handles a command launches standalone GUI script in
separate process and returns.
Standalone GUI script (python/ruby/.exe/whatever) displays GUI and
waits for user interaction.
After user interaction, standalone GUI script closes it's window,
communicates back to VIM via "clientserver" interface (call another
script, open file, move cursor etc) and exits.
If I go to System Preferences, Keyboard, Keyboard Shortcuts, then Application Shortcuts, I can define custom shortcuts to be used on a Mac.
Any way to access this functionality via Applescript?
The shortcuts are stored in NSUserKeyEquivalents dictionaries in ~/Library/Preferences/.GlobalPreferences.plist and the property lists of applications.
defaults write -g NSUserKeyEquivalents -dict-add Duplicate '~#d' Minimize '\0'
defaults write com.apple.finder NSUserKeyEquivalents '{"Show Package Contents"="#\r";}'
The shortcut format is described in the Cocoa Text System article.
System Preferences isn't scriptable with Applescript natively, you have to interact with it by GUI Scripting. GUI Scripting is really a last resort that allows you to interact with controls by explicitly declaring and calling them, and it doesn't take much to throw off a GUI script. It is difficult to implement even for experienced Applescript programmers. You'll find a few introductory tutorials out there in the web, but not much else.
The internals of the Mac OS are quickly becoming a lost art. Run the following in a shell, or run via shell in Applescript:
defaults write com.google.Chrome NSUserKeyEquivalents '{ "Search the Web…" = "#k"; }'
Also good to know: shortcuts for Services are in the pbs.plist, and they're stored using a different property than the NSUserKeyEquivalents.
There's info on how to write a basic script to change/add shortcuts for Services here:
Set Services keyboard shortcut via script OSX
This was the method I found the simplest, and it worked well for me (macOS 10.12.6 Sierra):
You can also use PlistBuddy and defaults:
/usr/libexec/PlistBuddy -c 'Delete NSServicesStatus:"(null) - test2 -
runWorkflowAsService"' ~/Library/Preferences/pbs.plist
2>/dev/null;defaults write pbs NSServicesStatus -dict-add '"(null) -
test2 - runWorkflowAsService"' '{key_equivalent = "^~#2";}'
The PlistBuddy command is not needed if there is not an existing entry
for the service. Replace test2 with the name of the service. Quit and
reopen applications to apply the changes.
^~#2 is control-option-command-2. See
http://osxnotes.net/keybindings.html.
And in case this might help those who are a bit less familiar with writing/executing scripts on macOS, I saved the script as a shell script (.sh extension), and ran it from Terminal using the following commannd:
sh "/path/to/script/scriptfile.sh"
I have written an AppleScript library to programmatically add Global & Application shortcuts. It took a tremendous amount of effort to work around the various quirks in how macOS implements shortcuts.
Version 1.0 is available here:
https://forum.latenightsw.com/t/setting-other-applications-keyboard-shortcuts-using-nsuserdefaults-defaults-not-updating/3537/5
I will be making some minor API additions & changes when I find the time, and will post the source code here in full at that time. Note that as mentioned above, Services shortcuts are stored using a completely different system & are not handled here.
i was using Fedora for about six months. Recently I have been changed to Ubuntu. And here in Ubuntu, there is no Code/Synatax for groovy in VI editor,which was actually there in Fedora VI. How to enable that? and if this not possible, then suggest me some good IDE's for Groovy(only for Groovy), so that i can increase my skill over the groovy language :):)
Don't suggest some advanced IDE, because this is the first time I'm going to use IDE in my life :)
If you want to stay with VI or rather VIM, there are two extensions that will help you developing Groovy scripts:
Syntax highlighting
File type detection - execute Groovy scripts using the F4-key