Comments (13)
If you use that, please add a fallback, an external tool like xdg-user-dir
is not necessarily installed:
godzil@box4 ~ $ xdg-user-dir
-bash: xdg-user-dir: command not found
from pyxel.
The filename for captured images is decided in the _get_capture_filename method in app.py.
And it only takes care of Windows and Mac for now.
If there's some way to get the path to the desktop on Linux, I'll add the code for that. And if there's no common way for that, I think the home directory can be used instead of the desktop.
Do you know how to get the desktop path on Linux? (I hope it's not different for each distribution.)
Or I should use the home directory on Linux?
from pyxel.
Both
import os
os.popen('xdg-user-dir DESKTOP').read().split('\n')[0]
and
import subprocess
subprocess.check_output(['xdg-user-dir', 'DESKTOP']).decode('utf-8').split('\n')[0]
Worked for me on Ubuntu and Fedora, I don't know if it works on all distribution though.
from pyxel.
I fixed it and released as 0.7.4.
Could you confirm it works right?
from pyxel.
@Godzil The implemented method that fixed this issue ea462c6 does not use xdg-user-dir.
from pyxel.
Well this is not the actual code:
Line 362 in d73c3aa
from pyxel.
@Godzil I was afraid that something like that would happen.
Two ways of solving this are:
- Using some other python module to do this and setting it as a dependency. (I think that there is a xdg module for python but I didn't check it out yet)
- Mixing my solution with @vesche 's to something like:
import subprocess
[...]
else:
try:
path = subprocess.check_output(["xdg-user-dir", "DESKTOP"], shell=True).decode('utf-8').split('\n')
except subprocess.CalledProcessError:
path = os.path.expanduser('~')
from pyxel.
@JeanAraujo @Godzil
Actually I don't have Linux environment now.
Though the code above looks correct, doest this code work on Linux actual? If so, I'll use this.
from pyxel.
def _get_capture_filename():
if os.name == 'nt':
path = os.path.join(
os.path.join(os.environ['USERPROFILE']), 'Desktop')
else:
try:
path = subprocess.check_output(["xdg-user-dir DESKTOP"], shell=True).decode('utf-8').split('\n')[0]
except subprocess.CalledProcessError:
path = os.path.expanduser('~')
return os.path.join(
path,
datetime.datetime.now().strftime('pyxel-%y%m%d-%H%M%S'))
Works for me, but I would first like @Godzil and @vesche thoughts on this 🤔
from pyxel.
@kitao As you must know there is not just one Linux distribution, and not all necessarily provide the same set of tools.
xdg-user-dir is not a tool installed by default on all distributions, on one of my computer, this tool does not exist, so relying only on it is not a good idea.
@JeanAraujo seems to be a good solution, try if the tool works, if not, fallback using the user folder, apart from missing Mac OS X, xdg-user is clearly not supported under Mac OS X.
from pyxel.
Oh, that's true, @Godzil
I'm sorry :p
@staticmethod
def _get_capture_filename():
plat = platform.system()
if plat == 'Windows':
path = os.path.join(
os.path.join(os.environ['USERPROFILE']), 'Desktop')
elif plat == 'Darwin':
path = os.path.join(
os.path.join(os.path.expanduser('~')), 'Desktop')
else:
path = os.path.join(
os.path.join(os.path.expanduser('~')), 'Desktop')
if not os.path.exists(path):
try:
path = subprocess.check_output(["xdg-user-dir DESKTOP"], shell=True).decode('utf-8').split('\n')[0]
except subprocess.CalledProcessError:
path = os.path.expanduser('~')
return os.path.join(
path,
datetime.datetime.now().strftime('pyxel-%y%m%d-%H%M%S'))
Well, this code looks a bit... extensive, but it supposedly works. I can't use a linux system at the moment so I'll check it later.
I still want @vesche thoughts on it.
from pyxel.
I imported the above code and released it as 0.7.5.
Please let me know if it doesn't work.
from pyxel.
Changed, tested and solved on #32.
Tested on Ubuntu 18.04.1 LTS
from pyxel.
Related Issues (20)
- Confusion with `blt` function HOT 7
- Unable to import classes from different files using https://kitao.github.io/pyxel/wasm/launcher/?run= HOT 6
- palette only 0..254 (v2.0.2) HOT 2
- mouse_wheel never become 0 HOT 3
- Pyxel Editor crash when selecting Music Editor HOT 6
- Non pixel perfect pixels on the right side of the screen HOT 29
- Pyxel not running HOT 4
- Pyxel crash when starting edit or hello world example HOT 1
- Don't start when I ask for
- command for the terminal didn't work (pycharm) HOT 2
- Slide sound effect only works once HOT 4
- Unable to build a pyxel to exe application on a drive other than C:/ on Windows. HOT 1
- pyxel edit で音符マークを押したら music_editor.py の インデックスエラーで異常終了する。 HOT 1
- `pyxel.sqrt(0)` returns 1.7976931348623157e+308 HOT 4
- Id like to edit the game on web. HOT 3
- Drone yazılımı arıyorum HOT 1
- Please tell me your work with Pyxel (Part5) HOT 6
- New functions HOT 2
- pyxel run of .pyxapp file results in "no such file: 'filename.pyxapp.py' HOT 2
- How to run Pyxel with the latest Emscripten (3.1.46+) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyxel.