executable_firefox-guile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/run/current-system/profile/bin/guile \
  2. --no-auto-compile -e (firefox) -s
  3. !#
  4. ;;;; firefox --- SYNOPSIS
  5. ;;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
  6. ;;;; Released under the GNU GPLv3 or any later version.
  7. (define-module (firefox)
  8. #:use-module (json)
  9. #:use-module (srfi srfi-37)
  10. #:export (main))
  11. ;;; Commentary:
  12. ;;;
  13. ;;; DESCRIPTION
  14. ;;;
  15. ;;; Code:
  16. (define %options
  17. (let ((display-and-exit-proc (lambda (msg)
  18. (lambda (opt name arg loads)
  19. (display msg) (quit)))))
  20. (list (option '(#\v "version") #f #f
  21. (display-and-exit-proc "firefox version 0.0.1\n"))
  22. (option '(#\h "help") #f #f
  23. (display-and-exit-proc
  24. "Usage: firefox ...")))))
  25. (define %default-options
  26. '())
  27. (define %home
  28. (and=> (getenv "HOME")
  29. (lambda (home)
  30. home)))
  31. (define %mjru
  32. (string-append %home "/.config/mjru/firefox.scm"))
  33. (define %sql-query
  34. `(,`("Groups"
  35. ,@(load %mjru)
  36. ("Default Group"
  37. ("Modified" . 1624594397582)
  38. ("Type" . "local")
  39. ("Words" . #())
  40. ("DontShowOn" . #())
  41. ("ShowOn" . #())
  42. ("FindWords" . #t)
  43. ("Enabled" . #t)
  44. ("ShowInEditableFields" . #f)
  45. ("Fcolor" . "#000")
  46. ("Color" . "#ff6")))
  47. ("PerformanceSetting" . 100)
  48. ("Donate" . 1626322397582)
  49. ("PrintHighlights" . #t)
  50. ("ShowFoundWords" . #t)
  51. ("neverHighlightOn" . #())
  52. ("Version" . "13")))
  53. (define %origin-key
  54. "78bc100e424d-6909-d8c4-5f4e-f0724f7c.:moz-extension")
  55. (define %webappsstore
  56. (string-append %home "/.mozilla/firefox/j56dvo43.default-1520714705340/webappsstore.sqlite"))
  57. (define (main args)
  58. (define opts
  59. (args-fold (cdr (program-arguments))
  60. %options
  61. (lambda (opt name arg loads)
  62. (error "Unrecognized option `~A'" name))
  63. (lambda (op loads)
  64. (cons op loads))
  65. %default-options))
  66. (system*
  67. "sqlite3"
  68. %webappsstore
  69. (format #f "SELECT * FROM webappsstore2 WHERE originKey = ~s"
  70. %origin-key))
  71. (system*
  72. "sqlite3"
  73. %webappsstore
  74. (format #f "UPDATE webappsstore2 SET value = '~a' WHERE originKey = ~s"
  75. (scm->json-string %sql-query) %origin-key)))
  76. ;;; firefox ends here