A programmable scratchpad

Notepad Plus

© Lead Image © IKO, Fotolia.com

© Lead Image © IKO, Fotolia.com

Article from Issue 245/2021
Author(s):

Boop, a digital scratchpad, lets you convert data from your desktop instead of exposing confidential data online. You can even extend Boop with your own functions using JavaScript.

If you need to count words or lines of text, calculate checksums and hashes, optimize program code, or perform any other conversion function, you can easily find an online source to do just that. However, you may not want to copy and paste confidential data to a potentially dubious website.

Instead, Boop [1], a digital notepad that can be scripted, performs this task locally. The open source program originally developed for macOS supports typing or pasting text via clipboard. At the touch of a button, a variety of predefined scripts or even your own small programs can then be applied to the entered text. This means that all the data stays on your computer, and you can save yourself the trouble of searching for the right utility online.

With the release of Boop-GTK [2], a port to the GTK toolkit, Linux and Windows users can now use Boop. The still very young application is not currently listed in the package sources of the major Linux distributions, with the exception of a boop-gtk entry in the Arch User Repository (AUR) for Arch Linux. Users of other distributions need to build the program from the source code or use the Snap [3] or Flathub packages [4] provided by the project.

Scriptable

Fundamentally, Boop works the same way regardless of the task: Copy text or code into the application window or type directly in the editor area, and then activate the script dialog via Ctrl+Shift+P. In the subsequent selection dialog, you can choose between (as of the editorial deadline) 59 different scripts (Figure 1).

Figure 1: If you frequently work with text, you can use Boop to count the number of characters, words, or lines.

The scope of these scripts ranges from Add Slashes (which prepends a backslash to certain special characters like '"\, or NUL) to a feature that makes converting localization strings between iOS and Android formats easier. The search field in the dialog header lets you easily filter out a specific function.

For example, web developers can clean up CSS files with Format CSS, prepare text for websites using HTML Decode and HTML Encode, or compress CSS markup via Minify CSS. You can then use Format CSS again to transform the optimized CSS code back into a readable format (Figure 2).

Figure 2: Boop optimizes CSS code or converts the compressed code back into readable text.

Developers who specialize in programming applications can use Eval Javascript to execute JavaScript directly in the context of Boop and view the output (Figure 3). Similar to CSS code, Boop can also minimize JSON and XML and unpack them accordingly, as well as transform JSON into various other formats.

Figure 3: Use Eval Javascript to execute JavaScript code in the application window.

Various text functions like Camel CaseKebab Case (all words connected by minus signs), Snake Case (connected with an underscore), Sponge Case (random uppercase/lowercase), Markdown QuoteReverse Lines, and Reverse String complete the repertoire for editors. If required, MD5 checksums or hash values (SHA-1, SHA-256, and SHA-512) can also be calculated for the entered data.

Add Your Own

If you are missing a certain function, it can be integrated -- with the appropriate know-how -- directly into Boop. For this purpose, the Open Config Directory option in the hamburger menu in the upper right corner opens a file manager with the ~/.config/boop-gtk folder. Boop automatically loads JavaScript files stored in the scripts/ subfolder into the application at program launch time.

For suggestions and details on how the scripts work, use the Get More Scripts menu item. It loads the GitHub repository maintained by the original Boop developer in your browser. You will find a number of scripts that have not yet made it directly into the program [5]. You can use these examples as a template to write your own script.

The Boop project also shows an example script on its homepage: The Poopificator randomly replaces words with a poop emoji [6] -- if that's a function you need. To do this, transfer the contents from Listing 1 to a new file named poop.js, and then move it to ~/.config/boop-gtk/scripts/. After restarting Boop, you will find a new entry named Poopificator under the action drop-down menu.

Listing 1:

Listing 1

poop.js

01 /**
02   {
03     "api":1,
04     "name":"Poopificator",
05     "description":"Swaps random words with poop emojis.",
06     "author":"Ivan",
07     "icon":"html",
08     "tags":"poop,emoji,hashtag"
09   }
10 **/
11
12 const poopFactor = 0.2
13
14 function main(state) {
15   var all = state.fullText.split(" ")
16   state.fullText = all.map(x => r() ? x : "& 128169;”).join(" ")
17 }
18
19 function r() {
20   return Math.random() >= poopFactor
21 }

The Poopficator action now replaces random words with the HTML code & #128169;. You then use a second action, HTML Decode, to turn the HTML snippets into the desired emoji (Figure 4). The script in Listing 1 requires the second action, because Linux Magazine uses typesetting software that does not allow this type of special character. If you transfer the script directly from Boop's project page, the second action is unnecessary.

Figure 4: Using the Poopificator sample script to extend Boop's feature set.

Conclusions

If you rely on web services for one or more functions discussed here, Boop offers a useful local solution. The program works without Internet access, requires fewer resources than a web browser, and all data remains on your computer. In addition, the Boop community continually adds new functions. And if you can't find the function you need, you can add your own scripts with some basic programming knowledge.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News