Skip to content

Commit

Permalink
chore: revert reusability snap util change because it's not helpful
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich committed Feb 18, 2024
1 parent ded6a5f commit c66485c
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions rclip/utils/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,41 @@ def is_snap():
return bool(os.getenv('SNAP'))


def check_snap_permissions(directory: str, package_name: str = "rclip"):
def check_snap_permissions(directory: str):
try:
any(os.scandir(directory))
except PermissionError:
homedir = os.getenv('SNAP_REAL_HOME')
if not homedir:
print(
'SNAP_REAL_HOME environment variable is not set.'
f' Please, report the issue to the {package_name} project on'
f' GitHub https://github.com/yurijmikhalevich/{package_name}/issues.'
' Please, report the issue to the rclip project on'
' GitHub https://github.com/yurijmikhalevich/rclip/issues.'
)
sys.exit(1)
if directory == homedir or directory.startswith(homedir + os.sep):
print(
f'{package_name} doesn\'t have access to the current directory.'
'rclip doesn\'t have access to the current directory.'
' You can resolve this issue by running:'
f'\n\n\tsudo snap connect {package_name}:home\n\n'
f'This command will grant {package_name} the necessary access to the home directory.'
'\n\n\tsudo snap connect rclip:home\n\n'
'This command will grant rclip the necessary access to the home directory.'
' Afterward, you can try again.'
)
sys.exit(1)
if directory == '/media' or directory.startswith('/media' + os.sep):
print(
f'{package_name} doesn\'t have access to the current directory.'
'rclip doesn\'t have access to the current directory.'
' You can resolve this issue by running:'
f'\n\n\tsudo snap connect {package_name}:removable-media\n\n'
f'This command will grant {package_name} the necessary access to the "/media" directory.'
'\n\n\tsudo snap connect rclip:removable-media\n\n'
'This command will grant rclip the necessary access to the "/media" directory.'
' Afterward, you can try again.'
)
sys.exit(1)
print(
f'Running {package_name} outside of the home or "/media" directories is not supported by its snap version.'
f' If you want to use {package_name} outside of home or "/media",'
f' file an issue in the {package_name} project on GitHub'
f' https://github.com/yurijmikhalevich/{package_name}/issues,'
f' describe your use case, and consider alternative {package_name} installation'
f' options https://github.com/yurijmikhalevich/{package_name}#linux.'
'Running rclip outside of the home or "/media" directories is not supported by its snap version.'
' If you want to use rclip outside of home or "/media",'
' file an issue in the rclip project on GitHub https://github.com/yurijmikhalevich/rclip/issues,'
' describe your use case, and consider alternative rclip installation'
' options https://github.com/yurijmikhalevich/rclip#linux.'
)
sys.exit(1)

0 comments on commit c66485c

Please sign in to comment.