Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
**Note: if you are using xkeyboard-config version 2.39 or newer, you already have the Windows Persian layout installed, and don't need this repo.**

I have been looking for a way to change to the keyboard layout of the Persian language for the Ubuntu operating system for a few years, which might be identical to the one I used to have while I was a windows user. This is probably the problem of most of the people who want to use Ubuntu. However, they cannot switch to it since it is almost impossible to type correctly using its predefined Persian language keyboard.

The instruction is the same. you should modify the `ir` and `evdev.xml` files. I hope it would be helpful for those who get used to the layout of windows and love to work with a real operating system.
I hope it would be helpful for those who get used to the layout of Windows and love to work with a real operating system.

Enjoy.

**Note: If your Linux distribution has a version of xkb with [!473](https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/473) merged, you already have a Windows Persian layout, and do not need this repo.**


## Automatic Installation

The automatic installer script requires `xmlstarlet` to be installed.
Install it using your package manager before running the script.

**Warning: The automatic installer does not detect any previous versions of this project. Make sure you don't already have an older version of the Windows Persian layout installed.**
**Warning: The automatic installer does not detect any previous versions of this project. If you are updating from a previous version, make sure you don't already have an older version of the Windows Persian layout installed.**

1. Clone the repository

Expand Down Expand Up @@ -43,7 +43,7 @@ cd windows-persian-keyboard-for-linux

```bash
sudo cp /usr/share/X11/xkb/symbols/ir /usr/share/X11/xkb/symbols/ir.backup
sudo cat ./ir | sudo tee -a /usr/share/X11/xkb/symbols/ir &>/dev/null
cat ./ir_patch | sudo tee -a /usr/share/X11/xkb/symbols/ir >/dev/null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This should be merged because currently the manual installation is broken.

```

3. Edit the xkb layouts registry with your text editor of choice (vim for example),
Expand All @@ -58,7 +58,7 @@ find the Persian layout and add this variant to the list of variants for Persian
```xml
<variant>
<configItem>
<name>pes_winkeys</name>
<name>winkeys</name>
<description>Persian (Windows)</description>
</configItem>
</variant>
Expand Down
6 changes: 3 additions & 3 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# https://github.com/sinadarvi/windows-persian-layout-for-linux

# Script by cs127 <https://cs127.github.io>
# 2023-03-11
# 2023-03-20

# Requirements:
# * xmlstarlet
Expand Down Expand Up @@ -33,7 +33,7 @@ XKBREG="$XKBHOME/rules/evdev.xml"

XML_IR="/xkbConfigRegistry/layoutList/layout[configItem/name='ir']"
XML_VL="$XML_IR/variantList"
XML_VL_WIN="$XML_VL/variant[configItem/name='pes_winkeys']"
XML_VL_WIN="$XML_VL/variant[configItem/name='winkeys']"
XML_VL_LAST="$XML_VL/variant[last()]"
XML_VL_LCFG="$XML_VL_LAST/configItem"

Expand All @@ -59,7 +59,7 @@ process_registry() {
! xmlstarlet ed -P -L \
-s "$XML_VL" -t elem -n "variant" \
-s "$XML_VL_LAST" -t elem -n "configItem" \
-s "$XML_VL_LCFG" -t elem -n "name" -v "pes_winkeys" \
-s "$XML_VL_LCFG" -t elem -n "name" -v "winkeys" \
-s "$XML_VL_LCFG" -t elem -n "description" -v "Persian (Windows)" \
"$XKBREG" &&
mv "$XKBREG.backup" "$XKBREG" && exitcode 12
Expand Down
28 changes: 14 additions & 14 deletions ir_patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
// ========================

partial alphanumeric_keys
xkb_symbols "pes_winkeys" {
xkb_symbols "winkeys" {
name[Group1]= "Persian (Windows)";

key <AE01> { [ Farsi_1, exclam ] };
key <AE02> { [ Farsi_2, at ] };
key <AE03> { [ Farsi_3, numbersign ] };
key <AE04> { [ Farsi_4, dollar ] };
key <AE05> { [ Farsi_5, percent ] };
key <AE06> { [ Farsi_6, asciicircum ] };
key <AE07> { [ Farsi_7, ampersand ] };
key <AE08> { [ Farsi_8, asterisk ] };
key <AE09> { [ Farsi_9, parenright ] };
key <AE10> { [ Farsi_0, parenleft ] };
key <TLDE> { [ division, multiply ] };
key <AE01> { [ 1, exclam, Farsi_1, 0x100200d ] };
key <AE02> { [ 2, at, Farsi_2, 0x100200c ] };
key <AE03> { [ 3, numbersign, Farsi_3, 0x100200e ] };
key <AE04> { [ 4, dollar, Farsi_4, 0x100200f ] };
key <AE05> { [ 5, percent, Farsi_5 ] };
key <AE06> { [ 6, asciicircum, Farsi_6 ] };
key <AE07> { [ 7, ampersand, Farsi_7 ] };
key <AE08> { [ 8, asterisk, Farsi_8 ] };
key <AE09> { [ 9, parenright, Farsi_9 ] };
key <AE10> { [ 0, parenleft, Farsi_0 ] };
key <AE11> { [ minus, underscore ] };
key <AE12> { [ equal, plus ] };

Expand Down Expand Up @@ -44,9 +45,9 @@ xkb_symbols "pes_winkeys" {
key <AC09> { [ Arabic_meem, guillemotright ] };
key <AC10> { [ Arabic_keheh, colon ] };
key <AC11> { [ Arabic_gaf, quotedbl ] };
key <TLDE> { [ division, multiply ] };

key <BKSL> { [ Arabic_peh, bar ] };

key <LSGT> { [ Arabic_peh, bar ] };
key <AB01> { [ Arabic_zah, Arabic_tehmarbuta ] };
key <AB02> { [ Arabic_tah, Arabic_yeh ] };
key <AB03> { [ Arabic_zain, Arabic_jeh ] };
Expand All @@ -58,6 +59,5 @@ xkb_symbols "pes_winkeys" {
key <AB09> { [ period, greater ] };
key <AB10> { [ slash, Arabic_question_mark ] };

include "nbsp(zwnj2nb3nnb4)"
include "level3(ralt_switch)"
};