Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does anyone know how to reliably use Firefox from command line to take screenshots? It used to work well a few years ago but now it does not. For one, it asks that Firefox is already running and I need to kill it. This is surprising -- why can't two Firefox processes run at the same time?


It is whining about the shared use of your main profile directory. You can give it a temporary profile directory to more clearly express your intentions via "--profile=/tmp/$(uuidgen)" or similar. I'd guess you could even just straight up point <<env HOME=$(tmpdir) firefox --screenshot...>> for even stronger isolation


The CLI has long had `-noremote` for a long time to tell it you want a second Firefox. It's useful with `-ProfileManager` or `-P $profileName` for multi-profile workflows, which are out of fashion this decade, especially with Multi-Account Containers being able to do most of those workflows in the same browser window now with different tags. But some of us still have ancient profiles for ancient reasons and ingrained habits regarding them.

Ancient documentation: https://www-archive.mozilla.org/docs/command-line-args.html


  PROFILEDIR="$(mktemp -d)"
  firefox --no-remote  --profile "$PROFILEDIR" --screenshot $PWD/output.png https://xkcd.com
  rm -r "$PROFILEDIR"
(You don't have to create and destroy a profile directory every time, but it's cleaner to do that way and you need one per instance you're going to run anyways)


Script with Playwright?


Use playwright?




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: