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

Use clifm as qutebrowser file picker #305

Closed
jonnieey opened this issue Sep 4, 2024 · 3 comments
Closed

Use clifm as qutebrowser file picker #305

jonnieey opened this issue Sep 4, 2024 · 3 comments

Comments

@jonnieey
Copy link

jonnieey commented Sep 4, 2024

Describe the bug
Cannot select file in qutebrowser

To Reproduce

~/.config/qutebrowser/config/py

c.fileselect.handler = "external"
c.fileselect.single_file.command = [
    "st",
    "-e",
    "/home/$USER/.config/clifm/plugins/call_file_picker.sh",
]
$HOME/.config/clifm/plugins/file_picker.sh
# Options to be passed to clifm
p() {
	CLIFM_OPTIONS=""

	clifm "$CLIFM_OPTIONS"
	sel_file="$(find "${XDG_CONFIG_HOME:-${HOME}/.config}/clifm/profiles" -name 'selbox*')"
	if [ -z "$sel_file" ]; then
		sel_file="$(find /tmp/clifm-$USER -name 'selbox*')"
	fi

	if [ -f "$sel_file" ]; then
		cmd="echo"
		while [ -z "$cmd" ]; do
			printf "Enter command ('q' to quit): "
			read -r cmd
		done

		[ "$cmd" != "q" ] && sed 's/ /\\ /g' "$sel_file" | xargs $cmd
		rm -- "$sel_file"
	else
		printf "No selected files\n" >&2
	fi
}
p
~/.config/clifm/call_file_picker.sh
#!/bin/bash

# The path to your file_picker.sh
FILE_PICKER_SCRIPT="$HOME/.config/clifm/plugins/file_picker.sh"
# Check if the file exists
if [[ -f "$FILE_PICKER_SCRIPT" ]]; then
    # Source the script
    source "$FILE_PICKER_SCRIPT"
else
    echo "Error: file_picker.sh not found at $FILE_PICKER_SCRIPT" >&2
    exit 1
fi

Expected behavior
Select file, quit and file is selected in qutebrowser.

Desktop (please complete the following information):

  • OS: Archlinux
  • Terminal: st (suckless)
  • CliFM version 1.20.5
  • Installation source: AUR (clifm-git)
  • qutebrowser version 6.7.1 (pyQt6)

Additional context

Using nnn -p - works which outputs to same as above script

@leo-arch
Copy link
Owner

leo-arch commented Sep 5, 2024

Hi @jonnieey. Got it working as follows:

~/.config/qutebrowser/config.py

c.fileselect.handler = "external"
c.fileselect.single_file.command = ['st', '-e', 'clifm', '--sel-file={}']

After clifm is launched, select the file you want and exit. That's it.

No plugin required!

@leo-arch
Copy link
Owner

leo-arch commented Sep 5, 2024

You can also use the new file_picker plugin as follows:

~/.config/qutebrowser/config.py

c.fileselect.handler = "external"
c.fileselect.single_file.command = ['/path/to/file_picker.sh']

The plugin defaults to xterm as terminal emulator. Edit the plugin file and set CLIFM_TERM to your preferred terminal. You can also set CLIFM_TERM as environment variable.

It is recommended to copy file_picker.sh to your local plugins directory (~/.config/clifm/plugins/).

Consult the documentation for more information.

@jonnieey
Copy link
Author

jonnieey commented Sep 5, 2024

thanks, confirm the above solution works, thanks.

closing this.

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

No branches or pull requests

2 participants