From c0b3233a61a894de42471b04f7a924ea6701de90 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 8 Feb 2020 12:09:05 +0100 Subject: etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks: Add CIFS/SMB home share to 'Places' area for GTK-3 based file browsers. --- ...-itzks-systems-roamingworkstation_smb-bookmarks | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks diff --git a/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks new file mode 100755 index 0000000..d7b79f9 --- /dev/null +++ b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +# Create GTK/Gnome places bookmark for easy access. +add_gtk3_place() { + SERVER="$1" + USER="$2" + GROUP="$3" + TITLE="$4" + SMBPATH="$5" + if [ ! grep -q "$SMBPATH $TITLE" "/home/$USER/.config/gtk-3.0/bookmarks" ]; then + echo "$SMBPATH $TITLE" >> /home/$USER/.config/gtk-3.0/bookmarks + chown $USER:$GROUP /home/$USER/.config/gtk-3.0/bookmarks + fi +} + +# FIXME Would be nice if the same bookmark file could be used for both +# KDE and Gnome +case "$ORIGHOMEDIR" in + /*/*/*) + homepath="$(ldapsearch -LLL -x '(&(uid=$USER)(sambaHomePath=*))' sambaHomePath | awk '/sambaHomePath: / { print $2 }')" + if [ "$homepath" ] ; then + SMBPATH=$(echo "smb:$homepath" | tr '\' /) + SERVER="$(echo $SMBPATH | cut -d/ -f3)" + else + # Extract FQDN from home directory path + SERVER="$(getent hosts $(echo $ORIGHOMEDIR | cut -d/ -f3) | awk '{print $2}')" + SMBPATH="smb://$SERVER/$USER/" + fi + + GROUP="$(id -ng $USER)" + TITLE="$USER on $SERVER via SMB" + add_gtk3_place "$SERVER" "$USER" "$GROUP" "$TITLE" "$SMBPATH" + ;; +esac -- cgit v1.2.3