summaryrefslogtreecommitdiff
path: root/.local/bin/o
blob: a12eee4652ee344b629e4e79a9a1b55624c6e2dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# useful links
# https://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon
# https://serverfault.com/questions/117152/do-background-processes-get-a-sighup-when-logging-off
# https://wiki.archlinux.org/title/default_applications

# improve
# if $1 is executable script filename in current dir and no ./ in front, use ./$1 ?
# also consider if $1 is executable but is directory?
# consider directoy, using xdg-mime to get the application name, hope the application can open dir and use it to batch open them, maybe not use while to open them one by one

# I don't care about errors, I don't want to handle errors, just shut up please.
# nohup seems not necessary if don't care about daemon SIGHUP requirement

if [ $# -eq 1 ] && [ -e "$1" ] && ! [ -x "$1" ]; then
	nohup xdg-open "$1" 0<&- >&- 2>&- &
else
	nohup "$@" 0<&- >&- 2>&- &
fi