Skip to content
Open
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# code-nautilus

This repo provides a visual studio code extension for Nautilus.
This repo provides a visual studio code/VSCodium extension for Nautilus.

## Install Extension

Expand Down
33 changes: 28 additions & 5 deletions code-nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,35 @@
from subprocess import call
import os


# path to vscode
VSCODE = 'code'
FLATPAK_VSCODE_PATH = "/var/lib/flatpak/exports/bin/com.visualstudio.code"
VSCODE_PATH = "/usr/bin/code"

# path to vscodium
FLATPAK_VSCODIUM_PATH = "/var/lib/flatpak/exports/bin/com.vscodium.codium"
VSCODIUM_PATH = "/usr/bin/codium"

# VSCODENAME: what name do you want to see in the context menu?

# what name do you want to see in the context menu?
VSCODENAME = 'Code'
if os.path.exists(FLATPAK_VSCODE_PATH):
VSCODE = "flatpak run com.visualstudio.code"
VSCODENAME = 'Code'
elif os.path.exists(FLATPAK_VSCODIUM_PATH):
VSCODE = "flatpak run com.vscodium.codium"
VSCODENAME = 'VSCodium'
elif os.path.exists(VSCODE_PATH):
VSCODE = 'code'
VSCODENAME = 'Code'
elif os.path.exists(VSCODIUM_PATH):
VSCODE = 'codium'
VSCODENAME = 'VSCodium'

Choose a reason for hiding this comment

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

If someone has VSCodium installed and VSCode, chances are that one prefers codium?
At least that is the case for me :)


# always create new window?
NEWWINDOW = False

# Force wayland? ( Flatpak packages may need to add permissions for wayland )
WAYLAND = True

class VSCodeExtension(GObject.GObject, Nautilus.MenuProvider):

Expand All @@ -35,9 +55,12 @@ def launch_vscode(self, menu, files):
args = '--new-window '

if NEWWINDOW:
args = '--new-window '
args = '--new-window'

call(VSCODE + ' ' + args + safepaths + '&', shell=True)
if WAYLAND and os.environ.get('XDG_SESSION_TYPE') == "wayland":
print("true")
args += ' --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations'
call(VSCODE + ' ' + args + ' ' + safepaths + '&', shell=True)

def get_file_items(self, *args):
files = args[-1]
Expand Down