Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/cli/open-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function openDesktop(url: string = '') {
return ChildProcess.spawn('open', [url], { env })
} else if (__WIN32__) {
return ChildProcess.spawn('cmd', ['/c', 'start', url], { env })
} else if (__LINUX__) {
return ChildProcess.spawn('xdg-open', [url], { env })
} else {
throw new Error(
`Desktop command line interface not currently supported on platform ${
Expand Down
17 changes: 17 additions & 0 deletions app/src/lib/editors/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum ExternalEditor {
SublimeText = 'Sublime Text',
Typora = 'Typora',
SlickEdit = 'SlickEdit',
ElementaryCode = 'Code',
}

export function parse(label: string): ExternalEditor | null {
Expand Down Expand Up @@ -42,6 +43,10 @@ export function parse(label: string): ExternalEditor | null {
return ExternalEditor.SlickEdit
}

if (label === ExternalEditor.ElementaryCode) {
return ExternalEditor.ElementaryCode
}

return null
}

Expand Down Expand Up @@ -85,6 +90,9 @@ async function getEditorPath(editor: ExternalEditor): Promise<string | null> {
'/opt/slickedit-pro2016/bin/vs',
'/opt/slickedit-pro2015/bin/vs',
])
case ExternalEditor.ElementaryCode:
return getPathIfAvailable('/usr/bin/io.elementary.code')

default:
return assertNever(editor, `Unknown editor: ${editor}`)
}
Expand All @@ -103,6 +111,7 @@ export async function getAvailableEditors(): Promise<
sublimePath,
typoraPath,
slickeditPath,
elementaryCodePath,
] = await Promise.all([
getEditorPath(ExternalEditor.Atom),
getEditorPath(ExternalEditor.VSCode),
Expand All @@ -111,6 +120,7 @@ export async function getAvailableEditors(): Promise<
getEditorPath(ExternalEditor.SublimeText),
getEditorPath(ExternalEditor.Typora),
getEditorPath(ExternalEditor.SlickEdit),
getEditorPath(ExternalEditor.ElementaryCode),
])

if (atomPath) {
Expand Down Expand Up @@ -141,5 +151,12 @@ export async function getAvailableEditors(): Promise<
results.push({ editor: ExternalEditor.SlickEdit, path: slickeditPath })
}

if (elementaryCodePath) {
results.push({
editor: ExternalEditor.ElementaryCode,
path: elementaryCodePath,
})
}

return results
}
5 changes: 4 additions & 1 deletion app/src/lib/editors/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import * as Darwin from './darwin'
import * as Win32 from './win32'
import * as Linux from './linux'

export type ExternalEditor = Darwin.ExternalEditor | Win32.ExternalEditor
export type ExternalEditor =
| Darwin.ExternalEditor
| Win32.ExternalEditor
| Linux.ExternalEditor

/** Parse the label into the specified shell type. */
export function parse(label: string): ExternalEditor | null {
Expand Down
15 changes: 15 additions & 0 deletions app/src/lib/shells/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum Shell {
Xterm = 'XTerm',
Terminology = 'Terminology',
Deepin = 'Deepin Terminal',
Elementary = 'Elementary Terminal',
}

export const Default = Shell.Gnome
Expand Down Expand Up @@ -54,6 +55,10 @@ export function parse(label: string): Shell {
return Shell.Deepin
}

if (label === Shell.Elementary) {
return Shell.Elementary
}

return Default
}

Expand Down Expand Up @@ -81,6 +86,8 @@ function getShellPath(shell: Shell): Promise<string | null> {
return getPathIfAvailable('/usr/bin/terminology')
case Shell.Deepin:
return getPathIfAvailable('/usr/bin/deepin-terminal')
case Shell.Elementary:
return getPathIfAvailable('/usr/bin/io.elementary.terminal')
default:
return assertNever(shell, `Unknown shell: ${shell}`)
}
Expand All @@ -99,6 +106,7 @@ export async function getAvailableShells(): Promise<
xtermPath,
terminologyPath,
deepinPath,
elementaryPath,
] = await Promise.all([
getShellPath(Shell.Gnome),
getShellPath(Shell.Mate),
Expand All @@ -109,6 +117,7 @@ export async function getAvailableShells(): Promise<
getShellPath(Shell.Xterm),
getShellPath(Shell.Terminology),
getShellPath(Shell.Deepin),
getShellPath(Shell.Elementary),
])

const shells: Array<IFoundShell<Shell>> = []
Expand Down Expand Up @@ -148,6 +157,10 @@ export async function getAvailableShells(): Promise<
shells.push({ shell: Shell.Deepin, path: deepinPath })
}

if (elementaryPath) {
shells.push({ shell: Shell.Elementary, path: elementaryPath })
}

return shells
}

Expand All @@ -172,6 +185,8 @@ export function launch(
return spawn(foundShell.path, ['-d', path])
case Shell.Deepin:
return spawn(foundShell.path, ['-w', path])
case Shell.Elementary:
return spawn(foundShell.path, ['-w', path])
default:
return assertNever(shell, `Unknown shell: ${shell}`)
}
Expand Down
28 changes: 28 additions & 0 deletions app/static/linux/github
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this file does not have the executable bit set after install:

$ ls -l "/opt/GitHub Desktop/resources/app/static"
total 960
...
-rw-r--r-- 1 root root    760 Mar 20 11:14 github
...

Should we just chmod a+x this file so everyone can launch it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, good catch! I might have done that without thinking or assumed it was done on the folder level on installation; yes, we'd want to make it executable


if [ ! -L "$0" ]; then
# if path is not a symlink, find relatively
GITHUB_PATH=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")")
else
if command -v readlink >/dev/null; then
# if readlink exists, follow the symlink and then find relatively
SYMLINK=$(readlink -f "$0")
GITHUB_PATH=$(dirname "$(dirname "$(dirname "$(dirname "$SYMLINK")")")")
else
# else use the standard install location
GITHUB_PATH="/opt/GitHub Desktop"
fi
fi
# check if this is a dev install or standard
if [ -f "$GITHUB_PATH/github-desktop-dev" ]; then
BINARY_NAME="github-desktop-dev"
else
BINARY_NAME="github-desktop"
fi

ELECTRON="$GITHUB_PATH/$BINARY_NAME"
CLI="$GITHUB_PATH/resources/app/cli.js"

ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"

exit $?
18 changes: 13 additions & 5 deletions script/linux-after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ set -e

PROFILE_D_FILE="/etc/profile.d/github-desktop.sh"
INSTALL_DIR="/opt/${productFilename}"
SCRIPT=$"#!/bin/sh
export PATH=\"$INSTALL_DIR:\$PATH\""
CLI_DIR="$INSTALL_DIR/resources/app/static"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we have full control over how the app is built for packaging, I think we can make the github shortcut live wherever we like. Other OSes have their own constraints:

  • Windows includes the versions in the path, so we need to update the shortcut after launch
  • macOS may requires elevation to install it at a predictable location, so we have an in-app flow to check and prompt

I'm going to leave this here for now because it's working, but if I have any better ideas I'll let you know.

Copy link
Author

@jfgordon2 jfgordon2 Mar 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH that would certainly make it easier; then we just can create a symbolic link in the /usr/bin directory
ln -s $INSTALL_DIR/resources/app/static/github /usr/bin/github


case "$1" in
configure)
echo "$SCRIPT" > "${PROFILE_D_FILE}";
. "${PROFILE_D_FILE}";
# add executable permissions for CLI interface
chmod +x "$CLI_DIR"/github || :
# check if this is a dev install or standard
if [ -f "$INSTALL_DIR/github-desktop-dev" ]; then
BINARY_NAME="github-desktop-dev"
else
BINARY_NAME="github-desktop"
fi
# create symbolic links to /usr/bin directory
ln -f -s "$INSTALL_DIR"/$BINARY_NAME /usr/bin || :
ln -f -s "$CLI_DIR"/github /usr/bin || :
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand All @@ -22,4 +30,4 @@ case "$1" in
;;
esac

exit 0
exit 0
4 changes: 4 additions & 0 deletions script/linux-after-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ case "$1" in
echo "#!/bin/sh" > "${PROFILE_D_FILE}";
. "${PROFILE_D_FILE}";
rm "${PROFILE_D_FILE}";
# remove symbolic links in /usr/bin directory
unlink /usr/bin/github-desktop || :
unlink /usr/bin/github-desktop-dev || :
unlink /usr/bin/github || :
;;

*)
Expand Down