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"
66 if [[ "${simulation}" = false ]]; then
71 if [[ ! -d "${dir}" ]]; then
72 _msg_error "${dir} does not exist."
75 output "file://${dir}"
81 if [[ "${simulation}" = false ]]; then
82 remove "${HOME}/.config/gtk-3.0/bookmarks"
86 source "${HOME}/.config/user-dirs.dirs"
89 "${XDG_DOCUMENTS_DIR}"
97 for dir in "${init_dirs[@]}"; do
98 output "file://${dir} $(basename "${dir}")"
104 # Argument analysis and processing
107 _opt_long="force,help,alterlive,t-mart,simulation"
108 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
109 if [[ ${?} != 0 ]]; then
139 echo "さすが店長、青春ブタ野郎だね"
148 _msg_error "Invalid argument '${1}'"
160 if [[ -z "${*}" ]]; then
161 _msg_error "Please specify a directory."
169 if [[ "${simulation}" = false ]]; then
170 remove "${HOME}/.config/gtk-3.0/bookmarks"
175 if [[ -f "${HOME}/.config/gtk-3.0/bookmarks" ]] && [[ "${force}" = false ]] && [[ "${simulation}" = false ]]; then
176 _msg_error "The sidebar already exists. Use -f to force initialization."
188 _msg_error "Please specify a command."
193 if [[ "${alterlive}" = true ]]; then
194 remove ~/.config/autostart/gensidebar.desktop