2023-12-01 09:50:45 -05:00
|
|
|
#!/usr/bin/env bb
|
|
|
|
|
|
|
|
(require
|
|
|
|
'[babashka.fs :as fs]
|
2023-12-01 16:02:46 -05:00
|
|
|
'[clojure.string :as str])
|
|
|
|
|
|
|
|
(def user (System/getenv "SUDO_USER"))
|
2023-12-01 17:53:07 -05:00
|
|
|
(def home (str "/home/" user))
|
2023-12-01 09:50:45 -05:00
|
|
|
|
|
|
|
;;todo: import from base.clj
|
|
|
|
(defn- safe-sh [& commands]
|
|
|
|
(as-> (apply shell/sh commands) $
|
|
|
|
(if (= (:exit $) 0) $ (throw (Exception. (:err $))))))
|
|
|
|
|
2023-12-01 16:02:46 -05:00
|
|
|
(defn- safe-sh-as-user [& commands]
|
|
|
|
(safe-sh "su" "-c" (str/join " " (map #(if (str/includes? % " ") (str "\"" % "\"") %) commands)) user))
|
2023-12-01 09:50:45 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
(defn- setup-spacemacs []
|
2023-12-01 15:24:33 -05:00
|
|
|
;; installing spacemacs
|
|
|
|
(println "setting up spacemacs..")
|
|
|
|
(-> (fs/file (str home "/.emacs.d")) (fs/delete-tree))
|
|
|
|
(safe-sh "git" "clone" "https://github.com/syl20bnr/spacemacs" (str home "/.emacs.d"))
|
|
|
|
(safe-sh "chown" (str user ":" user) "-R" (str home "/.emacs.d"))
|
|
|
|
(println "spacemacs set up"))
|
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
(defn- setup-android-scripts []
|
2023-12-01 16:02:46 -05:00
|
|
|
(let [android-scripts-dir (str home "/Projects/android-scripts")]
|
|
|
|
(fs/create-dirs android-scripts-dir)
|
|
|
|
(safe-sh "git" "clone" "ssh://git@git.schro.fi:4242/schrofi/android-scripts.git" android-scripts-dir)
|
|
|
|
(safe-sh "chown" (str user ":" user) "-R" android-scripts-dir)))
|
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
(defn- setup-i3 []
|
|
|
|
(println "setting up i3..")
|
|
|
|
(println "clearing xfce keyboard bindings..")
|
|
|
|
(as-> (safe-sh "xfconf-query" "--channel" "xfce4-keyboard-shortcuts" "--list") $
|
|
|
|
(:out $)
|
|
|
|
(str/split-lines $)
|
|
|
|
(doseq [property $]
|
|
|
|
;;we actually need to ignore errors here, as we will hit a few undefined properties
|
|
|
|
(shell/sh "xfconf-query" "--channel" "xfce4-keyboard-shortcuts" "--property" property "--set" ""))))
|
2023-12-01 16:02:46 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
;;todo: fetch spacemacs
|
|
|
|
;;todo: disable locking when closing lid on ac
|
|
|
|
(println "applying configuration..")
|
2023-12-01 16:02:46 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
;;(setup-spacemacs)
|
2023-12-01 09:50:45 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
;;change shell to fish
|
|
|
|
(safe-sh "chsh" "-s" "/usr/bin/fish" user)
|
|
|
|
(println "changed shell to fish")
|
2023-12-01 15:24:33 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
(safe-sh-as-user "git" "config" "--global" "user.name" "Florian Schrofner")
|
|
|
|
(safe-sh-as-user "git" "config" "--global" "user.email" "florian@schro.fi")
|
|
|
|
(println "changed git user data")
|
2023-12-01 15:24:33 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
(setup-i3)
|
|
|
|
(println "set up i3")
|
2023-12-01 09:50:45 -05:00
|
|
|
|
2023-12-01 17:53:07 -05:00
|
|
|
;;creating projects dir
|
|
|
|
(let [projects-dir (str home "/Projects")]
|
|
|
|
(fs/create-dirs projects-dir)
|
|
|
|
(safe-sh "chown" (str user ":" user) "-R" projects-dir)
|
|
|
|
(println "created project directory"))
|
|
|
|
|
|
|
|
(setup-android-scripts)
|
|
|
|
(println "set up android scripts")
|
|
|
|
|
|
|
|
(println "configuration applied")
|