Make Qutebrowser download in specific directory
0
votes
0
answers
34
views
#### General overview
The goal is to make Qutebrowser store downloads in a subdirectory of
~/downloads
named after the ISO date of the day when the download happend.
#### What I alredy did
In my ~/.config/qutebrowser/config.py
, I made this function:
def setDownloadDirectory():
import os
from datetime import datetime
# Formater current date
today = datetime.now().strftime('%Y-%m-%d')
download_dir = os.path.join(os.path.expanduser('~/Téléchargements/www'), today)
# Create the directory if any
if not os.path.exists(download_dir):
os.makedirs(download_dir)
# set the new directory
c.downloads.location.directory = download_dir
setDownloadDirectory()
So, yes, when I try to download something I get the desired behaviour, Qutebrowser suggest ~/Téléchargements/www/2025-06-07/
as download directory, as desired.
#### The problem
So, what’s the problem? Well their is two main problems:
1. The date is set to the moment when Qutebrowser was opened and not to the moment when the download happens. Let’s suppose I open Qutebrowser at 23:50, the directory will be set to /2025-06-07
and the downloads who will happens at 24:01 or latter in the next day will still on /2025-06-07
directory.
2. The day’s directory is immediately created at the moment when Qutebrowser starts, not when a download happens. So it could open multiple empty folders for the times I just opened Qutebrowser without asking any download.
#### The question
Is it possible to run setDownloadDirectory()
only when some events are triggers like when a download is asked?
It will ensure that the date is really the moment when the download happens and also create a directory only if needed.
Asked by fauve
(1529 rep)
Jun 7, 2025, 02:09 PM