replace sed with sd

This commit is contained in:
Tobias Powalowski 2024-06-26 10:40:18 +02:00
parent f0aa562c0c
commit cb685921df
4 changed files with 13 additions and 11 deletions

View file

@ -85,7 +85,7 @@ _geoip_mirrorlist() {
_COUNTRY="$(${_DLPROG} "http://ip-api.com/csv/?fields=countryCode")"
echo "GeoIP country ${_COUNTRY} detected." >>"${_LOG}"
${_DLPROG} -o /tmp/pacman_mirrorlist.txt "https://www.archlinux.org/mirrorlist/?country=${_COUNTRY}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on"
sed -i -e 's|^#Server|Server|g' /tmp/pacman_mirrorlist.txt
sd '^#Server' 'Server' /tmp/pacman_mirrorlist.txt
if rg -q 'Server = https:' /tmp/pacman_mirrorlist.txt; then
mv "${_PACMAN_MIRROR}" "${_PACMAN_MIRROR}.bak"
cp /tmp/pacman_mirrorlist.txt "${_PACMAN_MIRROR}"

View file

@ -56,7 +56,8 @@ GenericName=Installer
Exec=konsole -p colors=Linux -e /usr/bin/setup
Icon=system-software-install
EOF
sed -i -e "s#<default>applications:.*#<default>applications:systemsettings.desktop,applications:org.kde.konsole.desktop,preferred://filemanager,applications:${_STANDARD_BROWSER}.desktop,applications:gparted.desktop,applications:archboot.desktop</default>#g" /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml
sd '<default>applications:.*' "<default>applications:systemsettings.desktop,applications:org.kde.konsole.desktop,preferred://filemanager,applications:${_STANDARD_BROWSER}.desktop,applications:gparted.desktop,applications:archboot.desktop</default>" \
/usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/config/main.xml
cp /etc/xdg/autostart/archboot.desktop /usr/share/applications/
}

View file

@ -6,9 +6,10 @@ _configure_sway() {
echo "Configuring Sway..."
echo "Configuring bemenu..."
#shellcheck disable=SC2016
sed -i -e 's|^set $menu.*|set $menu j4-dmenu-desktop --dmenu=\x27bemenu -i --tf "#00ff00" --hf "#00ff00" --nf "#dcdccc" --fn "pango:Terminus 12" -H 30\x27 --no-generic --term="foot"|g' /etc/sway/config
sd '^set $menu.*' 'set $menu j4-dmenu-desktop --dmenu=\x27bemenu -i --tf "#00ff00" --hf "#00ff00" --nf "#dcdccc" --fn "pango:Terminus 12" -H 30\x27 --no-generic --term="foot"' \
/etc/sway/config
echo "Configuring wallpaper..."
sed -i -e 's|^output .*|output * bg /usr/share/archboot/grub/archboot-background.png fill|g' /etc/sway/config
sd '^output .*' 'output * bg /usr/share/archboot/grub/archboot-background.png fill' /etc/sway/config
echo "Configuring foot..."
if ! rg -q 'archboot colors' /etc/xdg/foot/foot.ini; then
cat <<EOF >> /etc/xdg/foot/foot.ini
@ -87,11 +88,11 @@ EOF
echo "Configuring waybar..."
if ! rg -q 'exec waybar' /etc/sway/config; then
# hide sway-bar
sed -i '/position top/a mode invisible' /etc/sway/config
sd 'position top' 'a mode invisible' /etc/sway/config
# diable not usable plugins
echo "exec waybar" >> /etc/sway/config
sed -i -e 's#, "custom/media"##g' /etc/xdg/waybar/config
sed -i -e 's#"mpd", "idle_inhibitor", "pulseaudio",##g' /etc/xdg/waybar/config
sd ', "custom/media"' '' /etc/xdg/waybar/config
sd '"mpd", "idle_inhibitor", "pulseaudio",' '' /etc/xdg/waybar/config
fi
echo "Configuring wayvnc..."
if ! rg -q wayvnc /etc/sway/config; then

View file

@ -123,7 +123,7 @@ _configure_xfce() {
</channel>
EOF
echo "Setting breeze as default icons..."
sed -i -e 's#<property name="IconThemeName" type="string" value="Adwaita"/>#<property name="IconThemeName" type="string" value="breeze"/>#g' \
sd '<property name="IconThemeName" type="string" value="Adwaita"/>' '<property name="IconThemeName" type="string" value="breeze"/>' \
/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml
echo "Setting archboot background image..."
cat << EOF >/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
@ -163,9 +163,9 @@ EOF
</channel>
EOF
echo "Replacing appfinder launcher with gparted..."
sed -i -e 's#xfce4-appfinder#gparted#g' /etc/xdg/xfce4/panel/default.xml
sd 'xfce4-appfinder' 'gparted' /etc/xdg/xfce4/panel/default.xml
echo "Replacing directory menu launcher with setup..."
sed -i -e 's#directorymenu#archboot#g' /etc/xdg/xfce4/panel/default.xml
sd 'directorymenu' 'archboot' /etc/xdg/xfce4/panel/default.xml
echo "Replacing menu structure..."
cat << EOF >/etc/xdg/menus/xfce-applications.menu
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
@ -224,7 +224,7 @@ EOF
</Menu>
EOF
echo "Adding gparted to xfce top level menu..."
sed -i -e 's#Categories=.*#Categories=X-Xfce-Toplevel;#g' /usr/share/applications/gparted.desktop
sd 'Categories=.*' 'Categories=X-Xfce-Toplevel;' /usr/share/applications/gparted.desktop
_HIDE_MENU="xfce4-mail-reader xfce4-about"
echo "Hiding ${_HIDE_MENU} menu entries..."
for i in ${_HIDE_MENU}; do