1 Star 0 Fork 0

deepin-community/default-settings

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dde-first-run 3.38 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
# vim: set ts=4 sw=4 fileencoding=utf-8:
# Luomio <nohappiness@gmail.com>
# Filename: dde-first-run.py
# Create Date: 27-03, 13
from os import path, remove
import locale
import os
import shutil
import getpass
import re
import subprocess
from gi.repository import GLib
def querySystemType():
f = open("/etc/deepin-version", "r")
content = f.read()
r = re.search(r"^Type=(.*)$", content, re.M)
return r.group(1)
def queryXDGDesktopDir():
return GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP)
if __name__ == "__main__":
lang, charset = locale.getdefaultlocale()
sys_type = querySystemType()
desktop_path = queryXDGDesktopDir()
if path.exists("/usr/bin/dde-introduction"):
if path.exists("/usr/bin/dde-am"):
subprocess.Popen(["/usr/bin/dde-am", "dde-introduction"])
else:
subprocess.Popen("dde-introduction")
# create symlink for introduction video
# fix introduction to demo.mp4,different mirror interfaces are consistent,but the content is different
introduction_video_path = "/usr/share/dde-introduction/demo.mp4"
introduction_video_link_path = "~/Videos/dde-introduction.mp4"
if path.exists(introduction_video_path):
if path.exists(path.expanduser(introduction_video_link_path)):
remove(path.expanduser(introduction_video_link_path))
os.symlink(introduction_video_path, path.expanduser('~/Videos/dde-introduction.mp4'))
if sys_type != "Desktop":
desktops = ['dde-computer.desktop', 'dde-trash.desktop' , 'dde-home.desktop']
if not path.exists(desktop_path):
os.makedirs(desktop_path)
for desktop in desktops:
desktop_file = path.join("/usr/share/applications", desktop)
if path.exists(desktop_file):
shutil.copyfile(desktop_file, path.join(desktop_path, desktop))
chrome_config = None
if not path.exists(path.expanduser('~/.config/google-chrome')):
if path.exists('/usr/share/deepin-default-settings/google-chrome/override-chrome-config.tar'):
chrome_config = '/usr/share/deepin-default-settings/google-chrome/override-chrome-config.tar'
elif path.exists('/usr/share/deepin-default-settings/google-chrome/chrome-config-%s.tar' % lang):
chrome_config = '/usr/share/deepin-default-settings/google-chrome/chrome-config-%s.tar' % lang
elif path.exists('/usr/share/deepin-default-settings/google-chrome/chrome-config.tar'):
chrome_config = '/usr/share/deepin-default-settings/google-chrome/chrome-config.tar'
else:
chrome_config = None
if chrome_config is not None:
import tarfile
tar = tarfile.open(chrome_config)
tar.extractall(path.expanduser('~/.config/'))
tar.close()
if path.exists(path.expanduser('~/.config/google-chrome/PepperFlash/latest-component-updated-flash')):
user_name=getpass.getuser()
pepperflash = path.expanduser('~/.config/google-chrome/PepperFlash/latest-component-updated-flash')
with open(pepperflash,"r") as f:
lines = f.readlines()
with open(pepperflash,"w") as f:
for line in lines:
f.write(re.sub(r'deepin',user_name,line))
if path.exists(path.expanduser('~/.config/autostart/dde-first-run.desktop')):
remove(path.expanduser('~/.config/autostart/dde-first-run.desktop'))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/deepin-community/default-settings.git
git@gitee.com:deepin-community/default-settings.git
deepin-community
default-settings
default-settings
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385