4 # Email : hayao@fascode.net
6 # (c) 2019-2020 Fascode Network.
20 for _file in "${_list[@]}"; do
21 if [[ -f ${_file} ]]; then
23 elif [[ -d ${_file} ]]; then
30 echo "usage ${0} [options] [command]"
32 echo " General options:"
33 echo " -f | --force Force overwriting"
34 echo " -s | --simulation Enable sumulation"
35 echo " -h | --help This help message and exit"
37 echo " General command:"
38 echo " add <dir> Add items to the sidebar"
39 echo " delete Delete all sidebar items"
40 echo " init Initializes the sidebar"
41 echo " help This help message and exit"
45 if [[ "${simulation}" = true ]]; then
48 echo "${@}" >> "${HOME}/.config/gtk-3.0/bookmarks"
57 if [[ ! -d "${HOME}/.config/gtk-3.0/" ]]; then
58 mkdir -p "${HOME}/.config/gtk-3.0/"
60 if [[ ! -f "${HOME}/.config/gtk-3.0/bookmarks" ]]; then
61 touch "${HOME}/.config/gtk-3.0/bookmarks"
69 if [[ ! -d "${dir}" ]]; then
70 _msg_error "${dir} does not exist."
73 output "file://${dir}"
79 remove "${HOME}/.config/gtk-3.0/bookmarks"
83 source "${HOME}/.config/user-dirs.dirs"
85 output "file://${XDG_DOCUMENTS_DIR} Documents"
86 output "file://${XDG_DOWNLOAD_DIR} Downloads"
87 output "file://${XDG_MUSIC_DIR} Music"
88 output "file://${XDG_PICTURES_DIR} Pictures"
89 output "file://${XDG_VIDEOS_DIR} Videos"
94 # Argument analysis and processing
97 _opt_long="force,help,alterlive,t-mart,simulation"
98 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
99 if [[ ${?} != 0 ]]; then
129 echo "さすが店長、青春ブタ野郎だね"
138 _msg_error "Invalid argument '${1}'"
150 if [[ -z "${*}" ]]; then
151 _msg_error "Please specify a directory."
159 remove "${HOME}/.config/gtk-3.0/bookmarks"
163 if [[ -f "${HOME}/.config/gtk-3.0/bookmarks" ]] && [[ "${force}" = false ]] && [[ "${simulation}" = false ]]; then
164 _msg_error "The sidebar already exists. Use -f to force initialization."
176 _msg_error "Please specify a command."
181 if [[ "${alterlive}" = true ]]; then
182 remove ~/.config/autostart/gensidebar.desktop