flathub / com.valvesoftware.Steam

https://flathub.org/apps/details/com.valvesoftware.Steam
335 stars 70 forks source link

Steam doesn't create shortcuts for games in main menu #85

Open ghost opened 6 years ago

ghost commented 6 years ago

Or maybe, does, but they are sandboxed by flatpak.

TingPing commented 6 years ago

The files it generates aren't useful outside of the sandbox so we would have to have some automated script that looks for created ones, makes them usable, and places them on the host (which it currently doesn't have permissions to).

nanonyme commented 5 years ago

@TingPing Any further ideas? Does the sandbox prevent described tool from running inside application context?

LeandroStanger commented 5 years ago

Would it be possible to create a script that would generate the shortcut?

gasinvein commented 5 years ago

I've created a script, which generates desktop entries for installed Steam games, and can work with flatpack'ed Steam. It uses awesome steamfiles python-vdf library to get info about games from steam files.

LeandroStanger commented 5 years ago

@gasinvein Will this work with Steam Play?

gasinvein commented 5 years ago

@LeandroStanger you mean bult-in wine "Proton"? Then yes. image

frizop commented 4 years ago

When creating "desktop shortcuts" from within steam, they get placed in the following directory:

$ cat ./.var/app/com.valvesoftware.Steam/Desktop/Slay\ the\ Spire.desktop
[Desktop Entry]
Name=Slay the Spire
Comment=Play this game on Steam
Exec=steam steam://rungameid/646570
Icon=steam_icon_646570
Terminal=false
Type=Application
Categories=Game;

I've found that you can replace the exec and move that file into ~/.local/share/applications/ it tags the game mostly properly, but even after relocating the icon files from ~/.var/app/com.valvesoftware.Steam/.local/share/icons/hicolor I note they didn't work until I used a complete path, like the following:

Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/steam-wrapper com.valvesoftware.Steam steam://run/646570
Icon=/home/frizop/.var/app/com.valvesoftware.Steam/.local/share/icons/hicolor/96x96/apps/steam_icon_646570.png

So it seems to me we'd just want to link ~./.var/app/com.valvesoftware.Steam/Desktop to a export directory like discussed in this ticket and then do a little regex magic fixing it up?

s#Exec=(.*$)#/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/steam-wrapper com.valvesoftware.Steam \1#

or similar?

Edit: I wanted to note I tried @gasinvein script but failed, as it never produced any desktop files based on the input of ./steam_desktop_updater.py /home/frizop/.var/app/com.valvesoftware.Steam/.local/share/Steam

KhalilSantana commented 4 years ago

If you are willing to relax the sandbox, it's quite easy to get it working without editing the .desktop files at all:

1. Create a wrapper script for steam and add it to your path:

#!/bin/bash
flatpak run com.valvesoftware.Steam $@

Put this in a file named steam in any folder that is in your $PATH (like ~/.local/bin)

2. Relax the sandbox Allow Steam to read/write to: xdg-data/icons and xdg-desktop

flatpak --user override --filesystem=xdg-data/icons com.valvesoftware.Steam
flatpak --user override --filesystem=xdg-data/applications com.valvesoftware.Steam
flatpak --user override --filesystem=xdg-desktop com.valvesoftware.Steam

3. Create the desktop file from Steam normaly Hope this helps

Edit: added the missing xdg-data/applications

gasinvein commented 4 years ago

@DirtyJukebox How this is going to work? Steam creates .desktop files with Exec=steam ..., so it'll (try to) launch non-flatpak Steam.

KhalilSantana commented 4 years ago

@gasinvein Because the on step 1 you create a file named steam, which is a script that simply calls flatpak run com.valvesoftware.Steam and passes all arguments to it, sorry if I wasn't clear =p

Step 1 In more detail:

1.1 Create file

echo "#!/bin/bash  
flatpak run com.valvesoftware.Steam $@" > ~/steam

1.2 Make it executable

chmod +x ~/steam

1.3 Make add it to your PATH

Add to your ~/.xinitrc or make your DE source this:

PATH="$PATH:$HOME/.local/bin"

1.4 Create that folder

mkdir ~/.local/bin

1.5 Move the steam wrapper to there

mv ~/steam ~/.local/bin

1.6 Logout and login

Hope this clears things up

gasinvein commented 4 years ago

@DirtyJukebox Sorry, I've misread your original comment, completely missing Step 1.

MathevsBatista commented 3 years ago

1.3 Make add it to your PATH

This can be a bit tricky, because you need to source this before login, otherwise your PATH might be wrong, you can either add it to your .xinitrc or use some DE spefic behavior. I'm on KDE plasma, so I simply made it source the same environment variables in my zsh configuration. The archwiki has a decent page on this

Add to your ~/.xinitrc or make your DE source this:

PATH="$PATH:$HOME/.local/bin"

In this point i completely block, how i can do this in debian 10 buster with wayland?

MathevsBatista commented 3 years ago

@DirtyJukebox please, help!!

KhalilSantana commented 3 years ago

@FUNKYBAT, I can't personally help you much on that front, because I don't run Wayland on my machines (Nvidia drivers+XWayland games = 5 FPS). Have you read the wiki page I've linked in my previous comment? In your case I think using pam_env(8) option should work for any DE or DM, and environment.d should work for GDM.

That being said, there's no reason simply dropping the file in a directory that is already exported/present in $PATH wouldn't work. Something like this:

echo "#!/bin/bash  
flatpak run com.valvesoftware.Steam $@" > ~/steam
chmod +x ~/steam
sudo mv ~/steam /usr/local/bin/
sudo chown root:root /usr/local/bin/steam
sudo chmod 755 /usr/local/bin/steam

The last three commands move the file to /usr/local/bin, make root the owner of the file, then give all users read and execute permissions. This is my attempt at making it more secure, probably not great, but then again I've never claimed this was a solution, it's just a hack around this bug/limitation in the flatpak'd version of Steam.

If all else fails, there's always /etc/profile.d, not sure if all DE/DMs source it, but worth a try

nanonyme commented 3 years ago

You probably just want

mkdir -p ~/bin
echo "#!/bin/bash  
flatpak run com.valvesoftware.Steam $@" > ~/bin/steam
chmod +x ~/bin/steam

if you want a command for it

MathevsBatista commented 3 years ago

Steam continue to put desktop shortcuts at: ~/.var/app/com.valvesoftware.Steam/Desktop and no menu shortcut at all :( but thanks for the attempt to help.

Mine path is: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin and I'm using debian 10 buster with wayland.

MathevsBatista commented 3 years ago
  1. Relax the sandbox Allow Steam to read/write to: xdg-data/icons and xdg-desktop

flatpak --user override --filesystem=xdg-data/icons com.valvesoftware.Steam

flatpak --user override --filesystem=xdg-desktop com.valvesoftware.Steam

Hey @DirtyJukebox, xdg-data/icons and xdg-desktop are folders of KDE? You can explain to me what are those 2 things?

KhalilSantana commented 3 years ago

@FUNKYBAT, Those are environment variables from Freedesktop's XDG User Dirs specification, that are available (mapped/aliased) in flatpak with similar names. I set them manually in my ZSH environment configuration file, which gets sourced by KDE, but it's not a KDE-specific variable.

Anyway, here's the environment variables and their mappings + values in my system: Name in Flatpak Variable Name Value
xdg-desktop $XDG_DESKTOP_DIR ~/Desktop
xdg-data/icons $XDG_DATA_HOME ~/.local/share/icons
KhalilSantana commented 3 years ago

Hum, I think I found out what you might be missing, I've reviewed my over ides and I've discovered I've also allowed xdg-data/applications

% flatpak --user override --show com.valvesoftware.Steam
[Context]
filesystems=xdg-data/applications;xdg-desktop;xdg-data/icons;/srv/games/;
MathevsBatista commented 3 years ago

Here i gonna send pictures of all process.

Captura de tela de 2020-09-15 10-46-00 Captura de tela de 2020-09-15 10-46-34 Captura de tela de 2020-09-15 10-46-53 Captura de tela de 2020-09-15 10-47-46

I still can't get menu shortcuts.

MathevsBatista commented 3 years ago

On the third image, it shows that the root user has permission to write, execute and read, and the other groups only execute and read. My system is in Portuguese, that's why I'm translating.

MathevsBatista commented 3 years ago

root@matheus-pc:/usr/local/bin# echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin

My path.

nanonyme commented 3 years ago

Please make sure not to run this app as root, it might cause insane amounts of mess.

MathevsBatista commented 3 years ago

S2

I'm not believing that the problem was just this, it worked perfectly after using the codes --user override not being root. I thank you @nanonyme and @DirtyJukebox.

gasinvein commented 3 years ago

@frizop @FUNKYBAT I've updated the script from https://github.com/flathub/com.valvesoftware.Steam/issues/85#issuecomment-416033188, hopefully it works again (note the new dependencies, vdf and steam instead of steamfiles).

MathevsBatista commented 3 years ago

Now I have shortcut entries, but when I open a game using these shortcuts, it opens the game with a Steam shortcut, just like as before I had shortcuts. Captura de tela de 2020-09-15 16-55-37 Game being opened with steam shortcut. Captura de tela de 2020-09-15 16-55-53 Game shortcut itself, forgive the ugly icon, I'm with any of them for terraria by now.

KhalilSantana commented 3 years ago

@FUNKYBAT, Glad I could help, I'll write another comment later (this week hopefully) with a more in-depth guide as the thread above can be confusing to read for future readers that stumble upon this issue.

About your last comment, I couldn't understand what you are trying to explain, does the game launch? Does the shortcut just not display the icon? Have you checked you haven't made the icons folder/files owned by root by accident during your previous attempts?

Your comment looks like it's been machine-translated, I'm not sure non-english text is allowed in this tracker/repo, so If you want to talk in Portuguese you can either PM me on Freenode (my nick there is d43mon), or via Matrix (@khalilsantana:matrix.org). If not, then just edit your comment to make it clearer to read/understand.

hadess commented 3 years ago

Ideally, Steam would be able to use a portal: https://github.com/flatpak/xdg-desktop-portal/issues/326

MathevsBatista commented 3 years ago

@DirtyJukebox, its not machine translated, but mine english is a little bad KKKK, you can give me your email? About the problem, now i can open the game through shortcut, but once the game is opened it appears as steam in dash, it was supposed to happen by your method? The shortcut problem itself as solved, the problem now is other, the game being opened and appearing as steam once its opened.

KhalilSantana commented 3 years ago

@FUNKYBAT, my email is khalilsantana@hotmail.com No, for me the game shows its own icon on my taskbar, here's a quick video demo . Maybe it's because your system is set to group apps in the taskbar? Also worth checking $XDG_DATA_HOME/icons/hicolor/64x64/apps/ and see if steam wrote the app icons there or not

Can202 commented 3 years ago

I've made a simple script, here, it's easy to use

How it works: If you run the script, copy the apps and icon of Steam folder to home folder, and add the steam command, that is flatpak run com.valvesoftware.Steam but just steam, with this the games works.

santiagocezar commented 3 years ago

Not sure if this helps someone, but you can just use the steam:// protocol on desktop files.

Here is an example for Terraria:

[Desktop Entry]
Name=Terraria
Icon=steam_icon_105600
Type=Application
Exec=xdg-open steam://rungameid/105600

You can then copy the icons installed in ~/.var/app/com.valvesoftware.Steam/data/icons/ (or use any icon pack that provides icons for games), write the file to ~/.local/share/applications and done!

This feels a lot safer than installing custom wrappers in the system, and I could probably write a simple script to do it automatically

gasinvein commented 3 years ago

you can just use the steam:// protocol on desktop files.

write a simple script to do it automatically

This is essentially what my script does - iterates over your game library folders and creates a .desktop entry with xdg-open steam://... for each installed game. Should work for both flatpak and non-flatpak Steam.

santiagocezar commented 3 years ago

Nevermind then, didn't see that. Your script looks cool! It is probably more complete that the one would've done 😅.

Would it be possible to convert it into an extension for the flatpak? I'm not sure of how that works

gasinvein commented 3 years ago

Would it be possible to convert it into an extension for the flatpak?

Yes, but I'm not sure if it makes sense. It needs write access to ~/.local/share/applications, which is too big sandbox hole.

Meganium97 commented 2 years ago

Why does your script not work for games in the "steamapps" section of steam? Using manjaro and your script it does not detect deltarune from the steamapps section.

gasinvein commented 2 years ago

@Meganium97 What is "steamapps section of steam"?

Meganium97 commented 2 years ago

@Meganium97 What is "steamapps section of steam"?

It looks like your script only looks in /steam/games. The steam apps location should be /steam/steamapps

gasinvein commented 2 years ago

@Meganium97 Sorry, I do not understand what those paths mean. Can you please at least show how do you run the script?

Meganium97 commented 2 years ago

I run the script with the default path, ~/.local/share/steam Deltarune is stored under steamapps. It is not found by the script.

gasinvein commented 2 years ago

@Meganium97 ~/.local/share/steam is invalid for this Steam flatpak app; this app has Steam installation in ~/.var/app/com.valvesoftware.Steam/data/Steam.

Meganium97 commented 2 years ago

Alright then, while this might be a problem for the flatpak version too, I will move this to the script repoistory.

ThracianKnight1907 commented 2 years ago

Could this be relevant? https://github.com/flatpak/xdg-desktop-portal/pull/696

gasinvein commented 2 years ago

@ThracianKnight1907 Yes. But Steam would need to add support for the new portal to make use of it; it's won't just work automagically.

ImTheSquid commented 2 years ago

I made an automatic service that watches the desktop files directory, should be a bit more set-and-forget than the scripts.

benjamin051000 commented 1 year ago

What's the current state of this problem? Still an issue (Fedora 36, latest version of steam at time of writing). Is this being worked on or is it not really being looked at right now? Thanks

gasinvein commented 1 year ago

What's the current state of this problem? Still an issue (Fedora 36, latest version of steam at time of writing). Is this being worked on or is it not really being looked at right now? Thanks

This issue can't be resolved on the flatpak side. Since dynamic launcher portal was implemented, flatpak'ed apps can now securely create desktop entries, but it requires implementing this portal support on the app side. So, it's only Valve who can address this.

ahjolinna commented 1 year ago

well this is still an issue (even on beta client), is there any ETA for adding the "dynamic launcher portal" thing??

nanonyme commented 1 year ago

This is highly unlikely to be fixed regardless if it requires Valve involvement. This flatpak is a community redistribution of Valve Steam.

foundObjects commented 1 year ago

I've created a script, which generates desktop entries for installed Steam games, and can work with flatpack'ed Steam. It uses awesome ~steamfiles~ python-vdf library to get info about games from steam files.

This is super useful, thank you for posting your work!

Have you considered gluing your script into the "add desktop icon" workflow by tracking the user's ~/.var/app/com.valvesoftware.Steam/.local/share/applications/ directory with a systemd user service and firing your script automatically when the content of that directory changes? That would make the whole 'add icon to desktop" thing actually add icons to the launcher somewhat seamlessly.