Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin authored Mar 25, 2024
2 parents 1aefd67 + 60b8c98 commit 6597c0b
Show file tree
Hide file tree
Showing 20 changed files with 1,062 additions and 1,132 deletions.
2 changes: 1 addition & 1 deletion bottles/backend/managers/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def download(
file_path = os.path.join(Paths.temp, rename)
os.rename(temp_dest, file_path)

if checksum:
if checksum and not os.environ.get("BOTTLES_SKIP_CHECKSUM"):
"""
Compare the checksum of the downloaded file with the one
provided by the caller. If they don't match, remove the
Expand Down
9 changes: 9 additions & 0 deletions bottles/backend/managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,11 @@ def create_bottle_from_config(self, config: BottleConfig) -> bool:
config.Path = f"{config.Path}__{rnd}"
os.makedirs(bottle_path)

# Pre-create drive_c directory and set the case-fold flag
bottle_drive_c = os.path.join(bottle_path, "drive_c")
os.makedirs(bottle_drive_c)
FileUtils.chattr_f(bottle_drive_c)

# write the bottle config file
saved = config.dump(os.path.join(bottle_path, "bottle.yml"))
if not saved.status:
Expand Down Expand Up @@ -1236,6 +1241,10 @@ def components_check():
# create the bottle directory
try:
os.makedirs(bottle_complete_path)
# Pre-create drive_c directory and set the case-fold flag
bottle_drive_c = os.path.join(bottle_complete_path, "drive_c")
os.makedirs(bottle_drive_c)
FileUtils.chattr_f(bottle_drive_c)
except:
logging.error(
f"Failed to create bottle directory: {bottle_complete_path}", jn=True
Expand Down
25 changes: 24 additions & 1 deletion bottles/backend/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import os
import shutil
import time
import fcntl
from pathlib import Path
from typing import Union

from array import array

class FileUtils:
"""
Expand Down Expand Up @@ -112,3 +113,25 @@ def wait_for_files(files: list, timeout: int = 0.5) -> bool:
time.sleep(timeout)

return True

@staticmethod
def chattr_f(directory: str) -> bool:
FS_IOC_GETFLAGS = 0x80086601
FS_IOC_SETFLAGS = 0x40086602
FS_CASEFOLD_FL = 0x40000000

success = True
if os.path.isdir(directory) and len(os.listdir(directory)) == 0:
fd = os.open(directory, os.O_RDONLY)
try:
arg = array('L', [0])
fcntl.ioctl(fd, FS_IOC_GETFLAGS, arg, True)
arg[0] |= FS_CASEFOLD_FL
fcntl.ioctl(fd, FS_IOC_SETFLAGS, arg, True)
except OSError:
success = False
os.close(fd)
else:
success = False

return success
69 changes: 35 additions & 34 deletions bottles/backend/utils/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TerminalUtils:
It will loop all the "supported" terminals to find the one
that is available, so it will be used to launch the command.
"""

colors = {
"default": "#00ffff #2b2d2e",
"debug": "#ff9800 #2e2c2b",
Expand All @@ -38,21 +39,21 @@ class TerminalUtils:

terminals = [
# Part of Flatpak package
['easyterm.py', '-d -p "%s" -c %s'],
["easyterm.py", '-d -p "%s" -c %s'],
# Third party
['foot', '%s'],
['kitty', '%s'],
['tilix', '-- %s'],
["foot", "%s"],
["kitty", "%s"],
["tilix", "-- %s"],
# Desktop environments
['xfce4-terminal', '-e %s'],
['konsole', '--noclose -e %s'],
['gnome-terminal', '-- %s'],
['kgx', '-e %s'],
['mate-terminal', '--command %s'],
['qterminal', '--execute %s'],
['lxterminal', '-e %s'],
["xfce4-terminal", "-e %s"],
["konsole", "--noclose -e %s"],
["gnome-terminal", "-- %s"],
["kgx", "-e %s"],
["mate-terminal", "--command %s"],
["qterminal", "--execute %s"],
["lxterminal", "-e %s"],
# Fallback
['xterm', '-e %s'],
["xterm", "-e %s"],
]

def __init__(self):
Expand All @@ -64,11 +65,15 @@ def check_support(self):
return True

for terminal in self.terminals:
terminal_check = subprocess.Popen(
f"command -v {terminal[0]} > /dev/null && echo 1 || echo 0",
shell=True,
stdout=subprocess.PIPE
).communicate()[0].decode("utf-8")
terminal_check = (
subprocess.Popen(
f"command -v {terminal[0]} > /dev/null && echo 1 || echo 0",
shell=True,
stdout=subprocess.PIPE,
)
.communicate()[0]
.decode("utf-8")
)

if "1" in terminal_check:
self.terminal = terminal
Expand All @@ -90,33 +95,29 @@ def execute(self, command, env=None, colors="default", cwd=None):
colors = self.colors[colors]
command = shlex.quote(command)

if self.terminal[0] == 'easyterm.py':
command = ' '.join(self.terminal) % (colors, shlex.quote(f'bash -c {command}'))
if self.terminal[0] == "easyterm.py":
command = " ".join(self.terminal) % (
colors,
shlex.quote(f"bash -c {command}"),
)
if "ENABLE_BASH" in os.environ:
command = ' '.join(self.terminal) % (colors, f"bash")
elif self.terminal[0] in ['kgx', 'xfce4-terminal']:
command = ' '.join(self.terminal) % "'sh -c %s'" % f'{command}'
elif self.terminal[0] in ['kitty', 'foot', 'konsole', 'gnome-terminal']:
command = ' '.join(self.terminal) % "sh -c %s" % f'{command}'
command = " ".join(self.terminal) % (colors, f"bash")
elif self.terminal[0] in ["xfce4-terminal"]:
command = " ".join(self.terminal) % "'sh -c %s'" % f"{command}"
elif self.terminal[0] in ["kitty", "foot", "konsole", "gnome-terminal"]:
command = " ".join(self.terminal) % "sh -c %s" % f"{command}"
else:
command = ' '.join(self.terminal) % "bash -c %s" % f'{command}'
command = " ".join(self.terminal) % "bash -c %s" % f"{command}"

logging.info(f"Command: {command}")

subprocess.Popen(
command,
shell=True,
env=env,
stdout=subprocess.PIPE,
cwd=cwd
command, shell=True, env=env, stdout=subprocess.PIPE, cwd=cwd
).communicate()[0].decode("utf-8")

return True

def launch_snake(self):
snake_path = os.path.dirname(os.path.realpath(__file__))
snake_path = os.path.join(snake_path, "snake.py")
self.execute(
command="python %s" % snake_path,
colors="easter"
)
self.execute(command="python %s" % snake_path, colors="easter")
4 changes: 2 additions & 2 deletions bottles/backend/wine/winecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ def _get_gamescope_cmd(self, return_steam_cmd: bool = False) -> str:
if params.gamescope_borderless:
gamescope_cmd.append("-b")
if params.gamescope_scaling:
gamescope_cmd.append("-n")
gamescope_cmd.append("-S integer")
if params.fsr:
gamescope_cmd.append("-U")
gamescope_cmd.append("-F fsr")
# Upscaling sharpness is from 0 to 20. There are 5 FSR upscaling levels,
# so multiply by 4 to reach 20
gamescope_cmd.append(
Expand Down
9 changes: 8 additions & 1 deletion bottles/frontend/windows/bottlepicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ def __select(self, *_args):
if row:
self.destroy()
subprocess.Popen(
["bottles-cli", "run", "-b", row.bottle, "-e", self.arg_exe]
[
"bottles-cli",
"run",
"-b",
f'"{row.bottle}"',
"-e",
f'"{self.arg_exe}"',
]
)

def __open(self, *_args):
Expand Down
3 changes: 3 additions & 0 deletions data/com.usebottles.bottles.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<name>Bottles</name>
<summary>Run Windows Software</summary>
<developer_name translatable="no">Bottles Contributors</developer_name>
<developer id="com.usebottles">
<name translatable="no">Bottles Contributors</name>
</developer>
<description>
<p>Bottles lets you run Windows software on Linux, such as applications and games. It introduces a workflow that helps you organize by categorizing each software to your liking. Bottles provides several tools and integrations to help you manage and optimize your applications.</p>
<p>Features:</p>
Expand Down
6 changes: 3 additions & 3 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: bottles\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-27 13:50+0530\n"
"PO-Revision-Date: 2023-08-21 21:27+0000\n"
"PO-Revision-Date: 2024-01-12 18:06+0000\n"
"Last-Translator: jonnysemon <[email protected]>\n"
"Language-Team: Arabic <https://hosted.weblate.org/projects/bottles/bottles/"
"ar/>\n"
Expand All @@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n"
"X-Generator: Weblate 5.0-dev\n"
"X-Generator: Weblate 5.4-dev\n"

#: bottles/backend/managers/backup.py:48 bottles/backend/managers/backup.py:95
msgid "No path specified"
Expand Down Expand Up @@ -409,7 +409,7 @@ msgstr "مُكّن تعيين الإصدار لهذه القارورة"

#: bottles/frontend/ui/details-bottle.blp:218
msgid "Versioning is active for this bottle."
msgstr "تعيين الإصدار نشط في هذه القارورة."
msgstr "تعيين الإصدار نشط لهذه القارورة."

#: bottles/frontend/ui/details-bottle.blp:227 bottles/frontend/ui/list-entry.blp:31
msgid "0"
Expand Down
Loading

0 comments on commit 6597c0b

Please sign in to comment.