[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question about scripts in guix-home
From: |
Fredrik Salomonsson |
Subject: |
Question about scripts in guix-home |
Date: |
Sat, 16 Oct 2021 03:43:34 +0000 |
Hi guix,
I decided to try out guix home. But I hit a bit of a snag. I'm trying to
port my waybar config over to it, but cannot figure out how to set the
execution bit on my two custom scripts I have.
This is what I currently have:
#+begin_src scheme
(define-module (plt home waybar)
#:use-module (gnu services)
#:use-module (gnu home services)
#:use-module (gnu packages wm)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (ice-9 format))
(define-public packages
(list
waybar
))
(define %source-dir (current-source-directory))
(define-public (get-services host)
"Return services for HOST."
(list
(simple-service 'plt-waybar-config
home-files-service-type
`(
("config/waybar/config"
,(local-file (format #f "~a/files/waybar/~a.conf"
%source-dir host)))
("config/waybar/style.css"
,(local-file (format #f "~a/files/waybar/~a-style.css"
%source-dir host)))
("config/waybar/modules/mic.sh"
,(local-file "files/waybar/modules-mic.sh"))
("config/waybar/modules/storage.sh"
,(local-file "files/waybar/modules-storage.sh"))
))))
#+end_src
Which generates the config but the mic.sh and storage.sh bash scripts
are missing their execution bit.
The bash scripts are really basic, for example here's the mic.sh:
#+begin_src bash
#! /usr/bin/env bash
mic_mute=$(pactl get-source-mute @DEFAULT_SOURCE@| cut -d" " -f2)
if [[ "$mic_mute" == "yes" ]]
then
echo '{"text": "", "class": "muted", "percentage": 0 }'
else
echo '{"text": "", "class": "unmuted", "percentage": 100}'
fi
#+end_src
I played around with gexp but didn't get anything working. Closest I got
what by using program-file
#+begin_src scheme
(define-public (get-services host)
"Return services for HOST."
(let ((mic-script (program-file
"mic.sh"
#~(execl #$(local-file "files/waybar/modules-mic.sh")
"mic.sh")))
(storage-script (program-file
"storage.sh"
#~(execl #$(local-file
"files/waybar/modules-storage.sh") "storage.sh"))))
(list
(simple-service 'plt-waybar-config
home-files-service-type
`(
("config/waybar/config"
,(local-file (format #f "~a/files/waybar/~a.conf"
%source-dir host)))
("config/waybar/style.css"
,(local-file (format #f
"~a/files/waybar/~a-style.css" %source-dir host)))
("config/waybar/modules/mic.sh"
,mic-script)
("config/waybar/modules/storage.sh"
,storage-script)
)))))
#+end_src
But it's still trying to execute the original scripts and fail due to
the execution bit.
I'm probably missing something obvious, but I haven't used gexp before.
How do you set the execution bit on a file-like object?
Or is there a better approach for dealing with these? Package them up
perhaps? As I just realized when writing this that I also need to patch
the shebang to point to the bash guix-home is using.
Thanks
--
s/Fred[re]+i[ck]+/Fredrik/g
- Question about scripts in guix-home,
Fredrik Salomonsson <=