Saturday, February 22, 2020

CopyQ for the impatient - Introduction

CopyQ is a really handy clipboard manager. As its name suggests, it enables you to easily return to previous items in your clipboard, but as you will see later, it offers much, much more. Thanks to its scripting capabilities, it is also a handy automation tool. I'm a big fan of CopyQ and I think it deserves more promotion, so I decided to create this, hopefully useful wrap-up.

Why to use it, and not something else?


On AlternativeTo, CopyQ holds the 2nd position with 162 likes at the time of writing. The 1st place is occupied by Ditto with 304 likes, but Ditto has one big disadvantage: it is only for Windows. For me, CopyQ is also much better when it comes to options of running custom commands (scripting). Both apps are free and open source.

When talking about Windows, since a recent Windows 10 build, you might use their built-in clipboard manager as well (just try to press Win+V if you own one). But even without trying out, I'm sure it will be pretty much behind CopyQ & co. when talking about productivity-boosting features for advanced users - just read on!

Features


Firstly, to make a basic idea of the app, here is a screenshot of its main window:

An example of CopyQ's main window, illustrating some basic terms.


Here are the main distinguishing traits of CopyQ:
  • Runs and offers the same interface on Linux, Mac and Windows.1
  • Supports images as well as formatted text.
  • You can search the clipboard history easily (supports regular expressions).
  • It has a simple built-in editor of clipboard items.
  • You can control what gets into the clipboard history. And of course, the history is persisted among computer restarts.
  • If you want, you can control it from command line as well.
  • Nearly endless possibilities of customization, including running custom commands (see Commands).
  • A superb documentation (see Documentation).
And to mention some advanced "enterprise" features:
The only nice-to-have feature which is missing, is probably an automated synchronization of commands across multiple machines (e. g. in a company)...

Basic setup


So now that we know what CopyQ can do, how to make it run on our machine? We start by downloading an installer or a portable archive - simply follow the installation instructions.

Once the CopyQ is installed and running, we set a global keyboard shortcut for showing the CopyQ's main window. Firstly, we need to open the Configuration dialog from the system tray:


Secondly, we set the shortcut in the opened dialog:


Here we inspired from Ditto's default shortcut, which is Ctrl+` - i. e. hold down Ctrl and press the back-quote (tilde = ~) key.2

In the same dialog, we can choose whether we want immediate pasting after selecting a clipboard item from history, or not:



Add a tab for your favorite snippets


Next, we might want to add a tab for keeping our favorite code snippets (as seen on the very first picture above), or whatever we intend to use it for. This is as easy as pressing Ctrl+T in the main window:



Done!


Now we can just enjoy the CopyQ, let it maintain the clipboard in the background and use its main window and/or shortcuts whenever we need to return to a previous clipboard item, for example. The GUI and default shortcuts are pretty intuitive, so luckily there's only little to learn for the basic usage.

Documentation


CopyQ has a pretty good documentation and this post is definitely not meant to be its replacement. Beware though that there are some little gotchas:

  • The project's home page on Github contains some overlapping information (e. g. installation steps). And it is only here where you can see a quick overview of app's features.
  • If you by coincidence get to a project's wiki page like Basic Usage, run away - it got deprecated and replaced by the newer documentation.

Commands


Attention: It gets a little bit more technical in here!

Pressing F6 in the CopyQ's main window takes you to the management of commands:

An example of the Commands window. It shows the source code of one of the many built-in commands (selected & inserted via the "Add" button). Properties of the command are set in the "Advanced" tab.


While working with commands in CopyQ is great and thoroughly documented, I miss a quick overview of some concepts for newbies. So here is my little attempt to fix that (You might still want to read the official glossary page first.):

  • Commands are either built-in, or user defined. Every command is actually a readable script (with some necessary metadata - options). For the impatient: see this paragraph for various forms of the command scripts.3
  • Every command may be run in different contexts depending on what checkboxes get selected in its "Type of Action" options section. That is:
    • automatic (when there's a new clipboard item)
    • in menu (to run it over selected item(s); a shortcut may be assigned)
    • global (to run it at anytime when needed; a global shortcut may be assigned)
    • display (changes how items look like in the main window)
    • script (changes the default set of available functions, so a more precise name would be an "extension script")
  • If you don't see a built-in command, you need to explicitly add it to available commands via the Commands window (F6). Or, you can achieve the same effect by assigning a shortcut to the command in the Configuration dialog (Ctrl+P).
  • The Action Dialog dialog (F5) lets you run an ad-hoc command script instead of an existing named command. You have to explicitly select a "Standard input" for passing the content of selected item(s) to the script.
    Here's an example, showing a rather improbable scenario of converting a URL address to uppercase:

All-in-all, with CopyQ commands you can do lots of interesting stuff and there are many ways of how to create and use them. There is even a library of commands from the author(s) in a dedicated Github project called copyq-commands. Maybe in another post we will take a closer look at this!

Follow-up article: CopyQ - The most useful commands.

1 Ordered alphabetically.

2 Beware though that a keystroke which includes a key that maps to different characters based on the current keyboard layout (like Ctrl+`) doesn't have to work under all circumstances. See issue 1323 for more details.

3 As you may have guessed, the "copyq:" scripts are written in ECMAScript and you can call built-in CopyQ functions from them. So if you are familiar with JavaScript, you'll be like at home here.

Sunday, November 10, 2019

Being active in communities

If by a pure coincidence someone ever watched this blog, he may think for example that I gave up writing new posts. It's not quite like that. Maybe I got a little lazier, my priorities changed over time. But I was also a little bit more active in communities - and this is the topic I would like to write about this time - to give you some ideas of what and why, plus some real life examples.

Active in communities - what's that?


If you haven't guessed already, I mean software communities. And by being active in them, I mean direct communication with the authors or other users of a concrete piece of software, being it an application, library, framework or whatever else. Such communication is done via authors' bug tracking system, forum or for example by email if there is no better way.

When you do this, you typically report a problem, help to solve a problem, vote for solving a problem, or simply just ask a question. Some call this a contribution and such a contribution is usually expected to be useful - no trolling nor unintended stupidity is welcome. So better be prepared to formulate your thoughts well in this area.

Why being active?


Just a few paragraphs and we are already getting to the core of what I want to share with you. I'm so proud of my conciseness sometimes! ;)

So what's the point of being active in the communities? I can see several reasons:
  1. Better than to curse. Contributing has usually more positive effect than just to curse the software or their authors.
  2. Improvement of the software. More or less directly, your action may lead to improvement of the software or its documentation. If nothing else, then at least you somewhat increased awareness of some problem. And if there are enough people claiming the same, someone grabs the it and fixes it. A nice example: Eclipse 4 broken perspectives (Thanks to Andrey Loskutov for undertaking this software maintainers' nightmare!).
  3. Learning. You learn more about the software you use and you learn to express your thoughts in a clear way. You may also improve your language skills.
  4. The effect you wish. You may blog, tweet, etc., about the problem, but depending on your impact area this doesn't have to have the effect you wish. An example: I blogged about a very unwelcome Maven artifacts resolution "feature", but as I know that no one actually reads this blog, I linked to the post from the corresponding bug tracker issue.
  5. Easier than maintaining your local clone. It's not unusual that when you work with open source software, you make your locally maintained clone of it and put your custom features or bug fixes into the clone. Depending on your or your company strategy, this may suffice.
    But it turns out that contributing your patch to the original authors may be better because of all the positive side effects of doing so (easier or no merging of the changes when upgrading, authors or the community may give you a helpful feedback, maybe even tell you you are doing it wrong, etc.).
  6. Good feeling from doing something for the people and for the world. :) This may sound like a cliche, but let's have a deeper look at this...
    This is probably a topic for a separate post, but have you ever heard about Green Computing / ICT? Unfortunately there is plenty of software in our daily use that consumes resources for no good reason. Take for example all those background processes which start up your computer fan when you leave your computer idle for a while - this is nothing wrong if it takes some finite time. But when it has no end, such software needs to be considered broken, senseless and thrown away. It's like ordering a service for your company and the supplier tells you that it can deliver the service only when you stop all the work for 4 hours every day! Again, an example taken from an open source product which I quite appreciate otherwise: Alfresco CMS and its Solr indexing craziness.

More examples from practice


In the preceding text you could already read some real life examples of interaction with some of my favorite software products like Eclipse, Maven or Alfresco. Let's have a look at another interesting ones:

Activity with Jira


Well, Jira is surely a great bug tracking and projects management system, even when it isn't open sourced. Still, it has got some gotchas - long outstanding issues which kinda surprise me. (Add to this that Jira authors recently decided to completely "modernize" the good old main menu, which was quite loudly rejected by lots of users - I haven't watched the story for some time though...)

I think Jira is an example of where the results coming from community activity are often close to zero - a typical resolution of many issues is Won't Fix, without any useful explanation or workaround. And this is done even for issues which are both seemingly easy to resolve as well as highly upvoted, even by paying customers.

It starts with relatively small feature requests like:
  • Mousing over custom field name on view issue page shows only the field name in the tooltip, not the field description - JRASERVER-28503 (from 2012)
  • Unable to change issue link type - JRASERVER-3097 (from 2004!)
And it ends with some long outstanding WTF bugs (I mean: "How can they even exist in such an application?".). To name some that I have also participated in:
  • Unable to edit an issue when the user is deactivated - JRACLOUD-38412 (from 2014; after 5 years things seem to start moving - success finally?!)
  • Changing Default language and creating a new project creates unwanted Issue Types and Resolutions - JRASERVER-43539 (from 2015; a duplicate was created in 2018 and closed as well; hopefully a minor impact though)

Activity with KeePass


I don't use KeePass for that long, but after using it for a while I noticed an apparent security issue with passwords still being visible after KeePass restart - #2462. Even though I had to remind the issue to authors, a new option was implemented pretty quickly afterwards. The old behavior was not changed as I suggested, but be prepared that you can't always get all what you want - the final decision is always left to the authors.

And that was probably the final thought of this blog post. What do you think about the community contributions? Do you have some other or different experience?

Sunday, January 20, 2019

The biggest WTF new "feature" I've ever seen?

This is mainly to those familiar with Maven, the build and dependency management tool. Also a kind of "open letter" to the Maven authors. The tool itself is great, all respect to its authors. But let's just jump straight to the problem now...

The new feature, or better say problem


Since Maven 3.0 (year 2010), while building your project at work, you download some regular dependency, say from your company Nexus repository, you take your notebook home, where you don't have access to that repository, and out of the blue, Maven starts telling you the dependency is not there in your repository, in exactly the same like when you have never downloaded it at all. Still, you can see the dependency artifact in your local repository on the disk. But Maven won't build your project anymore, isn't that a nice new feature? ;)

How to make Maven work again


Luckily, there's a way out, you need to activate so called "legacy mode" for your repository:

a) put "-Dmaven.legacyLocalRepo=true" to your "MAVEN_OPTS" environment vairable,
b) pass an option "-llr / --legacy-local-repository" to the "mvn" command

Alternatively, you can remove "_maven.repositories" (or "_remote.repositories" since a newer Maven version) files from your local repository as the last resort.

And because Maven authors failed to at least introduce a special switch to disable just this academically useful "where did the artifact come from? is that repository still accessible? if no, I will fail the build, even if it is a released artifact version which should never ever change" check, you also get the following uncompromising warning whenever you build with "legacy mode" activated:

Disabling enhanced local repository: using legacy is strongly discouraged to ensure build reproducibility.

Isn't that nice as well? Because what you strive for actually is something like "build reproducibility". And you have no other simple way of achieving this than to activate that "legacy mode" (or playing around with those files which should be considered internal to Maven).

After 9 years...


Many years passed since the described problem arose. It is also evident from various reported bugs and forums that the community (read: people using Maven for serious work) didn't accept the problem and I do think that the majority wants the original (read: sane) Maven behavior back. Still, Maven authors seem to do nothing about it. So this problem keeps confusing, sooner or later, every new Maven adopter.

I wouldn't say a thing if there was at least some progress, but I just cannot see it anywhere after all the years. It's just me guessing, but it feels like one of those situations when one invests lots of work into some cool stuff, but then it turns out not to be so cool. Logic says you should throw the stuff away, but emotions tell you it is your little perfect baby and you won't abandon it that simply.

So in the light of what was said and written (and there are tons of it!), I beg you please, Maven authors, please go and let your baby go in an upcoming Maven version soon. Hopefully not only me will thank you... :)

Some of the reported bugs so far