Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any keypress crashed rofi's calc mode #7

Closed
hjpotter92 opened this issue Jul 6, 2018 · 9 comments
Closed

Any keypress crashed rofi's calc mode #7

hjpotter92 opened this issue Jul 6, 2018 · 9 comments

Comments

@hjpotter92
Copy link

I build rofi-calc from source.

➜ sudo make install
make[1]: Entering directory '/home/hjpotter92/Documents/rofi-calc/build'
make[1]: Nothing to be done for 'install-exec-am'.
 /bin/mkdir -p '/usr/local/lib/rofi/'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   calc.la '/usr/local/lib/rofi/'
libtool: install: /usr/bin/install -c .libs/calc.so /usr/local/lib/rofi/calc.so
libtool: install: /usr/bin/install -c .libs/calc.lai /usr/local/lib/rofi/calc.la
libtool: warning: remember to run 'libtool --finish /usr/local/lib/rofi/'
make[1]: Leaving directory '/home/hjpotter92/Documents/rofi-calc/build'
➜ sudo ./libtool --finish /usr/local/lib/rofi/
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib/rofi/
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib/rofi/
.
.
.

when I actually run rofi-calc, it opens the rofi's dmenu but on any keypress it sends the signal 6:

➜ rofi -show calc -modi calc -no-show-match -no-sort

** (process:4869): ERROR **: Process errored with: Child process killed by signal 6
[1]    4869 trace trap  rofi -show calc -modi calc -no-show-match -no-sort
@PhilipTrauner
Copy link

Found the problem!
qalc tries to download currency metadata on first launch. If the $HOME/.qalculate folder does not exist and currency support is not explicitly disabled (-nocurrencies) this prompt will be presented to the user:

You need the download exchange rates to be able to convert between different currencies.
You can later get current exchange rates with the "exchange rates" command.
Do you want to fetch exchange rates now from the Internet (default yes)?

rofi-calc can't really deal with the prompt and crashes. I did not find a clean solution to skip the prompt, therefore I just forked the project and disabled currency support.

@svenstaro Should I open up a pull request? My fix definitely isn't a good solution, but at least it works 🤷‍♂️.

@svenstaro
Copy link
Owner

I will investigate. I had this problem too and thought I did something so it will always download the currencies without prompting.

@PhilipTrauner
Copy link

PhilipTrauner commented Jul 19, 2018

@svenstaro I think I know why it works on your end. The libqalculate Debian package is pretty old (0.9.7-9.2) while the Arch version is, to the surprise of absolutely no one, is very recent (2.6.1-1).

The newer versions don't present the prompt on first startup and also accept -version as a parameter to check which version is installed. The old ones do not support the -v argument, but interpret it as literal input, which doesn't really ease version detection efforts. The solution I'm proposing is to look for -v, -version in the -h output of qalc. If the search yields no results, disable currency conversion, if it does check the version and enable currency conversion based on that.

Another solution, which I'd consider the easiest to implement would be to just add an invocation of qalc to the installation instructions in the README.

Both solutions are somewhat hacky, but I can't really think of another way besides directly calling into libqalculate, which also doesn't really work around the problem with different versions.

@svenstaro
Copy link
Owner

From the releases page, it seems that the version in Debian is 8 years old. Do you really think that there is merit to supporting such an old version?

@PhilipTrauner
Copy link

Fair point. A semi-recent version is already present in the Debian experimental channel, and the version upgrade is seemingly blocked by a bug report filed in 2009. I'll contact the package maintainer and hope for the best.

I think denoting a minimum supported libqalculate version in the README would be useful regardless.

svenstaro added a commit that referenced this issue Jul 29, 2018
@svenstaro
Copy link
Owner

I added this to the README. Does this work for you?

@hjpotter92
Copy link
Author

hjpotter92 commented Jul 29, 2018

Recompiling and isntalling qalculate to /usr/bin/ (default install is to /usr/local/bin/) solved the issue.

Thanks a ton @svenstaro and @PhilipTrauner :)

Any ideas how I can configure rofi's combi to also work with rofi-calc? I'd like something similar to apple's launcher, which allows for calculations to be done from inside itself.

Right now, I use Ctrl-Tab to switch between calc and combi:

rofi.combi-modi:        window,drun,ssh,run
rofi.modi:              combi,calc
rofi.show:              combi

@PhilipTrauner
Copy link

@svenstaro Yep, looks good to me 👍

@svenstaro
Copy link
Owner

@hjpotter92 I invoke it like this:

rofi -show calc -modi calc -no-show-match -no-sort

I don't think mixing it into the combi would work very well. However, I'm currently building a new tool which also has graphing and all that really fancy stuff built in. I believe I've reached the extent of what rofi will support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants