Commit Graph

603 Commits

Author SHA1 Message Date
cyqsimon
4942647e1c Improve how we indicate that a command arg is optional 2023-08-21 21:26:17 +02:00
Henrik Friedrichsen
0c13afb46f Fix: fetch album only once
Should speed up display of the context menu

Fixes #1225
2023-07-23 14:49:21 +02:00
Henrik Friedrichsen
bef4742cec Remove duplicate album query 2023-07-23 14:49:21 +02:00
Flynn Duniho
924296ac52 Add add command for adding song to playlist (#1232)
* Add command for adding song to playlist

* edits for code style

* Return playlist dialog via `CommandResult::Modal`

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-07-22 16:03:21 +02:00
Henrik Friedrichsen
92cd4f1c8b Handle local tracks in playlist
- Show error on deletion, as we currently do not have a Uri we can pass to the
  Spotify API to delete local files in playlists
- Mark local files in `ListView`

fixes #1213
2023-07-22 15:42:14 +02:00
Henrik Friedrichsen
90b4560a2d Gracefully handle tracks without IDs
As reported in #1231:

Local files in playlists have no IDs. When trying to delete them ncspot crashes
as it tries to extract a track ID.
2023-07-22 15:42:14 +02:00
bentheklutz
2786c6ba34 Sort Artists Ignoring "The" (#1238)
* Sorting QoL

Ignore leading "The" when sorting albums and artists by artist name
in the library.

* Simplify stripping of `The ` prefix in artist

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-07-22 13:05:03 +02:00
Henrik Friedrichsen
66bb0746b6 Update to strum 0.25.0 2023-07-22 12:44:50 +02:00
Henrik Friedrichsen
83f9e8d224 Update dependencies 2023-07-22 12:31:26 +02:00
hrdl
f74661a15d feat: add save current command 2023-07-07 11:23:47 +02:00
Thomas Frans
0c93cafccf refactor: remove unused screenchange variable
The `screenchange` member variable on `Layout` didn't seem to be used
for anything except for debugging. A comment in `on_layout` makes it
seem like it wasn't meant to be used for debugging purposes but for
actual functionality that wasn't implemented.
2023-06-18 17:04:43 +02:00
Thomas Frans
d644397180 fix: forward mouse events inside layout
After refactoring layout, the if statements were removed in favor of a
single match. This changed the control flow a bit, breaking mouse event
propagation.
2023-06-14 23:03:25 +02:00
Thomas Frans
6c990b5bda fix: config option command_key not working 2023-06-06 20:44:14 +02:00
Thomas Frans
ac0bcb4420 fix: prevent tab switching from command line 2023-06-04 22:21:10 +02:00
Thomas Frans
bbd7bcf4aa fix: command line multi-byte prefix panic
Don't index into the command line command as the prefix can be altered
by the user and therefore be a multi-byte unicode character.
2023-06-04 17:30:06 +02:00
Thomas Frans
96bb2ea06b fix: '/' character not working in search view 2023-06-02 23:20:24 +02:00
Thomas Frans
6d2a0552bf refactor: move layout functionality under layout 2023-06-02 23:20:24 +02:00
Thomas Frans
d0efc0868f chore: fix Application::new documentation 2023-06-02 23:20:24 +02:00
Thomas Frans
0c97bd36c3 fix: remove ipc import on non-unix systems 2023-06-02 23:20:24 +02:00
Thomas Frans
c36d3cf272 refactor: move and add functions 2023-06-02 23:20:24 +02:00
Thomas Frans
04cbe8ac20 refactor: move base path config + documentation 2023-06-02 23:20:24 +02:00
Thomas Frans
6be45ece90 chore: document items in the config module
Sometimes the use of an item wasn't clear without reading the code. This
should help with that.
2023-06-02 23:20:24 +02:00
Thomas Frans
3b8de6600f refactor: move panic hook into module 2023-06-02 23:20:24 +02:00
Thomas Frans
abffb3c2a9 refactor: move cli argument parsing to main
Command line arguments are part of the OS process and should be under
main.
2023-06-02 23:20:24 +02:00
Thomas Frans
ae090b6073 refactor: move async runtime to application module
To have a clear distinction between code dealing with OS process
characteristics and code of ncspot itself, it makes sense to move the
async runtime together with ncspot as it doesn't have anything to do
with the OS process.
2023-06-02 23:20:24 +02:00
Thomas Frans
6d32f3d1f8 refactor: move 'global' data into Application
Some applications move their 'global' data into a struct called `App` or
`Application`. This makes it very clear what data belongs to the
'global' scope or in other words, to the application itself.
2023-06-02 23:20:24 +02:00
Henrik Friedrichsen
e6ed4ea024 Support multiple IPC sockets (#1171)
For instance for when multiple ncspot instances are running. In that case the
PID will be appended to the path, i.e. `~/.cache/ncspot/ncspot.20707.sock`.

Also ncspot will now delete the socket on shutdown.

Fixes #1158
2023-05-22 22:14:59 +02:00
cyqsimon
d8faa87431 Fix incorrect notification ID reuse on XDG (#1150)
* Fix incorrect notification ID reuse on XDG

* Remove `notification_id` persistence

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-05-22 17:51:29 +00:00
Thomas Frans
e9f34873b4 fix(ui): ListView decrement selected on remove
When removing an element, it is important to check whether it was the
last element in the list and decrement the selected index if so.
2023-05-12 21:07:53 +02:00
Jakub Jirutka
ba60fbddd0 Fix: breaking changes in rpostify 0.11.7 2023-05-09 10:36:04 +02:00
Callum Wishart
43a4883bd3 Update Nerdfont glyphs (#1141) 2023-05-04 23:43:50 +02:00
Henrik Friedrichsen
2771c319d6 Fix: gracefully handle invalid DBus setups
Some systems may have an ncspot binary with enabled MPRIS/DBus support, even
though DBus is not actually running on the system or the session is broken.

ncspot should not panic in such a situation, but handle gracefully instead.

Should help with #1139
2023-05-02 22:54:47 +02:00
Henrik Friedrichsen
d19d897e75 Fix: Restore previous Previous behavior (#1111)
* Fix: Restore previous `Previous` behavior

Fixes #1110
2023-04-04 14:54:32 +02:00
Henrik Friedrichsen
b0db0da3ef Rewrite MPRIS implementation using zbus (#1107)
* Rewrite MPRIS implementation using zbus

The initial DBus implementation was getting harder to maintain and `zbus` offers
some nice convenience features that should make our MPRIS implementation
cleaner.

For now this only implements the `org.mpris.MediaPlayer2` interface which does
not do much.

Should help with #1103

* Implement MPRIS properties

- `PlaybackStatus`
- `PlaybackRate`
- `Volume` (get/set)

* Implement remaining player properties/functions

* Emit signal for changed properties on track change
2023-04-01 21:53:37 +02:00
Thomas Frans
8fe30e34d0 Emulate double click to play items
Change the behavior of `ListView` to treat a click on an item that is
already selected as a double click. It allows the user to play songs
(not episodes since currently it's not possible to determine if a
`ListItem` is an episode) by "double clicking" them. It is a bit of a
hack, but it works pretty well. A possible downside is that when people
that don't like mouse integration in a TUI click to focus the terminal
window, it could jump to the song they clicked if that happened to be
the selected one.
2023-03-25 23:53:19 +01:00
Collin Lefeber
dcfb820c13 statusbar: update nerdfont glyphs
As of https://github.com/ryanoasis/nerd-fonts/issues/1096
nf-mdi* glyphs are marked obsolete in nerd-fonts upstream

Update the glyphs to non-deprecated nf-fa* counterparts
2023-03-19 00:21:29 +01:00
BlakeJC94
1a0258f197 Add vim-like page scrolling
* feat: added match fallback for handle_command SelectViewExt

* feat: HalfPage and FullPage MoveAmount variants

* feat: Display for MoveAmount variants

* feat: fallback for MoveAmount variants in TabView

* feat: ListView FullPage/HalfPage MoveAmount

* feat: default keybinds for page scrolling

* feat: HalfPage/FullPage MoveAmount for HelpView

* feat: removed new defaul keybinds for pagescroll

* style: "upwards" -> "halfpageup" etc.

* feat: toml parse "move pageup" / "move halfpageup"

* chore: cargo fmt

* feat: simplified page scroll command interface

* docs: added `move` to readme

* feat: replace FullPage and HalfPage with Float variant

* fix: remove stray variant

* dosc: update move command

* chore: fmt

* feat: implement MoveAmount::Float for selectview

* chore: fmt
2023-03-12 13:26:00 +01:00
Henrik Friedrichsen
3a460ea4ad Revert "Display shuffle order"
This reverts commit e68f50ddff.

Will be reintroduced with #1075
2023-03-09 19:34:13 +01:00
Thomas Frans
e8adff444c Automatic shell completion generation
* Add automatic shell completion generation.
Add automatic generation of shell completion scripts for various shells
(the ones supported by `clap_complete`). The scripts can be generated
using the `generate-shell-completion` xtask, which outputs the shell
script to stdout.

* Improve shell completion generation xtask.
General improvements to both the shell completion generation as well as
the xtask package itself. Update the README to match the new additions.
2023-03-09 19:02:11 +01:00
Thomas Frans
b27e84a386 Add manpage generation using xtask
* Add manpage generation.

* Hide xtask compilation info.
This changes the default behavior of the `cargo run` command for xtasks
to hide the compilation info. This makes sense as xtask's are run as a
program, and showing the compilation info every time clutters stdout
with unrelated info.

* Move ncspot's `clap::Command` to `lib.rs`.
Moving the `clap::Command` used internally by ncspot to a library allows
it to be easily shared between different packages (xtask and ncspot
itself).

This commit also reworks the xtasks to use clap for parsing the xtask
arguments, which simplifies writing new xtasks.

* Make `generate-manpage` `--output` optional.
When more xtasks get added, it would make sense to have a `generate-all`
subcommand that executes all xtasks, which wouldn't be able to have
options for every separate subcommand. Therefore the `output` argument
should be optional, and by default output to the `misc` directory which
contains extra metadata files already.

* Add packaging info to `README.md`.
Update the README to include information for packagers. The information
includes provided files as well as info on how to generate some of them.
2023-03-06 21:55:19 +01:00
Thomas Frans
0c5693c426 Disable autojump for add to playlist dialog.
Autojump seems to take precedence over regular keys, which isn't the
wanted behavior, especially when there are playlists in the list that
contain some of the most common Vim keybindings. For example when there
is a playlist called 'jazz', pressing `j` will jump to that playlist
instead of going down.

This commit disables autojump for now. If search inside the add to
playlist dialog would be a wanted feature, it could be implemented using
the default Vim search button `/` which would work the same way as
searching in other lists works right now.
2023-03-05 00:04:09 +01:00
Thomas Frans
98a0596c70 Change unnecessary usage of Arc to borrow instead
Some basic cleanup of function signatures that took ownership of their
parameters, even though they didn't need ownership. Switching over the
usage of `Arc` to a normal borrow has the added benefit of cleaning up
the code a bit since now a reference can be given instead of having to
clone the values. The other benefit is that a lot of clones aren't
necessary anymore. It's not going to have noticable performance
benefits, but it is still a good thing to have less clones all over the
code.
2023-03-05 00:02:25 +01:00
Thomas Frans
e68f50ddff Display shuffle order 2023-03-01 12:02:10 +01:00
inemajo
c2e030c2f0 Allow executing program to retrieve credentials
* config / authentication: permit to call external program for getting credentials

You can add into your ncspot/config.toml like this:

```
creds_username = "mylogin"
creds_passeval = "pass my_pass_path_to_spot_password"
```

Or using any password manager who send your password.to stdout.
If a newline is detected it will be automatically removed

* Move credential commands into separate structure

Also add an option for a username command

* Document credential commands

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-03-01 11:28:11 +01:00
Thomas Frans
9ca72e391d CI/CD: Add clippy and update actions
* Add clippy to CI.

* Update .github/workflows/ci.yml

* Update .github/workflows/ci.yml

* Use `cargo check` instead of `cargo build`

* Update CD workflow

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-02-28 22:49:32 +01:00
inemajo
801e847c88 commands: Adding "disconnect" command to force socket shutdown (#1057)
* commands: Adding "disconnect" command to force socket shutdown

* Rename to `reconnect`

* Add documentation to README

Related to: #628 #1033

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
2023-02-26 20:46:41 +01:00
Jonas Wunderlich
e8d652cc78 Always pass cover URL to notification
Regardless of the `cover` feature
2023-02-24 18:30:10 +01:00
Thomas Frans
a3c4989571 Switch from MM:SS to HH:MM:SS duration representation if needed
* Contidionally switch from MM:SS to HH:MM:SS duration representation if needed.

* Correct tiny style issue.

* --amend
2023-02-17 09:22:12 +01:00
Thomas Frans
829b799cc5 Fix clippy warnings. 2023-02-16 13:33:56 +01:00
Henrik Friedrichsen
8222f1b2e4 Use variables directly inside format strings
Most systems should have an up to date Rust compiler by now, so we should be
fine.
2023-02-06 20:15:43 +01:00